@arcgis/core 5.1.0-next.76 → 5.1.0-next.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/analysis/ElevationProfile/ElevationProfileGroup.d.ts +74 -0
- package/analysis/ElevationProfile/ElevationProfileGroup.js +2 -0
- package/analysis/ElevationProfileAnalysis.d.ts +29 -14
- package/analysis/ElevationProfileAnalysis.js +1 -1
- package/applications/Components/OrientedImageryViewer/ImageViewer/utils.d.ts +34 -0
- package/applications/Components/OrientedImageryViewer/ImageViewer/utils.js +2 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{537fe2522dff1e6ce03b.js → 11ea4be441a26134ce1f.js} +1 -1
- package/assets/esri/core/workers/chunks/17acbf40e7c1cb42d9bd.js +1 -0
- package/assets/esri/core/workers/chunks/1c7fd0a229a8112b0539.js +596 -0
- package/assets/esri/core/workers/chunks/{baeb96aef03d4c566af7.js → 1f53620f82cc7c3daabe.js} +1 -1
- package/assets/esri/core/workers/chunks/2387613b855771a3e537.js +1 -0
- package/assets/esri/core/workers/chunks/283d39dfb1625b5a74db.js +1 -0
- package/assets/esri/core/workers/chunks/{5e1b847b116d21908a54.js → 322c54081b25f1c53661.js} +1 -1
- package/assets/esri/core/workers/chunks/{330b47ac0759c3c35cc5.js → 34fe97bcacc0dfc5bce6.js} +1 -1
- package/assets/esri/core/workers/chunks/{14eb2cc8e2ad6d8d03fd.js → 3d9fcbe95dd22dbe730e.js} +1 -1
- package/assets/esri/core/workers/chunks/{e262c4864dc06c43b380.js → 3df8493b91aa3bce824d.js} +1 -1
- package/assets/esri/core/workers/chunks/{bf8f603848bad4a7deb4.js → 4ccb56333de0247dcb6f.js} +1 -1
- package/assets/esri/core/workers/chunks/5b6f2bfdcdd207d8ae42.js +1 -0
- package/assets/esri/core/workers/chunks/{88b480a1d1fb01778798.js → 5ee4b630ad39c21d11db.js} +21 -26
- package/assets/esri/core/workers/chunks/{6b66fc32451433129a88.js → 8508f238d99021e87f71.js} +1 -1
- package/assets/esri/core/workers/chunks/{bc75ab48f4c7609ef09d.js → 85d3475667c503ec4fc6.js} +1 -1
- package/assets/esri/core/workers/chunks/{9d6491f996eeb0c646ed.js → 85d8c7cc7f8decbe975d.js} +1 -1
- package/assets/esri/core/workers/chunks/9b9916864b6575c42c8a.js +1 -0
- package/assets/esri/core/workers/chunks/{75d5ea0da181f9e7425f.js → a8ca5d8740cc7e39197b.js} +6 -6
- package/assets/esri/core/workers/chunks/{8d75f6f27c1c17c33992.js → b7bb7072dbee978f3ca3.js} +1 -1
- package/assets/esri/core/workers/chunks/bf7e019437a3b6036300.js +2 -0
- package/assets/esri/core/workers/chunks/{99c161fecae710b53b40.js → d304343a781acfa3ff96.js} +1 -1
- package/assets/esri/core/workers/chunks/dbb9bb28696ff9536678.js +2 -0
- package/assets/esri/core/workers/chunks/{34ea3ed78041437a8fc8.js → f81c6f6ccc201f584970.js} +1 -1
- package/assets/esri/themes/base/_core.scss +2 -0
- package/assets/esri/themes/base/widgets/_PluginSettingsControls.scss +29 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_en.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ar.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_bg.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_bs.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ca.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_cs.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_da.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_de.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_el.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_en.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_es.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_et.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_fi.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_fr.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_he.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_hr.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_hu.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_id.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_it.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ja.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ko.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_lt.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_lv.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_nl.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_no.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_pl.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_pt-BR.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_pt-PT.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ro.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ru.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_sk.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_sl.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_sr.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_sv.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_th.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_tr.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_uk.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_vi.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_zh-CN.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_zh-HK.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_zh-TW.json +1 -1
- package/config.js +1 -1
- package/core/types.d.ts +28 -0
- package/form/elements/inputs/MultipleChoiceInput.d.ts +2 -2
- package/form/elements/inputs/MultipleChoiceInput.js +1 -1
- package/geometry/operators/types.d.ts +2 -2
- package/interfaces.d.ts +4 -7
- package/kernel.js +1 -1
- package/layers/ImageryLayer.d.ts +7 -1
- package/layers/ImageryLayer.js +1 -1
- package/layers/ImageryTileLayer.d.ts +7 -1
- package/layers/ImageryTileLayer.js +1 -1
- package/layers/WCSLayer.d.ts +7 -1
- package/layers/WCSLayer.js +1 -1
- package/layers/save/imageryUtils.js +1 -1
- package/layers/video/VideoController.js +1 -1
- package/networks/UnitIdentifierManager.d.ts +15 -15
- package/networks/UnitIdentifierManager.js +1 -1
- package/networks/support/jsonTypes.d.ts +125 -13
- package/package.json +3 -3
- package/popup/Features.d.ts +0 -1
- package/popup/Features.js +1 -1
- package/rest/networks/unitIdentifiers/reserve.js +2 -0
- package/rest/networks/unitIdentifiers/support/ReserveParameters.js +2 -0
- package/rest/networks/unitIdentifiers/support/ResizeParameters.js +1 -1
- package/rest/networks/unitIdentifiers/support/UnitQueryResult.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/analysis/ElevationProfile/ElevationProfileVisualization2D.js +1 -1
- package/views/2d/analysis/ElevationProfileAnalysisView2D.d.ts +5 -1
- package/views/2d/analysis/ElevationProfileAnalysisView2D.js +1 -1
- package/views/2d/engine/webgl/AFeatureTile.js +1 -1
- package/views/2d/engine/webgl/effects/HittestEffect.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/featureTechniqueUtils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/AFeatureShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/LineShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/ShaderHittest.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/hittestUtils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layers/BaseLayerView2D.d.ts +3 -3
- package/views/2d/layers/BaseLayerViewGL2D.d.ts +3 -3
- package/views/2d/layers/FeatureLikeLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/2d/layers/VectorTileLayerView2D.js +1 -1
- package/views/2d/layers/features/FeatureContainer.js +1 -1
- package/views/2d/support/clippingUtils.js +1 -1
- package/views/2d/support/hitTestUtils.js +1 -1
- package/views/3d/analysis/ElevationProfile/ElevationProfileVisualization3D.js +1 -1
- package/views/3d/analysis/ElevationProfileAnalysisView3D.d.ts +5 -1
- package/views/3d/analysis/ElevationProfileAnalysisView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMeshNormals.js +1 -1
- package/views/3d/terrain/ElevationData.js +1 -1
- package/views/3d/terrain/PatchGeometryFactory.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Renderable.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js +1 -5
- package/views/3d/webgl-engine/core/shaderLibrary/util/DiscardOrAdjustAlpha.glsl.js +1 -5
- package/views/3d/webgl-engine/core/shaderLibrary/util/MixExternalColor.glsl.js +16 -21
- package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
- package/views/3d/webgl-engine/effects/magnifier/Magnifier.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
- package/views/3d/webgl-engine/shaders/BlackLevelLightSoftCompression.glsl.js +5 -1
- package/views/3d/webgl-engine/shaders/OutputColorHighlightOLID.glsl.js +2 -2
- package/views/VideoView.js +1 -1
- package/views/View2D.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileChart.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileController.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileIndicatorPointVisualization.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileResult.d.ts +6 -4
- package/views/draw/DrawTool.js +1 -1
- package/views/draw/plugins/BezierSegmentPlugin.js +1 -1
- package/views/draw/plugins/FreehandSegmentPlugin.js +1 -1
- package/views/draw/support/PluginContext.js +1 -1
- package/views/draw/support/types.d.ts +21 -0
- package/views/draw/support/types.js +1 -1
- package/views/types.d.ts +2 -2
- package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
- package/widgets/BatchAttributeForm/templates/support/hashElementTemplate.js +1 -1
- package/widgets/Daylight/DaylightViewModel.js +1 -1
- package/widgets/Daylight/support/SliderWithDropdown.js +1 -1
- package/widgets/Editor/components/Settings.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileController.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileViewModel.js +1 -1
- package/widgets/ElevationProfile/support/ElevationProfileView.js +1 -1
- package/widgets/ElevationProfile/support/ElevationProfileView2D.js +1 -1
- package/widgets/ElevationProfile/support/ElevationProfileView3D.js +1 -1
- package/widgets/ElevationProfile/support/InputRepresentation2D.js +1 -1
- package/widgets/ElevationProfile/support/InputRepresentation3D.js +1 -1
- package/widgets/ElevationProfile/support/ProfileLine2D.js +1 -1
- package/widgets/ElevationProfile/support/ProfileLines3D.js +1 -1
- package/widgets/FeatureForm/FieldInput.js +1 -1
- package/widgets/HistogramRangeSlider/HistogramRangeSliderViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerVisibleElements.d.ts +5 -5
- package/widgets/OrientedImageryViewer/OrientedImageryViewerVisibleElements.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/constants.js +1 -1
- package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
- package/widgets/OrientedImageryViewer/services/SuperimposeService.js +2 -0
- package/widgets/OrientedImageryViewer/support/superimposeUtils.js +2 -0
- package/widgets/OrientedImageryViewer/types.d.ts +10 -0
- package/widgets/OrientedImageryViewer.d.ts +17 -2
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/Sketch/support/PluginManager.js +1 -1
- package/widgets/Sketch/support/SettingsManager.js +2 -0
- package/widgets/Sketch.js +1 -1
- package/widgets/Slider/SliderViewModel.d.ts +2 -1
- package/widgets/Slider/SliderViewModel.js +1 -1
- package/widgets/Slider.js +1 -1
- package/widgets/smartMapping/ColorSlider/ColorSliderViewModel.js +1 -1
- package/widgets/smartMapping/OpacitySlider/OpacitySliderViewModel.js +1 -1
- package/widgets/smartMapping/SizeSlider/SizeSliderViewModel.js +1 -1
- package/widgets/smartMapping/SmartMappingSliderViewModel.js +1 -1
- package/widgets/support/PluginSettingsControls.js +2 -0
- package/widgets/support/SnappingControls.js +1 -1
- package/widgets/support/forms/formUtils.js +1 -1
- package/analysis/ElevationProfile/elevationProfileLineTypes.js +0 -2
- package/assets/esri/core/workers/chunks/003476e950bd27a2f884.js +0 -596
- package/assets/esri/core/workers/chunks/07aca5ecad659d55e795.js +0 -2
- package/assets/esri/core/workers/chunks/7540f7df86620f067b5a.js +0 -1
- package/assets/esri/core/workers/chunks/76e34f81bb4a7b0e694c.js +0 -1
- package/assets/esri/core/workers/chunks/bfe575da727ce7c8d331.js +0 -2
- package/assets/esri/core/workers/chunks/cb45e5d4a4ef82cda583.js +0 -1
- package/assets/esri/core/workers/chunks/ea59b81299acaf0d85ee.js +0 -1
- package/assets/esri/core/workers/chunks/ef0eae13408cbf83a64f.js +0 -1
- package/rest/networks/unitIdentifiers/insertGap.js +0 -2
- package/rest/networks/unitIdentifiers/support/InsertGapParameters.js +0 -2
- /package/assets/esri/core/workers/chunks/{07aca5ecad659d55e795.js.LICENSE.txt → bf7e019437a3b6036300.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{bfe575da727ce7c8d331.js.LICENSE.txt → dbb9bb28696ff9536678.js.LICENSE.txt} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as r}from"../../../core/maybe.js";import{throwIfAborted as s}from"../../../core/promiseUtils.js";import{initial as o,watch as n,when as a}from"../../../core/reactiveUtils.js";import{schedule as l}from"../../../core/scheduling.js";import{property as d,subclass as c}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as h,invert as u,fromQuat as m}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as p,IDENTITY as f}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as y}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as g,sub as _,dot as v,set as w,transformMat3 as x,add as j}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as T,freeze as C,clone as M,fromValues as R,ZEROS as E}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{clone as O,fromValues as U,ONES as V}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMoon as S,isMars as A,getReferenceEllipsoid as H,SphericalECEFSpatialReferenceLike as P}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as L}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as k}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as I}from"../../../geometry/projection/projectVectorToVector.js";import{create as D}from"../../../geometry/support/aaBoundingRect.js";import{getContinuousIndexArray as F}from"../../../geometry/support/Indices.js";import{isCGCS2000 as B}from"../../../geometry/support/spatialReferenceUtils.js";import{BufferViewVec4f as G,BufferViewVec4u8 as z,BufferViewVec4u16 as N,BufferViewVec3f as q,BufferViewVec3u8 as W,BufferViewVec3u16 as $,BufferViewVec2f as Q,BufferViewInt16 as Z,BufferViewUint32 as J,BufferViewUint16 as X,BufferViewVec2i16 as Y}from"../../../geometry/support/buffer/BufferView.js";import K from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as ee}from"../../../support/elevationInfoUtils.js";import{addNormals as te}from"./IntegratedMeshNormals.js";import{LayerView3D as ie}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as re}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as se,removeLayerViewFromWasm as oe,getLyr3DWasm as ne}from"./Lyr3DWasm.js";import{toWasmModification as ae}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as le}from"./i3s/LayerElevationProvider.js";import{IntegratedMesh3DTilesLayerView3DSymbol as de}from"./support/integratedMesh3DTilesLayerViewInstanceUtils.js";import{primTypeConversion as ce,alphaModeConversion as he,faceCullingConversion as ue,wrapModeConversion as me,lyr3DTypeToByteSize as pe}from"./support/lyr3dTypeConversions.js";import{Tiles3DMeshIntersectionHandler as fe}from"./support/Tiles3DMeshIntersectionHandler.js";import{Frustum as be}from"../state/Frustum.js";import{ElevationRange as ye}from"../support/ElevationRange.js";import{toBoundingRect as ge}from"../support/extentUtils.js";import{Obb as _e,compute as ve}from"../support/orientedBoundingBox.js";import{glLayout as we}from"../support/buffer/glUtil.js";import{VertexBufferLayoutCreationParameters as xe,createVertexBufferLayout as je,ComponentGeometryParameters as Te,SourceGeometry as Ce}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as Me}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as Re}from"../webgl-engine/core/material/RenderTexture.js";import{Attribute as Ee}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as Oe}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as Ue}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as Ve}from"../webgl-engine/materials/pbrUtils.js";import Se from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as Ae,isInEffectiveScaleRange as He,validateScaleRange as Pe}from"../../support/layerViewUtils.js";import{PromiseQueue as Le}from"../../support/PromiseQueue.js";import{TaskPriority as ke}from"../../support/Scheduler.js";import{TextureCompressionTracker as Ie}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as De}from"../../../webscene/support/AlphaCutoff.js";var Fe;let Be=class extends(ie(Se)){static{Fe=de}constructor(e){super(e),this[Fe]=!0,this.type="integrated-mesh-3dtiles",this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._replacesTerrain=!1,this._isUsedAsGroundLayer=!1,this._applySSAO=!has("disable-feature:im-ssao"),this._imShading=!!has("enable-feature:im-shading"),this._imVertexNormals=!!has("enable-feature:im-vertex-normals"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._compressionTracker=new Ie,this._createRenderableQueue=new Le,this._dbgFlags=new Set;const t=e.view.resourceController;this._memCache=t.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._replacesTerrain=e.layer.replacesTerrain,this._isUsedAsGroundLayer=e.layer.isUsedAsGroundLayer,this._frameTask=t.scheduler.registerTask(ke.TILES3D,this),this._frustum=new be(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{s(t);const i=this.layer.queryElevationCallback;this.layer=e,this.layer.queryElevationCallback=i}):null}canRecycleWith(e){return e.url===this.layer.url&&"integrated-mesh-3dtiles"===e.type&&e.replacesTerrain===this._replacesTerrain&&e.isUsedAsGroundLayer===this._isUsedAsGroundLayer}initialize(){this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o),!this._canProjectWithoutEngine())throw Ae("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=se(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new fe(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged()),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),o),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),o),this._elevationProvider=new le({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler});const i=this._replacesTerrain?0:1;e.elevationProvider.register(i,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([n(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),a(()=>this.fullOpacity,()=>this._opacityChange()),n(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),o)])});this.layer.queryElevationCallback=(e,t)=>this._wasm.queryElevation(this,e,t),this.addResolvingPromise(t)}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),oe(this),this.layer.queryElevationCallback=null,this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler.destroy(),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._loadedObjects.clear(),this._usedMemory=0,this._cacheMemory=0,this._memCache.destroy(),this._createRenderableQueue.destroy(),this.notifyChange("readyToRun"),this._frameTask.remove(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=r(this._visibleGeometryChangedSchedulerHandle)}get fullOpacity(){return this.layer.replacesTerrain?this.view.map.ground.opacity:1}get hasModifications(){return this._modifications&&this._modifications.length>0}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>this._collection.updateObjectOpacity(t,e))}_cameraChanged(){const e=this._frustum;e.update(this.view.state.contentCamera);const t=this._visibleObjects;let i=!1;this._loadedObjects.forEach(r=>{const s=r.obb?.intersectsFrustum(e)??!1;s!==r.isVisible&&(r.isVisible=s,s?t.add(r):t.delete(r),r.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,s)),i||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(s,r.elevationRange))}),i&&this._setVisibleElevationRangeDirty()}intersect(e,t,i,r){this._intersectionHandler.intersect(e,t,i,r,null,!1)}get ready(){return!this.layer.replacesTerrain||!!this._wasm?.isTerrainReady}_modificationsChanged(){const e=this.layer.spatialReference,t=ae(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=D();this._layerClippingArea=ge(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=l(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.layer.replacesTerrain),this.forEachComponentObject(t=>t.updateMaterial({slicePlaneEnabled:e}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,ee(e))}get _wasm(){return ne(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return this.layer.isUsedAsGroundLayer||He(this.layer.effectiveScaleRange,this.view.scale)}canResume(){const e=this.layer&&"effectiveScaleRange"in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&this.parent&&!this.parent.suspended&&this.view?.ready&&(this.layer.isUsedAsGroundLayer||Pe(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,i=0,r=0,s=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isLoaded?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,s++):(i+=n.textureMemoryUsage,r+=n.vboMemoryUsage,o++)}),new re(this.usedMemory,s,o,Ne(t),Ne(e),Ne(r),Ne(i))}_canProjectWithoutEngine(){if(this.view.state.isLocal){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return ee(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new ye(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new ye;0===this._visibleObjects.size?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this._forEachRelevantVisibleTile(t=>e.expandElevationRange(t.elevationRange)),e.minElevation===1/0&&e.setElevationRangeValues(0,0));const t=this._get("visibleElevationRange");return t&&t.minElevation===e.minElevation&&t.maxElevation===e.maxElevation?t:e}_setVisibleElevationRangeDirty(){this.notifyChange("visibleElevationRange")}_forEachRelevantVisibleTile(e){const{view:t}=this,{spatialReference:i}=t,r=i.isWGS84||i.isWebMercator||B(i)||S(i)||A(i);if(this.view.state.isGlobal||!r)return this.forEachVisibleTile(e);const s=H(i).radius,{eye:o,viewForward:n,near:a}=t.state.camera,l=g(T(),n),d=500,c=Math.max(o[2],d),h=c+s,u=Math.sqrt(h**2-s**2),m=Math.abs(Math.atan2(u,s))*s,p=c>.5*s?.5*Math.PI*s:m,f=T();this.forEachVisibleTile(t=>{const{mbsRadius:i,mbsCenter:r}=t;if(i<0)return;_(f,r,o);const s=v(f,l);Math.abs(s)<p&&s+i>a&&s-i<p&&e(t)})}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachTile(e){for(const t of this._loadedObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const{componentObjects:i}of e)for(const e of i)t(e)}isUpdating(){const e=this._wasm;return this._wasmLayerId>=0&&null!=e&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}get readyToRun(){return!!this._frameTask?.readyToRun||this._createRenderableQueue.readyToRun}runTask(e){this._frameTask.processQueue(e),this._createRenderableQueue.runTask(e),this.notifyChange("readyToRun")}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed||this.destroying)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy");return this._createRenderable(e)}async _createRenderable(e){if(this.destroyed){const e=`IntegratedMesh3DTilesLayerView3D[${this.layer?.title}]: createRenderable called on destroyed instance`;throw this._dbg(3,e),new Error(e)}const{meshData:t}=e;if(null==t.data)throw new Error("meshData.data undefined");if("string"==typeof t.desc&&(t.desc=JSON.parse(t.desc)),null==t.desc)throw new Error("meshData.desc undefined");const i=t.desc,r=t.data.buffer,s={textureMemoryUsage:0},o=new Map,n=i.prims.length,a=i.materials,l=e=>this._getTexture(e,t,o,s);let d;try{d=this._createPrimitiveTextureBundles(n,i,a,l)}catch(u){throw o.forEach(e=>this._stage.removeTexture(e)),u}const c=new Array,h=new ye;try{const t=this._createRenderableQueue.push(()=>this._createRenderableMain(i,r,n,a,d,o,c,h),null);this.notifyChange("readyToRun");const l=await t;if(this.destroyed)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable aborted due to destroyed instance");if(await Promise.all(d.map(e=>e.materialPromise)),this.destroyed)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable aborted due to destroyed instance");for(const e of l.textureMemoryUsageEvaluators)s.textureMemoryUsage+=e();const u=new ze(e.handle,c,l.textures,l.cpuMemoryUsage,l.vboMemoryUsage,s.textureMemoryUsage,l.tileObb,e.stableNodeId,e.nodeDepth,h);this._lyrHandleToObjects.set(e.handle,u),this._memCache.put(Qe(u.handle),u);const{usedMemory:m}=u;return this._cacheMemory+=m,{memUsageBytes:m}}catch(u){throw d.forEach(e=>e.cleanup()),c.forEach(e=>this._collection.destroyObject(e)),o.forEach(e=>this._stage.removeTexture(e)),u}}_createPrimitiveTextureBundles(e,t,i,r){const s=new Array;try{for(let o=0;o<e;o++){const e=t.prims[o],n=i&&null!=e.materialId?i[e.materialId]:null;let a=Promise.resolve(Ze),l=null,d=null,c=null,h=null,u=null;if(n){const e="Pbr"===n.lightingModel;l=r(n.baseColorTex),d=e?r(n.metalTex):null,c=e?r(n.emissiveTex):null,h=e?r(n.occlusionTex):null,u=e?r(n.normalTex):null;const t=[l,d,c,h,u].map(e=>e?.loadPromise??null);a=Promise.all(t)}s.push({materialPromise:a,baseColorTexture:l,metallicRoughnessTexture:d,emissionTexture:c,occlusionTexture:h,normalTexture:u,cleanup:()=>{l?.dispose(),d?.dispose(),c?.dispose(),h?.dispose(),u?.dispose()}})}}catch(o){throw s.forEach(e=>e.cleanup()),o}return s}_createRenderableMain(e,t,i,r,s,o,n,a){let l=0;const d=C(...e.origin),c=this.view.basemapTerrain.spatialReference,m=this.view.state.isGlobal;let y=f;if(m){const e=b();L(P,d,e,c),y=h(p(),e)}if(null==e.obb)throw new Error("meshData.desc.obb undefined");const g=$e(e.obb),_=m?H(this.view.spatialReference).radius:0,v=y!==f,x=v?u(p(),y)??f:f,j=T(),E=new Array;for(let h=0;h<i;h++){const i=e.prims[h],o=s[h];this._dbgFlags.has(2)&&this._dbg(2,JSON.stringify(i));if(null==ce[i.ptype]){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+i.ptype+"). Skipping primitive."),o.cleanup();continue}const u=r&&null!=i.materialId?r[i.materialId]:null,p=null!=u?u.lightingModel:"Unlit",{positionView:f,positionAttr:b,normalsView:C,normalsAttr:S,colorAttr:A,texCoord0Attr:H,indicesView:P}=this.getBufferViews(i,t,y);if(null==b||null==f||null==P){o.cleanup();continue}const L=f.count,D=(e,t)=>!e||e.data.length/e.size===L||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!D(H,"numTexcoord")||!D(A,"numColors")||!D(S,"normals")){o.cleanup();continue}const F=new xe(null!=A,null!=C,H?1:0),B=je(F),G=B.createBuffer(L);Je({origin:d,ellipsoidRadius:_,isGlobal:m,ecefRotation:y},{texCoord0Attr:H,colorAttr:A,normalsAttr:S},G,{positionView:f,tileObb:g,obbHalfSizeAccumulator:j,elevationRange:a});const z=g?.clone()??We(b,d),N=new Uint32Array([0,P.typedBuffer.length]),q=we(B),W=this._imVertexNormals,$=te(new Uint8Array(G.buffer),P.typedBuffer,q,W,W?x:void 0),Q=new Te(q,this._imShading?2:0,F.textureCoordinateType,v?1:0,0),Z=new Ce({interleavedVertexData:$.data,vertexCount:$.data.byteLength/q[0].stride,indexData:$.indices},{positions:f.typedBuffer,indices:P.typedBuffer},N,Q),J=this.view.renderSpatialReference,X=T(),Y=[1,1,1];k(d,J,Y,c)||this._dbg(3,"Unsupported coordinate system for IM overlay"),I(d,J,X,c);let K=V,ee=De,ie=null,re=null,se=null,oe=null,ne=null,ae=1,le=!1,de=2,me=!1,pe=R(0,0,0);const fe=M(Ve),be="Pbr"===p;if(u&&(ie=o.baseColorTexture,ne=o.metallicRoughnessTexture,re=o.emissionTexture,oe=o.occlusionTexture,se=o.normalTexture,K=O(u.baseColorFactor),ee=u.alphaCutoff??De,be&&(w(fe,u.metallicFactor,u.roughnessFactor,0),u.emissiveFactor&&(pe=u.emissiveFactor)),ae=he[u.alphaMode],le=u.isDoubleSided,de=ue[u.faceCulling??"NotSet"],me=this.layer.replacesTerrain),this.destroyed){const e="Trying to add object to destroyed layer view";throw this._dbg(3,`${e} !== numPos. Skipping primitive.`),new Error(e)}ie||this._dbg(3,"No colour texture 1");const ye=this._collection.createObject({toMapSpace:U(X[0],X[1],Y[0],Y[1]),transform:new Me(d,x),obb:z,geometry:Z,elevationAlignable:!1},{isIntegratedMesh:!0,baseColor:K,textureAlphaCutoff:ee,mrrFactors:fe,baseColorTexture:ie,metallicRoughnessTexture:ne,normalTexture:se,occlusionTexture:oe,emissionTexture:re,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:ae,doubleSided:le,cullFace:de,isGround:me,emissiveBaseColor:pe,usePBR:be,slicePlaneEnabled:this.slicePlaneEnabled,opacity:this.fullOpacity,polygonOffset:0,ellipsoidMode:1,applySSAO:this._applySSAO});E.push(()=>{let e=ie?.texture?.usedMemory??0;return be&&(e+=(ne?.texture?.usedMemory??0)+(re?.texture?.usedMemory??0)+(oe?.texture?.usedMemory??0)+(se?.texture?.usedMemory??0)),e}),l+=this._collection.getObjectGPUMemoryUsage(ye),n.push(ye)}const S=Array.from(o.values()),{fullExtent:A}=this.layer;A?.hasZ&&A.zmax&&A.zmin&&(a.minElevation=Math.max(a.minElevation,A.zmin),a.maxElevation=Math.min(a.maxElevation,A.zmax));return{vboMemoryUsage:l,tileObb:g,textureMemoryUsageEvaluators:E,textures:S,cpuMemoryUsage:n.reduceRight((e,t)=>e+t.intersectionGeometry.usedMemory,0)}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._intersectionHandler.removeTile(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e)):this._dbg(3,`freeRendedrable on non-existent renderable ${e}`)}freeObject(e){const t=Qe(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){if(this.destroyed||this.destroying)return;const r=this._frustum,s=new Array;let o=!1,n=!1;for(let a=0;a<i;++a){if(!t[a])continue;const i=e[a],l=this._lyrHandleToObjects.get(i);if(l){if(l.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${l.stableNodeId}`);continue}o=!0,l.isLoaded=!0,this._loadedObjects.add(l),this._intersectionHandler.addTile(l),this._usedMemory+=l.usedMemory,this._cacheMemory-=l.usedMemory;const e=l.obb?.intersectsFrustum(r)??!0;l.isVisible=e,e&&(this._visibleObjects.add(l),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,l.elevationRange)),e&&l.obb&&s.push(l.obb),l.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(Qe(i))}else this._dbg(3,`Tried to mark Non existent object ${i} as loaded`)}for(let a=0;a<i;++a){const i=e[a];if(t[a])continue;const r=this._lyrHandleToObjects.get(i);if(r){if(!r.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${r.stableNodeId}`);continue}const e=r.isVisible;this._visibleObjects.delete(r),r.isVisible=!1,r.isLoaded=!1,this._loadedObjects.delete(r),this._intersectionHandler.removeTile(r),e&&(this._visibleGeometryChanged(),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,r.elevationRange)),this._usedMemory-=r.usedMemory,this._cacheMemory+=r.usedMemory,e&&r.obb&&s.push(r.obb),r.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(Qe(i),r)}else this._dbg(3,`Tried to mark Non existent object ${i} as not loaded`)}o&&this._visibleGeometryChanged(),this._elevationProvider.notifyObjectsChanged(s),n&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){const{visibleElevationRange:i}=this,{minElevation:r,maxElevation:s}=t;return e?r<i.minElevation||s>i.maxElevation:r===i.minElevation||s===i.maxElevation}_getTexture(e,t,i,r){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const o=i.get(s)??this._createTexture(e,t,i,r);return o?new Re(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,r){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!s.mipCount||a>1,d=me[e.wrapMode??"None"];let c=s.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,s.data.byteOffset,s.data.byteCount);let u=null,m=null,p=null;switch(s.format){case"Raw":"R8"===s.pixelFormat?(u=h,c=6403,m=""):"Rgb8"===s.pixelFormat?(u=h,c=6407,m=""):"Rgba8"===s.pixelFormat&&(u=h,c=6408,m="");break;case"Dxt1":u=h,c=6407,m="image/vnd-ms.dds";break;case"Dxt5":u=h,c=6408,m="image/vnd-ms.dds";break;case"Basis":u=h,c=6407,m="image/ktx2";break;case"Png":m="image/png",p=document.createElement("img");break;case"Jpeg":m="image/jpeg",p=document.createElement("img");break;case"Etc2":m="image/ktx",p=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(p&&m){const e=new Blob([h],{type:m});p.src=URL.createObjectURL(e),u=p}if(u&&null!=m){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(r.textureMemoryUsage-=e)}}:void 0,t=new Oe(u,{mipmap:l,maxAnisotropy:a,encoding:m,wrap:d,pixelFormat:c,compressionOptions:e,noUnpackFlip:!0,width:s.mip0Width,height:s.mip0Height});return this._stage.addTexture(t),i.set(s,t),t}return null}getBufferViews(e,t,i){let r,s,o,n,a,l,d,c=null;for(let u=0;u<e.atrbs.length;u++){const d=e.atrbs[u],{view:m}=d,p=void 0,f=m.byteOffset+m.byteCount,b=m.byteCount/pe[m.type],y=F(b);try{switch(d.sem){case"Position":3!==m.ncomp||"F32"!==m.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+m+")"):(r=new q(t,m.byteOffset,p,f),s=new Ee(r.typedBuffer,y,3));break;case"Normal":if(3!==m.ncomp||"F32"!==m.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+m+")");else{const e=new q(t,m.byteOffset,p,f),r=Ue(e.typedBuffer,i);a=new Z(r.buffer),l=new Ee(a.typedBuffer,y,2)}break;case"TexCoord":2!==m.ncomp||"F32"!==m.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+m+")"):void 0===n&&(n=new Ee(new Q(t,m.byteOffset,p,f).typedBuffer,y,2));break;case"Color":4===m.ncomp?("F32"===m.type&&(c=new G(t,m.byteOffset,p,f)),"U8"===m.type&&(c=new z(t,m.byteOffset,p,f)),"U16"===m.type&&(c=new N(t,m.byteOffset,p,f))):3===m.ncomp&&("F32"===m.type&&(c=new q(t,m.byteOffset,p,f)),"U8"===m.type&&(c=new W(t,m.byteOffset,p,f)),"U16"===m.type&&(c=new $(t,m.byteOffset,p,f))),null==c?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+m+")"):o=new Ee(c.typedBuffer,y,m.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+d.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,r=void 0,s=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":d=new X(t,i.byteOffset,r,s);break;case"U32":d=new J(t,i.byteOffset,r,s);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==d&&null!=r){const e=r.count;d=d=e<65535?new X(new Uint16Array(e).buffer):new J(new Uint32Array(e).buffer);for(let t=0;t<e;t++)d.set(t,t)}return{positionView:r,positionAttr:s,colorAttr:o,texCoord0Attr:n,indicesView:d,normalsView:a,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>!(this.layer.isUsedAsGroundLayer&&"replace"!==e.type)).toArray(),this._modifications.length<e.length&&t.getLogger(this).info("Ground layers only support replace modifications. Other modification types have been ignored.")},o),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([d()],Be.prototype,"fullOpacity",null),e([d({readOnly:!0})],Be.prototype,"ready",null),e([d({type:[K]})],Be.prototype,"_modifications",void 0),e([d()],Be.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([d()],Be.prototype,"layer",void 0),e([d({readOnly:!0})],Be.prototype,"visibleAtCurrentScale",null),e([d({readOnly:!0})],Be.prototype,"_collection",null),e([d()],Be.prototype,"elevationOffset",null),e([d({readOnly:!0})],Be.prototype,"visibleElevationRange",null),Be=e([c("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Be);const Ge=Be;class ze{constructor(e,t,i,r,s,o,n,a,l,d){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=r,this.vboMemoryUsage=s,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.nodeDepth=l,this.elevationRange=d,this.bvhIntersectionGeneration=0,this.isLoaded=!1,this.isVisible=!1;const c=T();n?.getCenter(c),this._obbCenterX=c[0],this._obbCenterY=c[1],this._obbCenterZ=c[2];const h=n?.radius??-1;this._obbRadius=h,this._obbRadiusSquared=h*h;const u=n?.halfSize;this._obbShortestHalfsize=u?Math.min(u[0],u[1],u[2]):0,this._mbsCenter=n?M(n.center):E}get usedMemory(){return this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}get mbsRadius(){return this._obbRadius}get mbsCenter(){return this._mbsCenter}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const{_obbCenterX:i,_obbCenterY:r,_obbCenterZ:s}=this,o=i-e[0],n=r-e[1],a=s-e[2],l=o*t[0]+n*t[1]+a*t[2];return o*o+n*n+a*a-l*l<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){const t=this._obbRadius;if(t<0)return!0;const i=e.center,r=e.radius,s=t+r,o=this._obbCenterX-i[0];if(o>s)return!1;const n=this._obbCenterY-i[1];if(n>s)return!1;const a=this._obbCenterZ-i[2];if(a>s)return!1;const l=o*o+n*n+a*a;if(l>s*s)return!1;if(l<=(this._obbShortestHalfsize+r)**2)return!0;return Math.sqrt(l)+t<=r||(this.obb?.intersectSphere(e)??!0)}}function Ne(e){return Math.round(e/1048.576)/1e3}const qe=T();function We(e,t){const i=ve(e);return j(qe,i.center,t),i.center=qe,i}function $e(e){return new _e(e.center,e.halfSize,y(...e.quaternion))}function Qe(e){return`${e}`}const Ze=new Array;function Je(e,t,i,r){const{origin:s,ellipsoidRadius:o,isGlobal:n,ecefRotation:a}=e,{texCoord0Attr:l,colorAttr:d,normalsAttr:c}=t,{positionView:h,tileObb:u,obbHalfSizeAccumulator:p,elevationRange:b}=r,y=i.getField("position",q),g=y.typedBuffer,_=y.typedBufferStride,v=l?.data,w=null!=l?i.getField("uv0",Q):null,j=w?.typedBuffer,T=w?.typedBufferStride??0,C=d?.data,M=d?.size??0,R=null!=d?i.getField("color",z):null,O=R?.typedBuffer,U=R?.typedBufferStride??0,V=c?.data,S=null!=c?i.getField("normalCompressed",Y):null,A=S?.typedBuffer,H=S?.typedBufferStride??0,P=null!=u?m(Ye,u.quaternionConjugate):f,L=x(Xe,u?.center??E,P),k=P[0],I=P[1],D=P[2],F=P[3],B=P[4],G=P[5],N=P[6],W=P[7],$=P[8],Z=L[0],J=L[1],X=L[2],K=a[0],ee=a[1],te=a[2],ie=a[3],re=a[4],se=a[5],oe=a[6],ne=a[7],ae=a[8],le=a!==f,de=s[0],ce=s[1],he=s[2],ue=h.count,me=h.typedBufferStride,pe=h.typedBuffer,fe=null!=j&&null!=v,be=null!=O&&null!=C&&(3===M||4===M),ye=4===M,ge=null!=A&&null!=V,_e=null!=p;let ve=_e?p[0]:0,we=_e?p[1]:0,xe=_e?p[2]:0;for(let m=0;m<ue;++m){const e=m*me,t=pe[e],i=pe[e+1],r=pe[e+2],s=t+de,a=i+ce,l=r+he,d=n?Math.sqrt(s*s+a*a+l*l)-o:l;if(b.expandElevationRangeValues(d,d),_e){const e=Math.abs(s*k+a*F+l*N-Z),t=Math.abs(s*I+a*B+l*W-J),i=Math.abs(s*D+a*G+l*$-X);ve=Math.max(ve,e),we=Math.max(we,t),xe=Math.max(xe,i)}const c=m*_;if(le){const s=t*K+i*ie+r*oe,o=t*ee+i*re+r*ne,n=t*te+i*se+r*ae;pe[e]=s,pe[e+1]=o,pe[e+2]=n,g[c]=s,g[c+1]=o,g[c+2]=n}else g[c]=t,g[c+1]=i,g[c+2]=r;if(fe){const e=2*m,t=m*T;j[t]=v[e],j[t+1]=v[e+1]}if(be){const e=m*U;if(ye){const t=4*m;O[e]=C[t],O[e+1]=C[t+1],O[e+2]=C[t+2],O[e+3]=C[t+3]}else{const t=3*m;O[e]=C[t],O[e+1]=C[t+1],O[e+2]=C[t+2],O[e+3]=255}}if(ge){const e=2*m,t=m*H;A[t]=V[e],A[t+1]=V[e+1]}}u&&_e&&(p[0]=ve,p[1]=we,p[2]=xe,u.setHalfSize(ve,we,xe))}const Xe=T(),Ye=p();export{Ge as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as s}from"../../../core/maybe.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{initial as o,watch as n,when as a}from"../../../core/reactiveUtils.js";import{schedule as l}from"../../../core/scheduling.js";import{property as c,subclass as d}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as h,invert as u,fromQuat as m}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as p,IDENTITY as f}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as y}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as g,sub as _,dot as v,set as w,transformMat3 as x,add as T}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as j,freeze as C,clone as M,fromValues as R,ZEROS as E}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{clone as O,fromValues as U,ONES as V}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMoon as S,isMars as A,getReferenceEllipsoid as H,SphericalECEFSpatialReferenceLike as P}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as L}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as k}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as I}from"../../../geometry/projection/projectVectorToVector.js";import{create as D}from"../../../geometry/support/aaBoundingRect.js";import{getContinuousIndexArray as F}from"../../../geometry/support/Indices.js";import{isCGCS2000 as B}from"../../../geometry/support/spatialReferenceUtils.js";import{BufferViewVec4f as G,BufferViewVec4u8 as z,BufferViewVec4u16 as N,BufferViewVec3f as q,BufferViewVec3u8 as W,BufferViewVec3u16 as $,BufferViewVec2f as Q,BufferViewInt16 as Z,BufferViewUint32 as J,BufferViewUint16 as X,BufferViewVec2i16 as Y}from"../../../geometry/support/buffer/BufferView.js";import K from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as ee}from"../../../support/elevationInfoUtils.js";import{addNormals as te}from"./IntegratedMeshNormals.js";import{LayerView3D as ie}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as se}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as re,removeLayerViewFromWasm as oe,getLyr3DWasm as ne}from"./Lyr3DWasm.js";import{toWasmModification as ae}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as le}from"./i3s/LayerElevationProvider.js";import{IntegratedMesh3DTilesLayerView3DSymbol as ce}from"./support/integratedMesh3DTilesLayerViewInstanceUtils.js";import{primTypeConversion as de,alphaModeConversion as he,faceCullingConversion as ue,wrapModeConversion as me,lyr3DTypeToByteSize as pe}from"./support/lyr3dTypeConversions.js";import{Tiles3DMeshIntersectionHandler as fe}from"./support/Tiles3DMeshIntersectionHandler.js";import{Frustum as be}from"../state/Frustum.js";import{ElevationRange as ye}from"../support/ElevationRange.js";import{toBoundingRect as ge}from"../support/extentUtils.js";import{Obb as _e,compute as ve}from"../support/orientedBoundingBox.js";import{glLayout as we}from"../support/buffer/glUtil.js";import{VertexBufferLayoutCreationParameters as xe,createVertexBufferLayout as Te,ComponentGeometryParameters as je,SourceGeometry as Ce}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as Me}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as Re}from"../webgl-engine/core/material/RenderTexture.js";import{Attribute as Ee}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as Oe}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as Ue}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as Ve}from"../webgl-engine/materials/pbrUtils.js";import Se from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as Ae,isInEffectiveScaleRange as He,validateScaleRange as Pe}from"../../support/layerViewUtils.js";import{PromiseQueue as Le}from"../../support/PromiseQueue.js";import{TaskPriority as ke}from"../../support/Scheduler.js";import{TextureCompressionTracker as Ie}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as De}from"../../../webscene/support/AlphaCutoff.js";var Fe;let Be=class extends(ie(Se)){static{Fe=ce}constructor(e){super(e),this[Fe]=!0,this.type="integrated-mesh-3dtiles",this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._replacesTerrain=!1,this._isUsedAsGroundLayer=!1,this._applySSAO=!has("disable-feature:im-ssao"),this._imShading=!!has("enable-feature:im-shading"),this._imVertexNormals=!!has("enable-feature:im-vertex-normals"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._compressionTracker=new Ie,this._createRenderableQueue=new Le,this._dbgFlags=new Set;const t=e.view.resourceController;this._memCache=t.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._replacesTerrain=e.layer.replacesTerrain,this._isUsedAsGroundLayer=e.layer.isUsedAsGroundLayer,this._frameTask=t.scheduler.registerTask(ke.TILES3D,this),this._frustum=new be(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{r(t);const i=this.layer.queryElevationCallback;this.layer=e,this.layer.queryElevationCallback=i}):null}canRecycleWith(e){return e.url===this.layer.url&&"integrated-mesh-3dtiles"===e.type&&e.replacesTerrain===this._replacesTerrain&&e.isUsedAsGroundLayer===this._isUsedAsGroundLayer}initialize(){this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o),!this._canProjectWithoutEngine())throw Ae("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=re(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new fe(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged()),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),o),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),o),this._elevationProvider=new le({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler});const i=this._replacesTerrain?0:1;e.elevationProvider.register(i,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([n(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),a(()=>this.fullOpacity,()=>this._opacityChange()),n(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),o)])});this.layer.queryElevationCallback=(e,t)=>this._wasm.queryElevation(this,e,t),this.addResolvingPromise(t)}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),oe(this),this.layer.queryElevationCallback=null,this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler.destroy(),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._loadedObjects.clear(),this._usedMemory=0,this._cacheMemory=0,this._memCache.destroy(),this._createRenderableQueue.destroy(),this.notifyChange("readyToRun"),this._frameTask.remove(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=s(this._visibleGeometryChangedSchedulerHandle)}get fullOpacity(){return this.layer.replacesTerrain?this.view.map.ground.opacity:1}get hasModifications(){return this._modifications&&this._modifications.length>0}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>this._collection.updateObjectOpacity(t,e))}_cameraChanged(){const e=this._frustum;e.update(this.view.state.contentCamera);const t=this._visibleObjects;let i=!1;this._loadedObjects.forEach(s=>{const r=s.obb?.intersectsFrustum(e)??!1;r!==s.isVisible&&(s.isVisible=r,r?t.add(s):t.delete(s),s.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,r)),i||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(r,s.elevationRange))}),i&&this._setVisibleElevationRangeDirty()}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}get ready(){return!this.layer.replacesTerrain||!!this._wasm?.isTerrainReady}_modificationsChanged(){const e=this.layer.spatialReference,t=ae(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=D();this._layerClippingArea=ge(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=l(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.layer.replacesTerrain),this.forEachComponentObject(t=>t.updateMaterial({slicePlaneEnabled:e}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,ee(e))}get _wasm(){return ne(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return this.layer.isUsedAsGroundLayer||He(this.layer.effectiveScaleRange,this.view.scale)}canResume(){const e=this.layer&&"effectiveScaleRange"in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&this.parent&&!this.parent.suspended&&this.view?.ready&&(this.layer.isUsedAsGroundLayer||Pe(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,i=0,s=0,r=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isLoaded?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,r++):(i+=n.textureMemoryUsage,s+=n.vboMemoryUsage,o++)}),new se(this.usedMemory,r,o,Ne(t),Ne(e),Ne(s),Ne(i))}_canProjectWithoutEngine(){if(this.view.state.isLocal){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return ee(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new ye(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new ye;0===this._visibleObjects.size?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this._forEachRelevantVisibleTile(t=>e.expandElevationRange(t.elevationRange)),e.minElevation===1/0&&e.setElevationRangeValues(0,0));const t=this._get("visibleElevationRange");return t&&t.minElevation===e.minElevation&&t.maxElevation===e.maxElevation?t:e}_setVisibleElevationRangeDirty(){this.notifyChange("visibleElevationRange")}_forEachRelevantVisibleTile(e){const{view:t}=this,{spatialReference:i}=t,s=i.isWGS84||i.isWebMercator||B(i)||S(i)||A(i);if(this.view.state.isGlobal||!s)return this.forEachVisibleTile(e);const r=H(i).radius,{eye:o,viewForward:n,near:a}=t.state.camera,l=g(j(),n),c=500,d=Math.max(o[2],c),h=d+r,u=Math.sqrt(h**2-r**2),m=Math.abs(Math.atan2(u,r))*r,p=d>.5*r?.5*Math.PI*r:m,f=j();this.forEachVisibleTile(t=>{const{mbsRadius:i,mbsCenter:s}=t;if(i<0)return;_(f,s,o);const r=v(f,l);Math.abs(r)<p&&r+i>a&&r-i<p&&e(t)})}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachTile(e){for(const t of this._loadedObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const{componentObjects:i}of e)for(const e of i)t(e)}isUpdating(){const e=this._wasm;return this._wasmLayerId>=0&&null!=e&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}get readyToRun(){return!!this._frameTask?.readyToRun||this._createRenderableQueue.readyToRun}runTask(e){this._frameTask.processQueue(e),this._createRenderableQueue.runTask(e),this.notifyChange("readyToRun")}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed||this.destroying)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable called after destroy");return this._createRenderable(e)}async _createRenderable(e){if(this.destroyed){const e=`IntegratedMesh3DTilesLayerView3D[${this.layer?.title}]: createRenderable called on destroyed instance`;throw this._dbg(3,e),new Error(e)}const{meshData:t}=e;if(null==t.data)throw new Error("meshData.data undefined");if("string"==typeof t.desc&&(t.desc=JSON.parse(t.desc)),null==t.desc)throw new Error("meshData.desc undefined");const i=t.desc,s=t.data.buffer,r={textureMemoryUsage:0},o=new Map,n=i.prims.length,a=i.materials,l=e=>this._getTexture(e,t,o,r);let c;try{c=this._createPrimitiveTextureBundles(n,i,a,l)}catch(u){throw o.forEach(e=>this._stage.removeTexture(e)),u}const d=new Array,h=new ye;try{const t=this._createRenderableQueue.push(()=>this._createRenderableMain(i,s,n,a,c,o,d,h),null);this.notifyChange("readyToRun");const l=await t;if(this.destroyed)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable aborted due to destroyed instance");if(await Promise.all(c.map(e=>e.materialPromise)),this.destroyed)throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable aborted due to destroyed instance");for(const e of l.textureMemoryUsageEvaluators)r.textureMemoryUsage+=e();const u=new ze(e.handle,d,l.textures,l.cpuMemoryUsage,l.vboMemoryUsage,r.textureMemoryUsage,l.tileObb,e.stableNodeId,e.nodeDepth,h);this._lyrHandleToObjects.set(e.handle,u),this._memCache.put(Qe(u.handle),u);const{usedMemory:m}=u;return this._cacheMemory+=m,{memUsageBytes:m}}catch(u){throw c.forEach(e=>e.cleanup()),d.forEach(e=>this._collection.destroyObject(e)),o.forEach(e=>this._stage.removeTexture(e)),u}}_createPrimitiveTextureBundles(e,t,i,s){const r=new Array;try{for(let o=0;o<e;o++){const e=t.prims[o],n=i&&null!=e.materialId?i[e.materialId]:null;let a=Promise.resolve(Ze),l=null,c=null,d=null,h=null,u=null;if(n){const e="Pbr"===n.lightingModel;l=s(n.baseColorTex),c=e?s(n.metalTex):null,d=e?s(n.emissiveTex):null,h=e?s(n.occlusionTex):null,u=e?s(n.normalTex):null;const t=[l,c,d,h,u].map(e=>e?.loadPromise??null);a=Promise.all(t)}r.push(new Je(a,l,c,d,h,u))}}catch(o){throw r.forEach(e=>e.cleanup()),o}return r}_createRenderableMain(e,t,i,s,r,o,n,a){let l=0;const c=C(...e.origin),d=this.view.basemapTerrain.spatialReference,m=this.view.state.isGlobal;let y=f;if(m){const e=b();L(P,c,e,d),y=h(p(),e)}if(null==e.obb)throw new Error("meshData.desc.obb undefined");const g=$e(e.obb),_=m?H(this.view.spatialReference).radius:0,v=y!==f,x=v?u(p(),y)??f:f,T=j(),E=new Array;for(let h=0;h<i;h++){const i=e.prims[h],o=r[h];this._dbgFlags.has(2)&&this._dbg(2,JSON.stringify(i));if(null==de[i.ptype]){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+i.ptype+"). Skipping primitive."),o.cleanup();continue}const u=s&&null!=i.materialId?s[i.materialId]:null,p=null!=u?u.lightingModel:"Unlit",{positionView:f,positionAttr:b,normalsView:C,normalsAttr:S,colorAttr:A,texCoord0Attr:H,indicesView:P}=this.getBufferViews(i,t,y);if(null==b||null==f||null==P){o.cleanup();continue}const L=f.count,D=(e,t)=>!e||e.data.length/e.size===L||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!D(H,"numTexcoord")||!D(A,"numColors")||!D(S,"normals")){o.cleanup();continue}const F=new xe(null!=A,null!=C,H?1:0),B=Te(F),G=B.createBuffer(L);Ke(new Ye(c,_,m,y),{texCoord0Attr:H,colorAttr:A,normalsAttr:S},G,{positionView:f,tileObb:g,obbHalfSizeAccumulator:T,elevationRange:a});const z=g?.clone()??We(b,c),N=new Uint32Array([0,P.typedBuffer.length]),q=we(B),W=this._imVertexNormals,$=te(new Uint8Array(G.buffer),P.typedBuffer,q,W,W?x:void 0),Q=new je(q,this._imShading?2:0,F.textureCoordinateType,v?1:0,0),Z=new Ce({interleavedVertexData:$.data,vertexCount:$.data.byteLength/q[0].stride,indexData:$.indices},{positions:f.typedBuffer,indices:P.typedBuffer},N,Q),J=this.view.renderSpatialReference,X=j(),Y=[1,1,1];k(c,J,Y,d)||this._dbg(3,"Unsupported coordinate system for IM overlay"),I(c,J,X,d);let K=V,ee=De,ie=null,se=null,re=null,oe=null,ne=null,ae=1,le=!1,ce=2,me=!1,pe=R(0,0,0);const fe=M(Ve),be="Pbr"===p;if(u&&(ie=o.baseColorTexture,ne=o.metallicRoughnessTexture,se=o.emissionTexture,oe=o.occlusionTexture,re=o.normalTexture,K=O(u.baseColorFactor),ee=u.alphaCutoff??De,be&&(w(fe,u.metallicFactor,u.roughnessFactor,0),u.emissiveFactor&&(pe=u.emissiveFactor)),ae=he[u.alphaMode],le=u.isDoubleSided,ce=ue[u.faceCulling??"NotSet"],me=this.layer.replacesTerrain),this.destroyed){const e="Trying to add object to destroyed layer view";throw this._dbg(3,`${e} !== numPos. Skipping primitive.`),new Error(e)}ie||this._dbg(3,"No colour texture 1");const ye=this._collection.createObject({toMapSpace:U(X[0],X[1],Y[0],Y[1]),transform:new Me(c,x),obb:z,geometry:Z,elevationAlignable:!1},{isIntegratedMesh:!0,baseColor:K,textureAlphaCutoff:ee,mrrFactors:fe,baseColorTexture:ie,metallicRoughnessTexture:ne,normalTexture:re,occlusionTexture:oe,emissionTexture:se,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:ae,doubleSided:le,cullFace:ce,isGround:me,emissiveBaseColor:pe,usePBR:be,slicePlaneEnabled:this.slicePlaneEnabled,opacity:this.fullOpacity,polygonOffset:0,ellipsoidMode:1,applySSAO:this._applySSAO});E.push(()=>{let e=ie?.texture?.usedMemory??0;return be&&(e+=(ne?.texture?.usedMemory??0)+(se?.texture?.usedMemory??0)+(oe?.texture?.usedMemory??0)+(re?.texture?.usedMemory??0)),e}),l+=this._collection.getObjectGPUMemoryUsage(ye),n.push(ye)}const S=Array.from(o.values()),{fullExtent:A}=this.layer;A?.hasZ&&A.zmax&&A.zmin&&(a.minElevation=Math.max(a.minElevation,A.zmin),a.maxElevation=Math.min(a.maxElevation,A.zmax));const D=n.reduceRight((e,t)=>e+t.intersectionGeometry.usedMemory,0);return new Xe(l,g,E,S,D)}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._intersectionHandler.removeTile(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e)):this._dbg(3,`freeRendedrable on non-existent renderable ${e}`)}freeObject(e){const t=Qe(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){if(this.destroyed||this.destroying)return;const s=this._frustum,r=new Array;let o=!1,n=!1;for(let a=0;a<i;++a){if(!t[a])continue;const i=e[a],l=this._lyrHandleToObjects.get(i);if(l){if(l.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${l.stableNodeId}`);continue}o=!0,l.isLoaded=!0,this._loadedObjects.add(l),this._intersectionHandler.addTile(l),this._usedMemory+=l.usedMemory,this._cacheMemory-=l.usedMemory;const e=l.obb?.intersectsFrustum(s)??!0;l.isVisible=e,e&&(this._visibleObjects.add(l),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,l.elevationRange)),e&&l.obb&&r.push(l.obb),l.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(Qe(i))}else this._dbg(3,`Tried to mark Non existent object ${i} as loaded`)}for(let a=0;a<i;++a){const i=e[a];if(t[a])continue;const s=this._lyrHandleToObjects.get(i);if(s){if(!s.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${s.stableNodeId}`);continue}const e=s.isVisible;this._visibleObjects.delete(s),s.isVisible=!1,s.isLoaded=!1,this._loadedObjects.delete(s),this._intersectionHandler.removeTile(s),e&&(this._visibleGeometryChanged(),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,s.elevationRange)),this._usedMemory-=s.usedMemory,this._cacheMemory+=s.usedMemory,e&&s.obb&&r.push(s.obb),s.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(Qe(i),s)}else this._dbg(3,`Tried to mark Non existent object ${i} as not loaded`)}o&&this._visibleGeometryChanged(),this._elevationProvider.notifyObjectsChanged(r),n&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){const{visibleElevationRange:i}=this,{minElevation:s,maxElevation:r}=t;return e?s<i.minElevation||r>i.maxElevation:s===i.minElevation||r===i.maxElevation}_getTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=i.get(r)??this._createTexture(e,t,i,s);return o?new Re(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!r.mipCount||a>1,c=me[e.wrapMode??"None"];let d=r.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,r.data.byteOffset,r.data.byteCount);let u=null,m=null,p=null;switch(r.format){case"Raw":"R8"===r.pixelFormat?(u=h,d=6403,m=""):"Rgb8"===r.pixelFormat?(u=h,d=6407,m=""):"Rgba8"===r.pixelFormat&&(u=h,d=6408,m="");break;case"Dxt1":u=h,d=6407,m="image/vnd-ms.dds";break;case"Dxt5":u=h,d=6408,m="image/vnd-ms.dds";break;case"Basis":u=h,d=6407,m="image/ktx2";break;case"Png":m="image/png",p=document.createElement("img");break;case"Jpeg":m="image/jpeg",p=document.createElement("img");break;case"Etc2":m="image/ktx",p=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(p&&m){const e=new Blob([h],{type:m});p.src=URL.createObjectURL(e),u=p}if(u&&null!=m){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(s.textureMemoryUsage-=e)}}:void 0,t=new Oe(u,{mipmap:l,maxAnisotropy:a,encoding:m,wrap:c,pixelFormat:d,compressionOptions:e,noUnpackFlip:!0,width:r.mip0Width,height:r.mip0Height});return this._stage.addTexture(t),i.set(r,t),t}return null}getBufferViews(e,t,i){let s,r,o,n,a,l,c,d=null;for(let u=0;u<e.atrbs.length;u++){const c=e.atrbs[u],{view:m}=c,p=void 0,f=m.byteOffset+m.byteCount,b=m.byteCount/pe[m.type],y=F(b);try{switch(c.sem){case"Position":3!==m.ncomp||"F32"!==m.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+m+")"):(s=new q(t,m.byteOffset,p,f),r=new Ee(s.typedBuffer,y,3));break;case"Normal":if(3!==m.ncomp||"F32"!==m.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+m+")");else{const e=new q(t,m.byteOffset,p,f),s=Ue(e.typedBuffer,i);a=new Z(s.buffer),l=new Ee(a.typedBuffer,y,2)}break;case"TexCoord":2!==m.ncomp||"F32"!==m.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+m+")"):void 0===n&&(n=new Ee(new Q(t,m.byteOffset,p,f).typedBuffer,y,2));break;case"Color":4===m.ncomp?("F32"===m.type&&(d=new G(t,m.byteOffset,p,f)),"U8"===m.type&&(d=new z(t,m.byteOffset,p,f)),"U16"===m.type&&(d=new N(t,m.byteOffset,p,f))):3===m.ncomp&&("F32"===m.type&&(d=new q(t,m.byteOffset,p,f)),"U8"===m.type&&(d=new W(t,m.byteOffset,p,f)),"U16"===m.type&&(d=new $(t,m.byteOffset,p,f))),null==d?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+m+")"):o=new Ee(d.typedBuffer,y,m.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+c.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,s=void 0,r=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":c=new X(t,i.byteOffset,s,r);break;case"U32":c=new J(t,i.byteOffset,s,r);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==c&&null!=s){const e=s.count;c=c=e<65535?new X(new Uint16Array(e).buffer):new J(new Uint32Array(e).buffer);for(let t=0;t<e;t++)c.set(t,t)}return{positionView:s,positionAttr:r,colorAttr:o,texCoord0Attr:n,indicesView:c,normalsView:a,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>!(this.layer.isUsedAsGroundLayer&&"replace"!==e.type)).toArray(),this._modifications.length<e.length&&t.getLogger(this).info("Ground layers only support replace modifications. Other modification types have been ignored.")},o),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([c()],Be.prototype,"fullOpacity",null),e([c({readOnly:!0})],Be.prototype,"ready",null),e([c({type:[K]})],Be.prototype,"_modifications",void 0),e([c()],Be.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([c()],Be.prototype,"layer",void 0),e([c({readOnly:!0})],Be.prototype,"visibleAtCurrentScale",null),e([c({readOnly:!0})],Be.prototype,"_collection",null),e([c()],Be.prototype,"elevationOffset",null),e([c({readOnly:!0})],Be.prototype,"visibleElevationRange",null),Be=e([d("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Be);const Ge=Be;class ze{constructor(e,t,i,s,r,o,n,a,l,c){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=s,this.vboMemoryUsage=r,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.nodeDepth=l,this.elevationRange=c,this.bvhIntersectionGeneration=0,this.isLoaded=!1,this.isVisible=!1;const d=j();n?.getCenter(d),this._obbCenterX=d[0],this._obbCenterY=d[1],this._obbCenterZ=d[2];const h=n?.radius??-1;this._obbRadius=h,this._obbRadiusSquared=h*h;const u=n?.halfSize;this._obbShortestHalfsize=u?Math.min(u[0],u[1],u[2]):0,this._mbsCenter=n?M(n.center):E}get usedMemory(){return this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage}get mbsRadius(){return this._obbRadius}get mbsCenter(){return this._mbsCenter}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const{_obbCenterX:i,_obbCenterY:s,_obbCenterZ:r}=this,o=i-e[0],n=s-e[1],a=r-e[2],l=o*t[0]+n*t[1]+a*t[2];return o*o+n*n+a*a-l*l<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){const t=this._obbRadius;if(t<0)return!0;const i=e.center,s=e.radius,r=t+s,o=this._obbCenterX-i[0];if(o>r)return!1;const n=this._obbCenterY-i[1];if(n>r)return!1;const a=this._obbCenterZ-i[2];if(a>r)return!1;const l=o*o+n*n+a*a;if(l>r*r)return!1;if(l<=(this._obbShortestHalfsize+s)**2)return!0;return Math.sqrt(l)+t<=s||(this.obb?.intersectSphere(e)??!0)}}function Ne(e){return Math.round(e/1048.576)/1e3}const qe=j();function We(e,t){const i=ve(e);return T(qe,i.center,t),i.center=qe,i}function $e(e){return new _e(e.center,e.halfSize,y(...e.quaternion))}function Qe(e){return`${e}`}const Ze=new Array;class Je{constructor(e,t,i,s,r,o){this.materialPromise=e,this.baseColorTexture=t,this.metallicRoughnessTexture=i,this.emissionTexture=s,this.occlusionTexture=r,this.normalTexture=o}cleanup(){this.baseColorTexture?.dispose(),this.metallicRoughnessTexture?.dispose(),this.emissionTexture?.dispose(),this.occlusionTexture?.dispose(),this.normalTexture?.dispose()}}class Xe{constructor(e,t,i,s,r){this.vboMemoryUsage=e,this.tileObb=t,this.textureMemoryUsageEvaluators=i,this.textures=s,this.cpuMemoryUsage=r}}class Ye{constructor(e,t,i,s){this.origin=e,this.ellipsoidRadius=t,this.isGlobal=i,this.ecefRotation=s}}function Ke(e,t,i,s){const{origin:r,ellipsoidRadius:o,isGlobal:n,ecefRotation:a}=e,{texCoord0Attr:l,colorAttr:c,normalsAttr:d}=t,{positionView:h,tileObb:u,obbHalfSizeAccumulator:p,elevationRange:b}=s,y=i.getField("position",q),g=y.typedBuffer,_=y.typedBufferStride,v=l?.data,w=null!=l?i.getField("uv0",Q):null,T=w?.typedBuffer,j=w?.typedBufferStride??0,C=c?.data,M=c?.size??0,R=null!=c?i.getField("color",z):null,O=R?.typedBuffer,U=R?.typedBufferStride??0,V=d?.data,S=null!=d?i.getField("normalCompressed",Y):null,A=S?.typedBuffer,H=S?.typedBufferStride??0,P=null!=u?m(tt,u.quaternionConjugate):f,L=x(et,u?.center??E,P),k=P[0],I=P[1],D=P[2],F=P[3],B=P[4],G=P[5],N=P[6],W=P[7],$=P[8],Z=L[0],J=L[1],X=L[2],K=a[0],ee=a[1],te=a[2],ie=a[3],se=a[4],re=a[5],oe=a[6],ne=a[7],ae=a[8],le=a!==f,ce=r[0],de=r[1],he=r[2],ue=h.count,me=h.typedBufferStride,pe=h.typedBuffer,fe=null!=T&&null!=v,be=null!=O&&null!=C&&(3===M||4===M),ye=4===M,ge=null!=A&&null!=V,_e=null!=p;let ve=_e?p[0]:0,we=_e?p[1]:0,xe=_e?p[2]:0;for(let m=0;m<ue;++m){const e=m*me,t=pe[e],i=pe[e+1],s=pe[e+2],r=t+ce,a=i+de,l=s+he,c=n?Math.sqrt(r*r+a*a+l*l)-o:l;if(b.expandElevationRangeValues(c,c),_e){const e=Math.abs(r*k+a*F+l*N-Z),t=Math.abs(r*I+a*B+l*W-J),i=Math.abs(r*D+a*G+l*$-X);ve=Math.max(ve,e),we=Math.max(we,t),xe=Math.max(xe,i)}const d=m*_;if(le){const r=t*K+i*ie+s*oe,o=t*ee+i*se+s*ne,n=t*te+i*re+s*ae;pe[e]=r,pe[e+1]=o,pe[e+2]=n,g[d]=r,g[d+1]=o,g[d+2]=n}else g[d]=t,g[d+1]=i,g[d+2]=s;if(fe){const e=2*m,t=m*j;T[t]=v[e],T[t+1]=v[e+1]}if(be){const e=m*U;if(ye){const t=4*m;O[e]=C[t],O[e+1]=C[t+1],O[e+2]=C[t+2],O[e+3]=C[t+3]}else{const t=3*m;O[e]=C[t],O[e+1]=C[t+1],O[e+2]=C[t+2],O[e+3]=255}}if(ge){const e=2*m,t=m*H;A[t]=V[e],A[t+1]=V[e+1]}}u&&_e&&(p[0]=ve,p[1]=we,p[2]=xe,u.setHalfSize(ve,we,xe))}const et=j(),tt=p();export{Ge as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{transformMat3 as e}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as t}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{decompressNormal as r,compressNormal as n}from"../webgl-engine/lib/Normals.js";import{DataType as o}from"../../webgl/enums.js";import{VertexElementDescriptor as s}from"../../webgl/VertexElementDescriptor.js";class c{constructor(e,t){this.data=e,this.indices=t}}function f(e,t,r,n,o){return!n||r.some(({name:e})=>"normal"===e||"normalCompressed"===e)?a(e,t,r,o):i(e,t,r,o)}function a(o,s,f,a){const i=new c(o.slice().buffer,s);if(a){const o=f[0].stride,s=i.data.byteLength/o;for(const c of f)if("normalCompressed"===c.name){const{offset:f}=c,l=new Int16Array(i.data),d=t();for(let t=0;t<s;++t)r(d,l,t,o/2,f/2),e(d,d,a),n(l,t,d[0],d[1],d[2],o/2,f/2)}else if("normal"===c.name){const{offset:r}=c,n=new Float32Array(i.data),f=t();for(let t=0;t<s;++t){const s=(t*o+r)/4;f[0]=n[s],f[1]=n[s+1],f[2]=n[s+2],e(f,f,a),n[s]=f[0],n[s+1]=f[1],n[s+2]=f[2]}}}return i}function i(e,t,r,n){const c=r[0].stride,f=c/4,a=new Float32Array(e.buffer,e.byteOffset,e.byteLength/4),i=t.length/3,y=e.byteLength/c,{faceNormals:m,faceAreas:A,faceEdges:w,edgeFaces:h,vertexFaces:g,vertexFaceCountAndOffset:b}=d(a,f,y,t,i,n);u(t,i,m,A,w,h);const $=c+4;return r.forEach(e=>e.stride=$),r.push(new s("normalCompressed",2,o.SHORT,c,$,!0)),l(a,f,i,y,t,c,$,m,A,g,b)}function l(e,t,r,n,o,s,f,a,i,l,d){const u=3*r,y=new(u<256?Uint8Array:u<65536?Uint16Array:Uint32Array)(o);let m=n;const A=new(n<256?Uint8Array:n<65536?Uint16Array:Uint32Array)(u-n),h=new ArrayBuffer(4*u),g=new Int16Array(h),b=new Uint32Array(h),$=new Uint32Array(e.buffer,e.byteOffset,e.length);let U=0,v=0;const x=new Uint32Array(r);let F=0;const M=1-w;for(let c=0;c<n;++c){U=d[2*c+1],v=U+d[2*c];let e=c;for(;U<v;){{const t=l[--v],r=3*t,n=a[r],o=a[r+1],s=a[r+2];F=0,x[F++]=t;let c=U;for(;c<v;){const e=l[c],t=3*e;if(n*a[t]+o*a[t+1]+s*a[t+2]>M){x[F++]=e;const t=--v;if(c<t){l[c]=l[t];continue}}++c}let f=0,d=0,u=0;if(1===F)f=n,d=o,u=s;else{for(let t=0;t<F;++t){const e=x[t],r=i[e],n=3*e;f+=a[n]*r,d+=a[n+1]*r,u+=a[n+2]*r}const e=Math.sqrt(f*f+d*d+u*u)||1;f/=e,d/=e,u/=e}{const t=1/(Math.abs(f)+Math.abs(d)+Math.abs(u)),r=f*t,n=d*t;let o=r,s=n;u<=0&&(o=(r>=0?1:-1)*(1-Math.abs(n)),s=(n>=0?1:-1)*(1-Math.abs(r)));const c=2*e,a=Math.round(32767*o),i=Math.round(32767*s);g[c]=a<-32767?-32767:a>32767?32767:a,g[c+1]=i<-32767?-32767:i>32767?32767:i}}if(e!==c)for(let t=0;t<F;++t){const r=3*x[t];y[r]===c&&(y[r]=e),y[r+1]===c&&(y[r+1]=e),y[r+2]===c&&(y[r+2]=e)}if(U>=v)break;e=m++,A[e-n]=c}}const p=m,E=f/4,I=new Float32Array(p*E),j=new Uint32Array(I.buffer),C=s/4;for(let c=0;c<n;++c){const e=c*t,r=c*E;for(let n=0;n<t;++n)j[r+n]=$[e+n];j[r+C]=b[c]}for(let c=n;c<p;++c){const e=A[c-n]*t,r=c*E;for(let n=0;n<t;++n)j[r+n]=$[e+n];j[r+C]=b[c]}return new c(I.buffer,y)}function d(e,t,r,n,o,s){const c=new Float32Array(3*o),f=new Float32Array(o),a=new Uint32Array(3*o),i=new Int32Array(2*(3*o)),l=3*o,d=new Uint32Array(l),u=new Uint32Array(2*r);for(let
|
|
2
|
+
import{transformMat3 as e}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as t}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{decompressNormal as r,compressNormal as n}from"../webgl-engine/lib/Normals.js";import{DataType as o}from"../../webgl/enums.js";import{VertexElementDescriptor as s}from"../../webgl/VertexElementDescriptor.js";class c{constructor(e,t){this.data=e,this.indices=t}}function f(e,t,r,n,o){return!n||r.some(({name:e})=>"normal"===e||"normalCompressed"===e)?a(e,t,r,o):i(e,t,r,o)}function a(o,s,f,a){const i=new c(o.slice().buffer,s);if(a){const o=f[0].stride,s=i.data.byteLength/o;for(const c of f)if("normalCompressed"===c.name){const{offset:f}=c,l=new Int16Array(i.data),d=t();for(let t=0;t<s;++t)r(d,l,t,o/2,f/2),e(d,d,a),n(l,t,d[0],d[1],d[2],o/2,f/2)}else if("normal"===c.name){const{offset:r}=c,n=new Float32Array(i.data),f=t();for(let t=0;t<s;++t){const s=(t*o+r)/4;f[0]=n[s],f[1]=n[s+1],f[2]=n[s+2],e(f,f,a),n[s]=f[0],n[s+1]=f[1],n[s+2]=f[2]}}}return i}function i(e,t,r,n){const c=r[0].stride,f=c/4,a=new Float32Array(e.buffer,e.byteOffset,e.byteLength/4),i=t.length/3,y=e.byteLength/c,{faceNormals:m,faceAreas:A,faceEdges:w,edgeFaces:h,vertexFaces:g,vertexFaceCountAndOffset:b}=d(a,f,y,t,i,n);u(t,i,m,A,w,h);const $=c+4;return r.forEach(e=>e.stride=$),r.push(new s("normalCompressed",2,o.SHORT,c,$,!0)),l(a,f,i,y,t,c,$,m,A,g,b)}function l(e,t,r,n,o,s,f,a,i,l,d){const u=3*r,y=new(u<256?Uint8Array:u<65536?Uint16Array:Uint32Array)(o);let m=n;const A=new(n<256?Uint8Array:n<65536?Uint16Array:Uint32Array)(u-n),h=new ArrayBuffer(4*u),g=new Int16Array(h),b=new Uint32Array(h),$=new Uint32Array(e.buffer,e.byteOffset,e.length);let U=0,v=0;const x=new Uint32Array(r);let F=0;const M=1-w;for(let c=0;c<n;++c){U=d[2*c+1],v=U+d[2*c];let e=c;for(;U<v;){{const t=l[--v],r=3*t,n=a[r],o=a[r+1],s=a[r+2];F=0,x[F++]=t;let c=U;for(;c<v;){const e=l[c],t=3*e;if(n*a[t]+o*a[t+1]+s*a[t+2]>M){x[F++]=e;const t=--v;if(c<t){l[c]=l[t];continue}}++c}let f=0,d=0,u=0;if(1===F)f=n,d=o,u=s;else{for(let t=0;t<F;++t){const e=x[t],r=i[e],n=3*e;f+=a[n]*r,d+=a[n+1]*r,u+=a[n+2]*r}const e=Math.sqrt(f*f+d*d+u*u)||1;f/=e,d/=e,u/=e}{const t=1/(Math.abs(f)+Math.abs(d)+Math.abs(u)),r=f*t,n=d*t;let o=r,s=n;u<=0&&(o=(r>=0?1:-1)*(1-Math.abs(n)),s=(n>=0?1:-1)*(1-Math.abs(r)));const c=2*e,a=Math.round(32767*o),i=Math.round(32767*s);g[c]=a<-32767?-32767:a>32767?32767:a,g[c+1]=i<-32767?-32767:i>32767?32767:i}}if(e!==c)for(let t=0;t<F;++t){const r=3*x[t];y[r]===c&&(y[r]=e),y[r+1]===c&&(y[r+1]=e),y[r+2]===c&&(y[r+2]=e)}if(U>=v)break;e=m++,A[e-n]=c}}const p=m,E=f/4,I=new Float32Array(p*E),j=new Uint32Array(I.buffer),C=s/4;for(let c=0;c<n;++c){const e=c*t,r=c*E;for(let n=0;n<t;++n)j[r+n]=$[e+n];j[r+C]=b[c]}for(let c=n;c<p;++c){const e=A[c-n]*t,r=c*E;for(let n=0;n<t;++n)j[r+n]=$[e+n];j[r+C]=b[c]}return new c(I.buffer,y)}function d(e,t,r,n,o,s){const c=new Float32Array(3*o),f=new Float32Array(o),a=new Uint32Array(3*o),i=new Int32Array(2*(3*o)),l=3*o,d=new Uint32Array(l),u=new Uint32Array(2*r);for(let h=0;h<o;++h){const e=3*h;for(let t=0;t<3;++t){++u[2*n[e+t]]}}{let e=0;for(let t=0;t<r;++t){const r=2*t;u[r+1]=e;e+=u[r]}for(let t=0;t<o;++t){const e=3*t;for(let r=0;r<3;++r){d[u[2*n[e+r]+1]++]=t}}for(let t=0;t<r;++t)u[2*t+1]-=u[2*t]}let y=0;const m=new Uint32Array(2*l*2),A=new Uint32Array(2*r);for(let h=0;h<r;++h){const e=2*h,t=4*u[e+1];A[e]=t,A[e+1]=t}function w(e,t,r){const n=Math.min(e,t),o=Math.max(e,t),s=e<t?0:1,c=2*n,f=A[c],a=A[c+1];let l=-1;for(let i=f;i<a;i+=2)if(m[i]===o){l=m[i+1];break}return-1===l&&(l=y++,m[a]=o,m[a+1]=l,A[c+1]=a+2,i[2*l+(1-s)]=-1),i[2*l+s]=r,l}for(let h=0;h<n.length;h+=3){const r=n[h],o=r*t,i=e[o],l=e[o+1],d=e[o+2],u=n[h+1],y=u*t,m=e[y],A=e[y+1],g=e[y+2],b=n[h+2],$=b*t,U=i-m,v=l-A,x=d-g,F=i-e[$],M=l-e[$+1],p=d-e[$+2],E=v*p-x*M,I=x*F-U*p,j=U*M-v*F,C=Math.sqrt(E*E+I*I+j*j)||1,O=h/3;f[O]=.5*C;const q=1/C;if(s){const e=s[0]*E+s[3]*I+s[6]*j,t=s[1]*E+s[4]*I+s[7]*j,r=s[2]*E+s[5]*I+s[8]*j;c[3*O]=e*q,c[3*O+1]=t*q,c[3*O+2]=r*q}else c[3*O]=E*q,c[3*O+1]=I*q,c[3*O+2]=j*q;const L=w(r,u,O),N=w(u,b,O),k=w(b,r,O);a[3*O]=L,a[3*O+1]=N,a[3*O+2]=k}return{faceNormals:c,faceAreas:f,faceEdges:a,vertexFaces:d,vertexFaceCountAndOffset:u,edgeFaces:i}}function u(e,t,r,n,o,s){const c=new Uint8Array(t),f=new Uint32Array(t),a=new Uint32Array(3*t);let i=0;const l=new Uint32Array(t);let d=0;for(let u=0;u<e.length;u+=3){const e=u/3;if(1===c[e])continue;c[e]=1;const t=r[3*e],y=r[3*e+1],m=r[3*e+2];for(d=0,l[d++]=e,a[0]=o[3*e],a[1]=o[3*e+1],a[2]=o[3*e+2],i=3,f[e]=e+1;i>0;){const n=a[--i];for(let u=0;u<2;++u){const w=s[2*n+u];if(-1===w||f[w]===e+1)continue;f[w]=e+1;const h=r[3*w],g=r[3*w+1],b=r[3*w+2];if(Math.abs(1-(t*h+y*g+m*b))<A){l[d++]=w,c[w]=1;for(let e=0;e<3;++e){const t=o[3*w+e];t!==n&&(a[i++]=t)}}}}if(d>1){let e=0,t=0,o=0,s=0;for(let f=0;f<d;++f){const c=l[f],a=n[c];e+=a,t+=r[3*c]*a,o+=r[3*c+1]*a,s+=r[3*c+2]*a}const c=Math.sqrt(t*t+o*o+s*s)||1;t/=c,o/=c,s/=c;for(let f=0;f<d;++f){const c=l[f];r[3*c]=t,r[3*c+1]=o,r[3*c+2]=s,n[c]=e}}}}function y(e,t,r,n,o,s,c,f,a,i){const l=new Uint32Array(2*n);for(let d=0;d<r;++d){const e=a[2*d],t=a[2*d+1];for(let o=e;o<t;o+=2){const e=i[o],t=i[o+1];t>=n||t<0?console.error(`Invalid edge index ${t} for vertex ${d}`):e>=r||e<0||e<d?console.error(`Invalid vertex ${e} for edge ${t}`):(l[2*t]=d,l[2*t+1]=e)}}for(let d=0;d<t;++d){const t=[e[3*d],e[3*d+1],e[3*d+2]],r=[f[3*d],f[3*d+1],f[3*d+2]];for(const e of t){const t=o[2*e+1];m(s,t,t+o[2*e],1,d)||console.error(`Face ${d} not found in vertexFaces for vertex ${e}`)}for(const e of r){const t=c[2*e],r=c[2*e+1];-1!==t||-1!==r?d!==t&&d!==r&&console.error(`Edge ${e} of face ${d} does not list it as a face`):console.error(`Edge ${e} of face ${d} has no faces`)}}for(let d=0;d<n;++d){const e=c[2*d],t=c[2*d+1];if(-1===e&&-1===t){console.error(`Edge ${d} has no faces`);continue}for(const s of[e,t].filter(e=>-1!==e)){const e=f[3*s],t=f[3*s+1],r=f[3*s+2];d!==e&&d!==t&&d!==r&&console.error(`Edge ${d} not found in edgesPerFace for face ${s}`)}const r=l[2*d],n=l[2*d+1];r===n&&console.error(`Edge ${d} is degenerate with identical vertices ${r}`);const o=Math.min(r,n);m(i,a[2*o]+1,a[2*o+1],2,d)||console.error(`Edge ${d} not found in edgeMap for vertex ${o}`)}for(let d=0;d<r;++d){const r=o[2*d+1],n=o[2*d];for(let o=r;o<r+n;++o){const r=s[o];(r<0||r>=t)&&console.error(`Invalid face ${r} in vertexFaces for vertex ${d}`),m(e,3*r,3*r+3,1,d)||console.error(`Face ${r} in vertexFaces for vertex ${d} does not reference it in indices`)}}}function m(e,t,r,n,o){for(let s=t;s<r;s+=n)if(e[s]===o)return!0;return!1}const A=.04,w=.8;export{f as addNormals,y as checkTopology};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{clamp as t}from"../../../core/mathUtils.js";import{ElevationSamplerData as a}from"../../../layers/support/ElevationSamplerData.js";import{bilerp as o}from"../support/mathUtils.js";import{elevationNoDataValue as i}from"./TerrainConst.js";class
|
|
2
|
+
import{clamp as t}from"../../../core/mathUtils.js";import{ElevationSamplerData as a}from"../../../layers/support/ElevationSamplerData.js";import{bilerp as o}from"../support/mathUtils.js";import{elevationNoDataValue as i}from"./TerrainConst.js";class n{constructor(t,o,i){this.type="elevation",this.level=t[0],this.i=t[1],this.j=t[2],this.extent=o,this.samplerData=new a(i,o)}computeMinMaxValue(t,a,n,e){e.minElevation=1/0,e.maxElevation=-1/0,e.hasNoDataValues=!1;const l=t-this.level;if(l<=0)return e;const r=2**l;if(!(Math.floor(a/r)===this.i&&Math.floor(n/r)===this.j))return e;let s=1/0,h=-1/0;const f=this.samplerData.data.width,u=this.samplerData.data.values,m=.5*i;let c=(f-1)/r,p=(n-this.j*r)*c,M=(a-this.i*r)*c;if(c<1){const t=Math.floor(p),a=Math.floor(M),i=t+a*f,n=u[i],l=u[i+1],r=u[i+f],s=u[i+f+1];if(n+l+r+s<m){const i=p-t,h=M-a,f=o(n,l,r,s,i,h),u=o(n,l,r,s,i+c,h),m=o(n,l,r,s,i,h+c),v=o(n,l,r,s,i+c,h+c);return e.minElevation=Math.min(f,u,m,v),e.maxElevation=Math.max(f,u,m,v),e}p=t,M=a,c=1}else p=Math.floor(p),M=Math.floor(M),c=Math.ceil(c);for(let o=p;o<=p+c;o++)for(let t=M;t<=M+c;t++){const a=u[o+t*f];a<m?(s=Math.min(s,a),h=Math.max(h,a)):e.hasNoDataValues=!0}return e.minElevation=s,e.maxElevation=h,e}}const e=.5*i;function l(t,a,o){if(null==o)return null;for(const i of o){if(!i)continue;const o=r(t,a,i);if(null!=o)return o}return null}function r(a,o,i){const n=i.safeWidth;let l=t(i.dy*(i.y1-o),0,n),r=t(i.dx*(a-i.x0),0,n);const s=Math.floor(l),h=Math.floor(r),f=i.data.width,u=s*f+h,m=i.data.values,c=m[u],p=m[u+1],M=u+f,v=m[M],x=m[M+1];if(c+v+p+x<e){l-=s,r-=h;const t=c+(p-c)*r;return t+(v+(x-v)*r-t)*l}return null}export{n as ElevationData,l as sampleElevation,r as sampleSingleElevation};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{clamp as t,isPowerOfTwo as e}from"../../../core/mathUtils.js";import{maxUint16 as n}from"../../../core/typedArrayUtil.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{PatchGeometryLUT as i}from"./PatchGeometryLUT.js";import{zeroToFour as a,neighborTileIfLoadedOrSelf as c}from"./PatchRenderData.js";import{internalAssert as l,enableTerrainInternalChecks as u,neighborEdgeIndices as d,almostEquals as f}from"./terrainUtils.js";import{isCornerNeighbor as m}from"./Tile.js";import{compareTilesByLij as g}from"./tileUtils.js";import{compressNormal as h}from"../webgl-engine/lib/Normals.js";const p=65536;function x(t,e){const{tile:n,geometry:s,geometryState:r}=t,{extentInRadians:i,surface:a}=n,{isWebMercator:c,renderer:l}=a,{numVerticesPerSide:u,wireframe:d}=r,f=u-1,m=(u-2)**2,g=c&&(2===e||3===e),h=c&&(1===e||3===e),p=((g?1:0)+(h?1:0))*mt*u,x=ut(r),S=m+p+4*x,v=l.tileGeometryCache.acquire(S);s.numVerticesPerSide=u,s.vertexAttributes=v,s.maxEdgeVertexCount=x;const{boundingBox:V}=s;o(V);const B=P(t);ot.update(f,i,B),y(t),s.poleVerticesStartIndex=m;const b=M(t,g,h);s.edgeVerticesStartIndex=m+p,Q(t),I(t),W(s,b,d),t.intersectionData=null}function M(t,e,o){const{tile:s,localOrigin:r,geometry:i}=t,{extent:a,ellipsoid:c}=s,{boundingBox:l,numVerticesPerSide:u,vertexAttributes:d,poleVerticesStartIndex:f}=i,m=u-1,g=r[0],p=r[1],x=r[2],M=c.radius,y=a[1],S=a[3],v=[];let V=f;const I=(t,e)=>{const o=e*u;lt(-g,-p,t*M-x,l),v.push(new et(1===t,o,1===t?0:2,V,mt));const s=C(-1===t?y:S,M),r=t*Math.PI/2-s,i=.99*(1===t?1:-1),a=M+0,{position:c,uv0:f}=d,{typedBuffer:I,typedBufferStride:B}=d.normalCompressed;for(let u=1;u<=mt;++u){const t=s+r*(u/mt),e=Math.cos(t),o=Math.sin(t);for(let s=0;s<=m;s++){const t=s/m,r=ot.sinLonLUT[s],u=ot.cosLonLUT[s]*e,d=r*e,M=o,y=u*a-g,S=d*a-p,v=M*a-x;lt(y,S,v,l),c.setValues(V,y,S,v),f.setValues(V,Math.round(t*n),Math.round(i*n)),h(I,V,u,d,M,B),++V}}};return e&&I(-1,0),o&&I(1,m),v}function y(t){const{tile:e}=t;if(!e.intersectsClippingArea)return;const{geometry:o,geometryState:s,localOrigin:i}=t,{numVerticesPerSide:a,samplerData:c}=s,l=a-2,u=a-1,{vertexAttributes:d,boundingBox:f}=o,{position:m,uv0:g}=d,{typedBuffer:p,typedBufferStride:x}=d.normalCompressed,{extent:M}=e,y=M[0],S=M[2],v=M[1],V=M[3],I=e.ellipsoid.radius,B=i[0],b=i[1],C=i[2],L=m.typedBuffer,A=m.typedBufferStride,P=1/u;let D=0;if(1<=l){const t=P,e=v*(1-t)+V*t,o=ot.sinLatLUT[1],s=ot.cosLatLUT[1];for(let i=1;i<=l;i++){const a=i*P,l=y*(1-a)+S*a,u=ot.sinLonLUT[i],d=ot.cosLonLUT[i],m=I+r(l,e,c),h=m*d*s-B,p=m*u*s-b,x=m*o-C;lt(h,p,x,f);const M=(i-1)*A;L[M]=h,L[M+1]=p,L[M+2]=x,g.setValues(i-1,Math.round(a*n),Math.round(t*n))}}for(let E=1;E<=l;E++){const t=E*P,e=v*(1-t)+V*t,o=ot.sinLatLUT[E],s=ot.cosLatLUT[E],i=E+1,a=i*P,d=v*(1-a)+V*a,m=ot.sinLatLUT[i],M=ot.cosLatLUT[i],T=ot.sinLonLUT[0],O=ot.cosLonLUT[0],R=I+r(y,e,c);let U=O*s*R-B,w=T*s*R-b,N=o*R-C;const j=D*A;let F=L[j],q=L[j+1],W=L[j+2];for(let V=1;V<=l;V++){const t=V*P,i=y*(1-t)+S*t,T=ot.sinLonLUT[V],O=ot.cosLonLUT[V];let R=0,j=0,k=0;if(V<l){const t=(D+1)*A;R=L[t],j=L[t+1],k=L[t+2]}else{const t=ot.sinLonLUT[u],n=ot.cosLonLUT[u],i=I+r(S,e,c);R=n*s*i-B,j=t*s*i-b,k=o*i-C}const z=U,G=w,H=N;U=F,w=q,N=W,F=R,q=j,W=k;const J=R-z,K=j-G,Q=k-H;let X=0,Y=0,Z=0;if(E>1){const t=(D-l)*A;X=L[t],Y=L[t+1],Z=L[t+2]}else{const t=ot.sinLatLUT[0],e=ot.cosLatLUT[0],n=I+r(i,v,c);X=O*e*n-B,Y=T*e*n-b,Z=t*n-C}const $=I+r(i,d,c),_=O*M*$-B,tt=T*M*$-b,et=m*$-C;if(E<l){const e=D+l,o=e*A;L[o]=_,L[o+1]=tt,L[o+2]=et,lt(_,tt,et,f),g.setValues(e,Math.round(t*n),Math.round(a*n))}const nt=X-_,st=Y-tt,rt=Z-et;let it=O*s,at=T*s,ct=o;ct*ct<.999&&(it=Q*st-K*rt,at=J*rt-Q*nt,ct=K*nt-J*st);const ut=1/Math.sqrt(it*it+at*at+ct*ct);h(p,D,it*ut,at*ut,ct*ut,x),++D}}}function S(t){t.tile.intersectsClippingArea&&(I(t),_(t),t.intersectionData=null)}function v(t){t.tile.intersectsClippingArea&&(X(t),I(t),_(t),tt(t),t.intersectionData=null)}function V(t){t.tile.intersectsClippingArea&&(b(t),B(t,!0),_(t),t.intersectionData=null)}function I(t){t.tile.intersectsClippingArea&&(b(t),B(t))}function B(t,o=!1){const{geometry:s,geometryState:i,tile:a,localOrigin:m}=t,{level:h,extent:p,extentInRadians:x,ellipsoid:M}=a,y=M.radius,S=x[0],v=x[2],V=x[1],I=x[3],{samplerData:B}=i,b=p[0],C=p[2],L=p[1],A=p[3],D=P(t),{boundingBox:E,vertexAttributes:T}=s,O=m[0],R=m[1],U=m[2],{position:w,uv0:N}=T,j=w.typedBuffer,F=w.typedBufferStride;for(let P=0;P<4;++P){const m=1===P||3===P,x=i.edgeResolutions[P];l(e(x));const M=x+1,T=c(a,i.edgePeerNeighbors[P]);if(it(a,T,P)){Y(t,P,T);continue}const w=null!=T;l(!w||T.level===a.level),l(!w||g(a,T)<=0);const q=T?.renderData,W=q?.geometryState;if(u){const t=a.surface;if(!T&&t&&!t.updatingRootTiles){const e=d[P],n=a.findNeighborTile(e,t=>t.loaded||t.leaf||t.level===a.level);n?n.intersectsClippingArea&&(l(!n.loaded),l(!n.leaf),l(n.level===h)):l(null==t?.rootTiles||!a.shouldHaveNeighbor(e))}}const k=1===P?p[2]:p[0],z=T?.extent,G=z&&m?1===P?z[0]:z[2]:k,H=0===P?p[3]:p[1],J=1===P?1:0,K=0===P?1:0,Q=1===P?v:S,X=0===P?I:V,Z=Math.sin(Q),$=Math.cos(Q),_=Math.sin(X),tt=Math.cos(X),et=W?.samplerData,nt=w?(t,e,n)=>.5*(r(t,e,B)+r(n,e,et)):(t,e,n)=>r(t,e,B),ot=s.outerEdgesOffsetAndLength[2*P+0],st=o&&M>3?M-3:1,rt=null!=B&&B.some(t=>null!=t),at=null!=et&&et.some(t=>null!=t),ct=rt||at,ut=1/x,dt=ot;l(!z||f(z[2]-z[0],p[2]-p[0]));(()=>{const t=1===P?-1:3===P?1:0,e=0===P?-1:2===P?1:0,o=(p[2]-p[0])*ut,i=t*o,a=e*o,c=m?t*((v-S)*ut):0,l=m?0:e*ut,u=K,d=m?Q+c:Q,f=m?Math.sin(d):Z,g=m?Math.cos(d):$,h=m?Q-c:Q,x=m?Math.sin(h):Z,V=m?Math.cos(h):$,I=m?X:D(u+l),T=m?_:Math.sin(I),q=m?tt:Math.cos(I),W=m?X:D(u-l),z=m?_:Math.sin(W),Y=m?tt:Math.cos(W);let ot=0,rt=0,it=0;{const t=0*ut,e=m?k:b*(1-t)+C*t,n=m?G:e,o=m?L*(1-t)+A*t:H,s=m?Q:S*(1-t)+v*t,r=m?Z:Math.sin(s),i=m?$:Math.cos(s),a=m?D(t):X,c=m?Math.sin(a):_,l=m?Math.cos(a):tt,u=y+nt(e,o,n);ot=i*l*u,rt=r*l*u,it=c*u}let at=0,ft=0,mt=0;{const t=1*ut,e=m?k:b*(1-t)+C*t,n=m?G:e,o=m?L*(1-t)+A*t:H,s=m?Q:S*(1-t)+v*t,r=m?Z:Math.sin(s),i=m?$:Math.cos(s),a=m?D(t):X,c=m?Math.sin(a):_,l=m?Math.cos(a):tt,u=y+nt(e,o,n);at=i*l*u,ft=r*l*u,mt=c*u}for(let p=1;p<M-1;p+=st){let t=0,e=0,o=0;{const n=(p+1)*ut,s=m?k:b*(1-n)+C*n,r=m?G:s,i=m?L*(1-n)+A*n:H,a=m?Q:S*(1-n)+v*n,c=m?Z:Math.sin(a),l=m?$:Math.cos(a),u=m?D(n):X,d=m?Math.sin(u):_,f=m?Math.cos(u):tt,g=y+nt(s,i,r);t=l*f*g,e=c*f*g,o=d*g}const c=t,l=e,u=o,d=at,h=ft,M=mt;at=c,ft=l,mt=u;{const t=dt+p,e=t*F,o=d-O,s=h-R,r=M-U;j[e]=o,j[e+1]=s,j[e+2]=r,lt(o,s,r,E);const i=p*ut,a=m?J:i,c=m?i:K;N.setValues(t,Math.round(a*n),Math.round(c*n))}const I=ot,W=rt,st=it;ot=d,rt=h,it=M;const gt=d,ht=h,pt=M,xt=1/Math.sqrt(gt*gt+ht*ht+pt*pt),Mt=pt*xt;let yt=0,St=0,vt=0;if(ct&&Mt*Mt<.999){let t=0,e=0,n=0;{const o=0===P?-1:1;t=o*(c-I),e=o*(l-W),n=o*(u-st)}{const o=p*ut,s=m?k:b*(1-o)+C*o,c=m?G:s,l=m?L*(1-o)+A*o:H,u=m?Q:S*(1-o)+v*o,d=m?Z:Math.sin(u),h=m?$:Math.cos(u),M=m?D(o):X,I=m?Math.sin(M):_,E=m?Math.cos(M):tt;let O=gt,R=ht,U=pt;if(w){const t=y+r(c-i,l-a,et),e=m?E:Y;O=(m?V:h)*e*t,R=(m?x:d)*e*t,U=(m?I:z)*t}{const o=y+r(s+i,l+a,B),c=m?E:q,u=(m?g:h)*c*o,p=(m?f:d)*c*o,x=(m?I:T)*o;w||(O=2*gt-u,R=2*ht-p,U=2*pt-x);const M=3===P?-1:1,S=M*(O-u),v=M*(R-p),V=M*(U-x);yt=n*v-e*V,St=t*V-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=gt*xt,St=ht*xt,vt=pt*xt;s.setEdgeNormalFromValues(P,p,yt,St,vt)}})()}}function b(t){Z(t)}function C(t,e){return Math.PI/2-2*Math.atan(Math.exp(-t/e))}function L(t,e,n,o){return C(t*(1-o)+e*o,n)}function A(t,e,n){return t*(1-n)+e*n}function P(t){const{tile:e}=t;if(e.surface.isWebMercator){const t=e.extent,n=e.ellipsoid.radius;return e=>L(t[1],t[3],n,e)}const n=e.extentInRadians;return t=>A(n[1],n[3],t)}function D(t,e){const{tile:n,geometryState:s,geometry:r}=t,{extent:i,surface:a}=n,{wireframe:c}=s,l=i[0],u=i[1],d=i[2]-l,f=i[3]-u,{numVerticesPerSide:m,clippingArea:g}=s,h=null!=g?Math.max(0,(g[0]-l)/d):0,p=null!=g?Math.max(0,(g[1]-u)/f):0,x=null!=g?Math.min(1,(g[2]-l)/d):1,M=null!=g?Math.min(1,(g[3]-u)/f):1,y=(m-2)**2,S=ut(s),v=y+4*S,V=a.renderer.tileGeometryCache.acquire(v),{boundingBox:I}=r;o(I),r.numVerticesPerSide=m,r.vertexAttributes=V,r.maxEdgeVertexCount=S,r.minu=h,r.minv=p,r.maxu=x,r.maxv=M,E(t),r.edgeVerticesStartIndex=y,Q(t),U(t),W(r,[],c),t.intersectionData=null}function E(e){const o=e.tile;if(!o.intersectsClippingArea)return;const{geometry:s,geometryState:i,localOrigin:a}=e,{samplerData:c,clippingArea:l,numVerticesPerSide:u}=i,{surface:d,extent:f,ellipsoid:m}=o,{isWebMercatorOnPlateCarree:g}=d,p=null!=l?l:st,x=f[0],M=f[1],y=f[2],S=f[3],v=Math.max(x,p[0]),V=Math.min(y,p[2]),I=Math.max(M,p[1]),B=Math.min(S,p[3]),b=m.radius,C=o.horizontalScale,L=u-1,A=u-2,{minu:P,minv:D,maxu:E,maxv:T,boundingBox:O,vertexAttributes:R}=s,{position:U,uv0:w}=R,{typedBuffer:N,typedBufferStride:j}=R.normalCompressed,F=a[0],q=a[1],W=a[2],k=U.typedBuffer,z=U.typedBufferStride;let G=0;const H=t(M,I,B),J=g?(Math.PI/2-2*Math.atan(Math.exp(-H/b)))*b:H*C,K=1/L,Q=t(M*(1-K)+S*K,I,B);let X=J,Y=g?(Math.PI/2-2*Math.atan(Math.exp(-Q/b)))*b:Q*C;for(let Z=1;Z<=A;Z++){const e=Z/L,o=t(M*(1-e)+S*e,I,B),s=t(e,D,T),i=Y,a=(Z-1)/L,l=t(M*(1-a)+S*a,I,B),u=X,d=(Z+1)/L,f=t(M*(1-d)+S*d,I,B),m=g?(Math.PI/2-2*Math.atan(Math.exp(-f/b)))*b:f*C,p=t(d,D,T);X=Y,Y=m;const R=t(x,v,V);let U=R*C,H=r(R,o,c);const J=1/L,K=t(J,P,E),Q=t(x*(1-K)+y*K,v,V);let $=K,_=Q,tt=Q*C,et=r(Q,o,c);if(1===Z){const e=tt-F,o=X-q,r=et-W,i=0*z;k[i]=e,k[i+1]=o,k[i+2]=r,lt(e,o,r,O);const a=t(J,P,E);w.setValues(G,Math.round(a*n),Math.round(s*n))}for(let g=1;g<=A;g++){const e=tt,a=et,d=(g+1)/L,M=t(d,P,E),S=t(x*(1-d)+y*d,v,V),I=_;_=S;{const t=G+1,e=t*z;if(1===Z||g===A){const a=S*C,l=r(S,o,c);if(1===Z&&g<A){const o=a-F,r=i-q,c=l-W;k[e]=o,k[e+1]=r,k[e+2]=c,lt(o,r,c,O),w.setValues(t,Math.round(M*n),Math.round(s*n))}tt=a,et=l}else tt=k[e]+F,et=k[e+2]+W}const B=tt,b=et,D=U,T=H;U=e,H=a;const R=(G-A)*z,J=1===Z?r(I,l,c):k[R+2]+W,K=r(I,f,c);if(Z<A){const t=G+A,o=t*z,s=e-F,r=m-q,i=K-W;k[o]=s,k[o+1]=r,k[o+2]=i,lt(s,r,i,O);const a=$;$=M,w.setValues(t,Math.round(a*n),Math.round(p*n))}{const t=B-D,e=u-m,n=e*(b-T),o=t*(J-K),s=-e*t,r=n*n+o*o+s*s;if(0===r)h(N,G,0,0,1,j);else{const t=1/Math.sqrt(r);h(N,G,n*t,o*t,s*t,j)}}++G}}}function T(t,e){t.tile.intersectsClippingArea&&(N(t),w(t,!0),_(t),t.intersectionData=null)}function O(t,e){t.tile.intersectsClippingArea&&(X(t),U(t),_(t),tt(t),t.intersectionData=null)}function R(t,e){t.tile.intersectsClippingArea&&(U(t),_(t),t.intersectionData=null)}function U(t,e){t.tile.intersectsClippingArea&&(N(t),w(t,!1))}function w(n,o){const{geometry:s,geometryState:i,localOrigin:a}=n,f=n.tile,{surface:m,extent:h}=f,{clippingArea:p,samplerData:x}=i,M=null!=p?p:st,y=h[0],S=h[2],v=h[1],V=h[3],I=[V>M[3],S>M[2],v<M[1],y<M[0]],B=f.horizontalScale,b=q(m.isWebMercatorOnPlateCarree,f.ellipsoid.radius,B),{minu:C,minv:L,maxu:A,maxv:P,boundingBox:D}=s,E=Math.max(y,M[0]),T=Math.min(S,M[2]),O=Math.max(v,M[1]),R=Math.min(V,M[3]),U=a[0],w=a[1],N=a[2];for(let j=0;j<4;++j){const a=1===j||3===j,h=i.edgeResolutions[j];l(e(h));const p=h+1,M=I[j],F=c(f,i.edgePeerNeighbors[j]);if(!M&&it(f,F,j)){Y(n,j,F);continue}const q=null!=F&&!M,W=F?.renderData,k=W?.geometryState;if(u&&(l(!q||F.level===f.level),l(!q||g(f,F)<=0),f&&!F&&!m.updatingRootTiles)){const t=d[j],e=f.findNeighborTile(t,t=>t.loaded||t.leaf||t.level===f.level);m.updatingRootTiles||(e?e.intersectsClippingArea&&(l(!e.loaded),l(!e.leaf),l(e.level===f.level)):l(null==m?.rootTiles||!f.shouldHaveNeighbor(t)))}const z=t(1===j?S:y,E,T),G=t(0===j?V:v,O,R),H=k?.samplerData,J=o&&p>3?p-3:1,K=t(1===j?1:0,C,A),Q=t(0===j?1:0,L,P),X=q?(t,e)=>.5*(r(t,e,H)+r(t,e,x)):(t,e)=>r(t,e,x),Z=(S-y)/h,$=a?1===j?Z:-Z:0,_=a?0:0===j?Z:-Z,tt=-$,et=-_;let nt=0,ot=0,st=0;{const e=0/h,n=a?z:t(y*(1-e)+S*e,E,T),o=a?t(v*(1-e)+V*e,O,R):G,s=X(n,o);nt=n*B,ot=b(o),st=s}let rt=0,at=0,ct=0;{const e=1/h,n=a?z:t(y*(1-e)+S*e,E,T),o=a?t(v*(1-e)+V*e,O,R):G,s=X(n,o);rt=n*B,at=b(o),ct=s}for(let e=1;e<p-1;e+=J){const n=e/h,o=rt,i=at,c=ct;{const r=a?K:t(n,C,A),l=a?t(n,L,P):Q,u=o-U,d=i-w,f=c-N;lt(o,d,f,D),s.setEdgeVertexFromValuesRawPositionUV(j,e,u,d,f,r,l)}{const n=(e+1)/h,o=a?z:t(y*(1-n)+S*n,E,T),s=a?t(v*(1-n)+V*n,O,R):G,r=X(o,s);rt=o*B,at=b(s),ct=r}const l=rt,u=ct,d=nt,f=ot,m=st;nt=o,ot=i,st=c;let g=0,p=0,M=0;if(a){const e=at-i,s=u-c,a=f-i,l=m-c,d=t(v*(1-n)+V*n,O,R),h=z+tt,y=h*B-o,S=r(h,d,x)-c,I=3===j?-1:1;if(g=I*(-a+e)*S,p=I*y*(-l+s),M=-I*y*(-a+e),q){const t=z+$,n=t*B-o;g=(-a+e)*(S-(r(t,d,H)-c)),p=(y-n)*(-l+s),M=-(y-n)*(-a+e)}}else{const e=l-o,s=u-c,a=d-o,f=m-c,h=t(y*(1-n)+S*n,E,T),v=G+et,V=r(h,v,x)-c,I=b(v)-i,B=2===j?-1:1;if(g=B*I*(-f+s),p=B*(-a+e)*V,M=-B*I*(-a+e),q){const t=h,n=G+_,o=b(n)-i;g=(-I+o)*(-f+s),p=(-a+e)*(-V+(r(t,n,H)-c)),M=-(-I+o)*(-a+e)}}const I=1/Math.sqrt(g*g+p*p+M*M);s.setEdgeNormalFromValues(j,e,g*I,p*I,M*I)}}}function N(t,e){Z(t)}function j(t,e){return(Math.PI/2-2*Math.atan(Math.exp(-t/e)))*e}function F(t,e){return t*e}function q(t,e,n){return t?t=>j(t,e):t=>F(t,n)}function W(t,e,n){const{numVerticesPerSide:o,vertexAttributes:s,maxEdgeVertexCount:r}=t,i=o-1,c=s.count,l=2*(o-3)*(o-3),u=4*(i+r-3),d=a.reduce((e,n)=>e+(i+t.getEdgeCount(n)-3),0),f=e.reduce((t,e)=>t+i*(2*(e.latitudeResolution-1)+1),0),m=3*(n?2:1),g=(l+u+f)*m,h=c>=p?new Uint32Array(g):new Uint16Array(g);for(let a=0;a<g;++a)h[a]=0;t.indices=h,t.indexCount=(l+d+f)*m,t.poleIndicesStartIndex=l*m,t.edgeIndicesStartIndex=(l+f)*m,n?(H(t),J(t,e),K(t)):(k(t),z(t,e),G(t))}function k(t){const{numVerticesPerSide:e,indices:n,vertexAttributes:o}=t,{position:s}=o,{typedBuffer:r,typedBufferStride:i}=s,a=e-2,c=e-3,l=0,u=e-3;let d=0;for(let f=0;f<c;++f){const t=f*a;for(let e=l;e<u;++e){const o=t+e,s=o+1,c=s+a,l=c-1;dt(o,s,c,l,i,r)?(n[d]=o,n[d+1]=s,n[d+2]=c,n[d+3]=c,n[d+4]=l,n[d+5]=o):(n[d]=o,n[d+1]=s,n[d+2]=l,n[d+3]=l,n[d+4]=s,n[d+5]=c),d+=6}}}function z(t,e){const{numVerticesPerSide:n,indices:o,poleIndicesStartIndex:s}=t,r=n-1;let i=s;for(const a of e){const e=a.isNorth?1:2,s=a.isNorth?2:1,c=a.isNorth?3:4,l=a.isNorth?4:3;let u=t.getEdgeVertexIndex(a.connectedOuterEdgeOffset,0),d=1;for(let t=0;t<a.latitudeResolution;++t){const f=0===t?a.rowOffset:u+n;for(let n=0;n<r;n++){const r=f+n;o[i]=u,o[i+e]=u+1,o[i+s]=r,t<a.latitudeResolution-1?(o[i+c]=u+1,o[i+l]=r+1,o[i+5]=r,i+=6):i+=3,u+=d}u=f,d=1}}}function G(t){const{indices:e,numVerticesPerSide:n,edgeIndicesStartIndex:o}=t,s=n-1,r=s-2;let i=o;for(let a=0;a<4;++a){const n=ct[a];let o=0,c=0;const u=t.getEdgeCount(a),d=n.count;l(d===s-1);const f=1===a||2===a,m=f?1:2,g=f?2:1,h=t.getEdgeFirstVertexIndex(a),p=1,x=n.vertex0Index,M=n.stride;for(;o<u-1||c<d-1;){const t=x+c*M,n=h+o*p,a=o<u-1,l=c<d-1,f=a&&(!l||(a?0+s*(o+.5)/(u-1):0)<=(l?1+r*(c+.5)/(d-1):0));f?++o:++c;const y=f?n+p:t+M;e[i]=t,e[i+m]=n,e[i+g]=y,i+=3}}t.indexCount=i}function H(t){const{indices:e,numVerticesPerSide:n,vertexAttributes:o}=t,{position:s}=o,{typedBuffer:r,typedBufferStride:i}=s,a=n-2;let c=0;for(let l=0;l<n-3;++l){const t=l*a;for(let o=0;o<n-3;++o){const n=l*a+o,s=n+1,u=s+a,d=u-1,f=t+o,m=f+1,g=m+a;dt(f,m,g,g-1,i,r)?(ft(e,c,n,s,u),c+=6,ft(e,c,u,d,n)):(ft(e,c,n,s,d),c+=6,ft(e,c,d,u,s)),c+=6}}}function J(t,e){const{indices:n,numVerticesPerSide:o,poleIndicesStartIndex:s}=t,r=o-1;let i=s;for(const a of e){const e=a.connectedOuterEdgeOffset;let s=t.getEdgeVertexIndex(e,0),c=1;for(let t=0;t<a.latitudeResolution;++t){const e=0===t?a.rowOffset:s+o;for(let o=0;o<r;o++)ft(n,i,s,s+1,e+o),i+=6,t<a.latitudeResolution-1&&(ft(n,i,s+1,e+o+1,e+o),i+=6),s+=c;s=e,c=1}}}function K(t){const{indices:e,numVerticesPerSide:n,edgeIndicesStartIndex:o}=t,s=n-1,r=s-2;let i=o;for(let a=0;a<4;++a){const n=ct[a];let o=0,c=0;const u=t.getEdgeCount(a),d=n.count;l(d===s-1);const f=1===a||2===a,m=f?1:3,g=f?3:1,h=t.getEdgeFirstVertexIndex(a),p=1,x=n.vertex0Index,M=n.stride;for(;o<u-1||c<d-1;){const t=x+c*M,n=h+o*p,a=o<u-1,l=c<d-1,f=a&&(!l||(a?0+s*(o+.5)/(u-1):0)<=(l?1+r*(c+.5)/(d-1):0));f?++o:++c;const y=f?n+p:t+M;e[i]=t,e[i+m]=n,e[i+m+1]=n,e[i+g]=y,e[i+g+1]=y,e[i+5]=t,i+=6}}t.indexCount=i}function Q(t){const{geometry:e,geometryState:n}=t,{edgeResolutions:o}=n,{numVerticesPerSide:s,edgeVerticesStartIndex:r}=e,i=s-2;let a=r;for(let c=0;c<4;++c){{const t=0===c||2===c,e=(0===c?i-1:0)*i+(1===c?i-1:0),n=(t?0:1)*i+(t?1:0),o=ct[c];o.vertex0Index=e,o.stride=n,o.count=i}{const t=o[c]+1;e.outerEdgesOffsetAndLength[2*c+0]=a,e.outerEdgesOffsetAndLength[2*c+1]=t,a+=t}}}function X(t){Q(t),t.geometryState.wireframe?K(t.geometry):G(t.geometry)}function Y(o,s,r){const{geometryState:i,geometry:a,tile:c,localOrigin:u}=o,d=1===s||3===s,f=i.edgeResolutions[s];l(e(f));const m=f+1,{boundingBox:g,minu:h,minv:p,maxu:x,maxv:M,vertexAttributes:y}=a,S=t(1===s?1:0,h,x),v=t(0===s?1:0,p,M),V=r.renderData,I=V.geometryState,B=V.geometry,b=(s+2)%4,C=B.getEdgeCount(b),L=c.getNeighborEdgeStartVertexIndex(s,r)*f,A=f*2**(c.level-r.level);l(I.edgeResolutions[b]===A),l(C-1===A);const P=V.localOrigin[0]-u[0],D=V.localOrigin[1]-u[1],E=V.localOrigin[2]-u[2],T=a.getEdgeFirstVertexIndex(s),{position:O,uv0:R}=y,U=O.typedBuffer,w=O.typedBufferStride,N=y.normalCompressed,j=N.typedBuffer,F=N.typedBufferStride,q=B.vertexAttributes,W=B.getEdgeFirstVertexIndex(b),k=q.position.typedBuffer,z=q.position.typedBufferStride,G=q.normalCompressed.typedBuffer,H=q.normalCompressed.typedBufferStride;for(let e=1;e<m-1;++e){const o=T+e,s=W+(L+e),r=o*w,i=s*z,a=k[i]+P,c=k[i+1]+D,l=k[i+2]+E;U[r]=a,U[r+1]=c,U[r+2]=l,lt(a,c,l,g);const u=o*F,m=s*H;j[u]=G[m],j[u+1]=G[m+1];const y=e/f,V=d?S:t(y,h,x),I=d?t(y,p,M):v;R.setValues(o,Math.round(V*n),Math.round(I*n))}}function Z(e){const{geometry:o,geometryState:s,localOrigin:i}=e,{clippingArea:a,samplerData:c}=s,{minu:u,minv:d,maxu:f,maxv:m,boundingBox:h,vertexAttributes:p}=o,x=e.tile,{surface:M,ellipsoid:y,extent:S,extentInRadians:v,horizontalScale:V}=x,I="local"===M.view?.viewingMode,B=y.radius;let b=0,C=0,L=0;const A=(t,e,n)=>{const o=v[0===e?1:3],s=v[0===t?0:2],r=Math.cos(o),i=Math.sin(o),a=Math.sin(s),c=Math.cos(s),l=B+n;b=c*r*l,C=a*r*l,L=i*l},D=I?(()=>{const e=a,n=null!=e&&(S[3]>e[3]||S[2]>e[2]||S[1]<e[1]||S[0]<e[0]),o=q(M.isWebMercatorOnPlateCarree,B,V);return(s,r,i)=>{const a=0===s?S[0]:S[2],c=0===r?S[1]:S[3],l=n?t(a,e[0],e[2]):a,u=n?t(c,e[1],e[3]):c,d=i;b=l*V,C=o(u),L=d}})():A;let E=0,T=0,O=0,R=0,U=0,w=0,N=0,j=0,F=0;const W=I&&M.isWebMercatorOnPlateCarree,k=(t,e,n,o,s)=>{let r=0,i=0,a=0;if(I){const t=e*V,s=W?(Math.PI/2-2*Math.atan(Math.exp(-n/B)))*B:n*V;r=t-b,i=s-C,a=o-L}else{const s=P(t),c=t.tile,l=c.extent,u=c.extentInRadians,d=(e-l[0])/(l[2]-l[0]),f=(n-l[1])/(l[3]-l[1]),m=u[0]*(1-d)+u[2]*d,g=s(f),h=Math.cos(g),p=Math.sin(g),x=Math.sin(m),M=Math.cos(m),y=B+o;r=M*h*y-b,i=x*h*y-C,a=p*y-L}switch(s){case 0:N+=r,j+=i,F+=a;break;case 1:R-=r,U-=i,w-=a;break;case 2:N-=r,j-=i,F-=a;break;case 3:R+=r,U+=i,w+=a}},z=a??st,G=S[0],H=S[2],J=S[1],K=S[3],Q=[K>z[3],H>z[2],J<z[1],G<z[0]],X=Math.max(G,z[0]),Y=Math.min(H,z[2]),Z=Math.max(J,z[1]),_=Math.min(K,z[3]),tt=t=>Math.max(z[0],Math.min(z[2],t)),et=t=>Math.max(z[1],Math.min(z[3],t)),ot=t=>{const e=s.cornerNeighborCornerTiles;E=0,T=0,O=1,R=0,U=0,w=0,N=0,j=0,F=0;let n=1/0;for(let s=0;s<4;++s){const o=e[4*t+s];n=Math.min(n,o?.level??1/0)}for(let s=0;s<4;++s){const o=e[4*t+s];rt[s]=o?.level===n?o:null}let o=1,i=0;for(let s=0;s<4;++s){const t=rt[s];t&&(o=Math.max(o,t?.renderData.geometryState.numVerticesPerSide),i=t.extent[2]-t.extent[0])}const a=i,c=o;l(c>1);const u=a/c;for(let s=0;s<4;++s){const t=rt[(s+3)%4],e=rt[s%4];if(!t&&!e)continue;const n=0===s?1:1===s?2:2===s?3:0,o=0===s?2:1===s?3:2===s?0:1;if(t&&e){const i=nt[s][0]*u,a=nt[s][1]*u,c=t.extent,l=tt(c[0===n||1===n?2:0]+i),d=et(c[0===n||3===n?3:1]+a),f=e.extent,m=tt(f[0===o||1===o?2:0]+i),g=et(f[0===o||3===o?3:1]+a),h=t.renderData,p=e.renderData,x=r(l,d,h.geometryState.samplerData),M=r(m,g,p.geometryState.samplerData);k(h,l,d,.5*(x+M),s)}else{const i=t??e,a=t?n:o,c=i.extent,l=nt[s],d=tt(c[0===a||1===a?2:0]+l[0]*u),f=et(c[0===a||3===a?3:1]+l[1]*u),m=i.renderData,g=r(d,f,m.geometryState.samplerData);k(m,d,f,g,s)}}if(!I){const t=Math.sqrt(b*b+C*C+L*L);E=b/t,T=C/t,O=L/t}if(I||O*O<.999){const t=Math.sqrt(R*R+U*U+w*w);R/=t,U/=t,w/=t;const e=Math.sqrt(N*N+j*j+F*F);N/=e,j/=e,F/=e,E=w*j-U*F,T=R*F-w*N,O=U*N-R*j;const n=1/Math.sqrt(E*E+T*T+O*O);E*=n,T*=n,O*=n}},it=s.cornerNeighborCornerTiles;for(let P=0;P<4;++P){const e=P,a=(P+1)%4,M=0===P||1===P?1:0,y=0===P||3===P?1:0,S=t(M,u,f),v=t(y,d,m),V=o.getEdgeFirstVertexIndex(e),I=o.getEdgeCount(e),B=0===P||3===P?I-1:0,A=o.getEdgeFirstVertexIndex(a),R=o.getEdgeCount(a),U=0===P||1===P?R-1:0;let w=-1;for(let t=0;t<4;++t){const e=it[4*P+t],n=it[4*P+w];e&&(-1===w||g(n,e)>0)&&(w=t)}const N=w,j=it[4*P+N];if(j!==x){const t=x.level-j.level,e=2**t,o=[j.lij[0]+t,j.lij[1]*e,j.lij[2]*e],r=[o[1]+e===x.lij[1],0===P&&(1===N||0===N&&j!==it[4*P+3])||1===P&&(0===N||1===N&&j!==it[4*P+2]),o[1]===x.lij[1]+1,2===P&&(3===N||2===N&&j!==it[4*P+1])||3===P&&(2===N||3===N&&j!==it[4*P+0])],a=r.reduce((t,e)=>t+(e?1:0),0);l(1===a||2===a);let c=-1,u=-1;const d=j.renderData;if(1===a){const t=r.findIndex(t=>t);l(0<=t&&t<=3),c=(t+2)%4;const e=s.edgeResolutions[t];u=x.getNeighborEdgeStartVertexIndex(t,j)*e+e*(0===t&&0===P||1===t&&0===P||2===t&&1===P||3===t&&3===P?1:0)}else{l(r[1]||r[3]),c=r[1]?3:1;const t=d.geometryState.edgeResolutions[c];u=0===P||3===P?0:t}const f=d.geometry;{const t=V+B,e=A+U,o=f.getEdgeFirstVertexIndex(c)+u,s=f.vertexAttributes,r=d.localOrigin,a=s.position,l=a.typedBuffer,m=o*a.typedBufferStride,g=l[m]+r[0]-i[0],x=l[m+1]+r[1]-i[1],M=l[m+2]+r[2]-i[2];lt(g,x,M,h);const y=p.position,I=y.typedBuffer,b=t*y.typedBufferStride;I[b]=g,I[b+1]=x,I[b+2]=M;const C=e*y.typedBufferStride;I[C]=g,I[C+1]=x,I[C+2]=M;const L=p.uv0;L.setValues(t,Math.round(S*n),Math.round(v*n)),L.setValues(e,Math.round(S*n),Math.round(v*n));{const n=s.normalCompressed.typedBuffer,r=o*s.normalCompressed.typedBufferStride,i=p.normalCompressed,a=i.typedBuffer;{const e=t*i.typedBufferStride;a[e]=n[r],a[e+1]=n[r+1]}{const t=e*i.typedBufferStride;a[t]=n[r],a[t+1]=n[r+1]}}}}else{const n=Q[e],s=Q[a];let l;if(n||s){const e=t(G*(1-M)+H*M,X,Y),n=t(J*(1-y)+K*y,Z,_);l=r(e,n,c)}else l=$(it,P);D(M,y,l),ot(P);const u=b-i[0],d=C-i[1],f=L-i[2];lt(u,d,f,h),o.setEdgeVertexFromValuesRawPositionUVNormal(e,B,u,d,f,S,v,E,T,O),o.setEdgeVertexFromValuesRawPositionUVNormal(a,U,u,d,f,S,v,E,T,O)}}for(let t=0;t<4;++t)rt[t]=null}function $(t,e){const n=4*e,o=a.reduce((e,o)=>Math.min(e,t[n+o]?.level??1/0),1/0);u&&(l(!t[n+0]||!t[n+2]||m(t[n+0],t[n+2],5)),l(!t[n+1]||!t[n+3]||m(t[n+1],t[n+3],7)));let s=0,i=0;for(let a=0;a<4;++a){const e=t[n+a];if(e?.level===o){const t=0===a||1===a,n=0===a||3===a,o=e.extent,c=o[t?0:2],l=o[n?1:3],u=e.renderData?.geometryState?.samplerData;i+=r(c,l,u),s++}}const c=s?i/s:0;return l(null!=c),c}function _(t){const{vao:e,geometry:n}=t,{vertexAttributes:o,edgeVerticesStartIndex:s}=n,r=o.position.typedBuffer;e.buffer()?.setSubData(r,s,s,r.length)}function tt(t){const{vao:e,geometry:n}=t,{indices:o,indexCount:s,edgeIndicesStartIndex:r}=n;e.indexBuffer.setSubData(o,r,r,s)}class et{constructor(t,e,n,o,s){this.isNorth=t,this.connectedRowOffset=e,this.connectedOuterEdgeOffset=n,this.rowOffset=o,this.latitudeResolution=s}}const nt=[[0,1],[1,0],[0,-1],[-1,0]],ot=new i,st=s(-1/0,-1/0,1/0,1/0),rt=[null,null,null,null];function it(t,e,n){if(!e)return!1;const o=g(t,e);return o>0||0===o&&n>=2}class at{constructor(){this.vertex0Index=0,this.stride=1,this.count=0}getVertexIndex(t){return l(0<=t&&t<this.count),this.vertex0Index+this.stride*t}}const ct=[new at,new at,new at,new at];function lt(t,e,n,o){t<o[0]?o[0]=t:t>o[3]&&(o[3]=t),e<o[1]?o[1]=e:e>o[4]&&(o[4]=e),n<o[2]?o[2]=n:n>o[5]&&(o[5]=n)}function ut(t){const{edgeResolutions:e,numVerticesPerSide:n}=t,o=1+Math.max(...e);return Math.max(n,o)}function dt(t,e,n,o,s,r){const i=t*s,a=r[i],c=r[i+1],l=r[i+2],u=e*s,d=r[u],f=r[u+1],m=r[u+2],g=n*s,h=r[g],p=r[g+1],x=r[g+2],M=o*s,y=r[M],S=r[M+1],v=r[M+2];return(d-y)*(d-y)+(f-S)*(f-S)+(m-v)*(m-v)>(a-h)*(a-h)+(c-p)*(c-p)+(l-x)*(l-x)}function ft(t,e,n,o,s){t[e]=n,t[e+1]=o,t[e+2]=o,t[e+3]=s,t[e+4]=s,t[e+5]=n}const mt=6;export{D as createPlanarGlobePatch,x as createSphericalGlobePatch,V as updateCornerSpherical,T as updateCornersPlanar,O as updateEdgeElevationsAndResolutionsPlanar,v as updateEdgeElevationsAndResolutionsSpherical,R as updateEdgesAndCornersPlanar,S as updateEdgesAndCornersSpherical};
|
|
2
|
+
import{clamp as t,isPowerOfTwo as e}from"../../../core/mathUtils.js";import{maxUint16 as n}from"../../../core/typedArrayUtil.js";import{empty as o}from"../../../geometry/support/aaBoundingBox.js";import{fromValues as s}from"../../../geometry/support/aaBoundingRect.js";import{sampleElevation as r,sampleSingleElevation as i}from"./ElevationData.js";import{PatchGeometryLUT as a}from"./PatchGeometryLUT.js";import{zeroToFour as c,neighborTileIfLoadedOrSelf as l}from"./PatchRenderData.js";import{maxPatchTesselation as u,elevationNoDataValue as d}from"./TerrainConst.js";import{internalAssert as f,enableTerrainInternalChecks as m,neighborEdgeIndices as g,almostEquals as h}from"./terrainUtils.js";import{isCornerNeighbor as p}from"./Tile.js";import{compareTilesByLij as x}from"./tileUtils.js";import{compressNormal as M}from"../webgl-engine/lib/Normals.js";const y=65536;function S(t,e){const{tile:n,geometry:s,geometryState:r}=t,{extentInRadians:i,surface:a}=n,{isWebMercator:c,renderer:l}=a,{numVerticesPerSide:u,wireframe:d}=r,f=u-1,m=(u-2)**2,g=c&&(2===e||3===e),h=c&&(1===e||3===e),p=((g?1:0)+(h?1:0))*Ct*u,x=Vt(r),M=m+p+4*x,y=l.tileGeometryCache.acquire(M);s.numVerticesPerSide=u,s.vertexAttributes=y,s.maxEdgeVertexCount=x;const{boundingBox:S}=s;o(S);const B=R(t);ut.update(f,i,B),v(t),s.poleVerticesStartIndex=m;const V=L(t,g,h);s.edgeVerticesStartIndex=m+p,et(t),A(t),Q(s,V,d),t.intersectionData=null}function L(t,e,o){const{tile:s,localOrigin:r,geometry:i}=t,{extent:a,ellipsoid:c}=s,{boundingBox:l,numVerticesPerSide:u,vertexAttributes:d,poleVerticesStartIndex:f}=i,m=u-1,g=r[0],h=r[1],p=r[2],x=c.radius,y=a[1],S=a[3],L=[];let v=f;const B=(t,e)=>{const o=e*u;Bt(-g,-h,t*x-p,l),L.push(new ct(1===t,o,1===t?0:2,v,Ct));const s=E(-1===t?y:S,x),r=t*Math.PI/2-s,i=.99*(1===t?1:-1),a=x+0,{position:c,uv0:f}=d,{typedBuffer:B,typedBufferStride:V}=d.normalCompressed;for(let u=1;u<=Ct;++u){const t=s+r*(u/Ct),e=Math.cos(t),o=Math.sin(t);for(let s=0;s<=m;s++){const t=s/m,r=ut.sinLonLUT[s],u=ut.cosLonLUT[s]*e,d=r*e,x=o,y=u*a-g,S=d*a-h,L=x*a-p;Bt(y,S,L,l),c.setValues(v,y,S,L),f.setValues(v,Math.round(t*n),Math.round(i*n)),M(B,v,u,d,x,V),++v}}};return e&&B(-1,0),o&&B(1,m),L}function v(t){const e=t.geometryState.samplerData,n=1===e?.length?e[0]:null;n?B(t,n):V(t)}function B(t,e){const{tile:n}=t;if(!n.intersectsClippingArea)return;const{geometry:o,geometryState:s,localOrigin:r}=t,{numVerticesPerSide:i}=s,a=i-2,c=i-1,{vertexAttributes:l,boundingBox:u}=o,{position:d,uv0:f}=l,{typedBuffer:m,typedBufferStride:g}=l.normalCompressed,{extent:h}=n,p=n.ellipsoid.radius,x=r[0],y=r[1],S=r[2],L=d.typedBuffer,v=d.typedBufferStride,B=f.typedBuffer,V=f.typedBufferStride;I(c,h,e);let C=0;const T=e.data.values;if(1<=a){const t=ft[1],e=ut.sinLatLUT[1],n=ut.cosLatLUT[1];for(let o=1;o<=a;o++){const s=ut.sinLonLUT[o],r=ut.cosLonLUT[o],i=p+b(o,1,T),a=i*r*n-x,c=i*s*n-y,l=i*e-S;Bt(a,c,l,u);const d=(o-1)*v;L[d]=a,L[d+1]=c,L[d+2]=l;const f=(o-1)*V;B[f]=ft[o],B[f+1]=t}}for(let I=1;I<=a;I++){const t=ut.sinLatLUT[I],e=ut.cosLatLUT[I],n=I+1,o=ft[n],s=ut.sinLatLUT[n],r=ut.cosLatLUT[n],i=ut.sinLonLUT[0],l=ut.cosLonLUT[0],d=p+b(0,I,T);let f=l*e*d-x,h=i*e*d-y,U=t*d-S;const A=C*v;let P=L[A],D=L[A+1],E=L[A+2];for(let w=1;w<=a;w++){const i=ut.sinLonLUT[w],l=ut.cosLonLUT[w];let d=0,A=0,O=0;if(w<a){const t=(C+1)*v;d=L[t],A=L[t+1],O=L[t+2]}else{const n=ut.sinLonLUT[c],o=ut.cosLonLUT[c],s=p+b(c,I,T);d=o*e*s-x,A=n*e*s-y,O=t*s-S}const R=f,N=h,j=U;f=P,h=D,U=E,P=d,D=A,E=O;const F=d-R,q=A-N,W=O-j;let k=0,z=0,G=0;if(I>1){const t=(C-a)*v;k=L[t],z=L[t+1],G=L[t+2]}else{const t=ut.sinLatLUT[0],e=ut.cosLatLUT[0],n=p+b(w,0,T);k=l*e*n-x,z=i*e*n-y,G=t*n-S}const H=p+b(w,n,T),J=l*r*H-x,K=i*r*H-y,Q=s*H-S;if(I<a){const t=C+a,e=t*v;L[e]=J,L[e+1]=K,L[e+2]=Q,Bt(J,K,Q,u);const n=t*V;B[n]=ft[w],B[n+1]=o}const X=k-J,Y=z-K,Z=G-Q;let $=l*e,_=i*e,tt=t;tt*tt<.999&&($=W*Y-q*Z,_=F*Z-W*X,tt=q*X-F*Y);const et=1/Math.sqrt($*$+_*_+tt*tt);M(m,C,$*et,_*et,tt*et,g),++C}}}function V(t){const{tile:e}=t;if(!e.intersectsClippingArea)return;const{geometry:o,geometryState:s,localOrigin:i}=t,{numVerticesPerSide:a,samplerData:c}=s,l=a-2,u=a-1,{vertexAttributes:d,boundingBox:f}=o,{position:m,uv0:g}=d,{typedBuffer:h,typedBufferStride:p}=d.normalCompressed,{extent:x}=e,y=x[0],S=x[2],L=x[1],v=x[3],B=e.ellipsoid.radius,V=i[0],I=i[1],b=i[2],C=m.typedBuffer,T=m.typedBufferStride,U=1/u;let A=0;if(1<=l){const t=U,e=L*(1-t)+v*t,o=ut.sinLatLUT[1],s=ut.cosLatLUT[1];for(let i=1;i<=l;i++){const a=i*U,l=y*(1-a)+S*a,u=ut.sinLonLUT[i],d=ut.cosLonLUT[i],m=B+r(l,e,c),h=m*d*s-V,p=m*u*s-I,x=m*o-b;Bt(h,p,x,f);const M=(i-1)*T;C[M]=h,C[M+1]=p,C[M+2]=x,g.setValues(i-1,Math.round(a*n),Math.round(t*n))}}for(let P=1;P<=l;P++){const t=P*U,e=L*(1-t)+v*t,o=ut.sinLatLUT[P],s=ut.cosLatLUT[P],i=P+1,a=i*U,d=L*(1-a)+v*a,m=ut.sinLatLUT[i],x=ut.cosLatLUT[i],D=ut.sinLonLUT[0],E=ut.cosLonLUT[0],w=B+r(y,e,c);let O=E*s*w-V,R=D*s*w-I,N=o*w-b;const j=A*T;let F=C[j],q=C[j+1],W=C[j+2];for(let v=1;v<=l;v++){const t=v*U,i=y*(1-t)+S*t,D=ut.sinLonLUT[v],E=ut.cosLonLUT[v];let w=0,j=0,k=0;if(v<l){const t=(A+1)*T;w=C[t],j=C[t+1],k=C[t+2]}else{const t=ut.sinLonLUT[u],n=ut.cosLonLUT[u],i=B+r(S,e,c);w=n*s*i-V,j=t*s*i-I,k=o*i-b}const z=O,G=R,H=N;O=F,R=q,N=W,F=w,q=j,W=k;const J=w-z,K=j-G,Q=k-H;let X=0,Y=0,Z=0;if(P>1){const t=(A-l)*T;X=C[t],Y=C[t+1],Z=C[t+2]}else{const t=ut.sinLatLUT[0],e=ut.cosLatLUT[0],n=B+r(i,L,c);X=E*e*n-V,Y=D*e*n-I,Z=t*n-b}const $=B+r(i,d,c),_=E*x*$-V,tt=D*x*$-I,et=m*$-b;if(P<l){const e=A+l,o=e*T;C[o]=_,C[o+1]=tt,C[o+2]=et,Bt(_,tt,et,f),g.setValues(e,Math.round(t*n),Math.round(a*n))}const nt=X-_,ot=Y-tt,st=Z-et;let rt=E*s,it=D*s,at=o;at*at<.999&&(rt=Q*ot-K*st,it=J*st-Q*nt,at=K*nt-J*ot);const ct=1/Math.sqrt(rt*rt+it*it+at*at);M(h,A,rt*ct,it*ct,at*ct,p),++A}}}function I(e,o,s){const r=o[0],i=o[2],a=o[1],c=o[3],l=1/e,{dx:u,dy:d,x0:f,y1:m,safeWidth:g}=s,h=s.data.width;for(let p=0;p<=e;p++){const e=p*l,o=t(u*(r*(1-e)+i*e-f),0,g),s=Math.floor(o);mt[p]=s,pt[p]=o-s;const x=t(d*(m-(a*(1-e)+c*e)),0,g),M=Math.floor(x);gt[p]=M*h,ht[p]=(M+1)*h,xt[p]=x-M,ft[p]=Math.round(e*n)}}function b(t,e,n){const o=mt[t],s=pt[t],r=gt[e],i=ht[e],a=xt[e],c=r+o,l=n[c],u=n[c+1],d=n[i+o],f=n[i+o+1];if(l+d+u+f>=dt)return 0;const m=l+(u-l)*s;return m+(d+(f-d)*s-m)*a}function C(t){t.tile.intersectsClippingArea&&(A(t),it(t),t.intersectionData=null)}function T(t){t.tile.intersectsClippingArea&&(nt(t),A(t),it(t),at(t),t.intersectionData=null)}function U(t){t.tile.intersectsClippingArea&&(D(t),P(t,!0),it(t),t.intersectionData=null)}function A(t){t.tile.intersectsClippingArea&&(D(t),P(t))}function P(t,o=!1){const{geometry:s,geometryState:a,tile:c,localOrigin:u}=t,{level:d,extent:p,extentInRadians:y,ellipsoid:S}=c,L=S.radius,v=y[0],B=y[2],V=y[1],I=y[3],{samplerData:b}=a,C=p[0],T=p[2],U=p[1],A=p[3],P=R(t),{boundingBox:D,vertexAttributes:E}=s,w=u[0],O=u[1],N=u[2],{position:j,uv0:F}=E,q=j.typedBuffer,W=j.typedBufferStride,k=F.typedBuffer,z=F.typedBufferStride,{typedBuffer:G,typedBufferStride:H}=E.normalCompressed,J=1===b?.length?b[0]:null,K=(t,e,n)=>J?i(t,e,J)??0:r(t,e,b)??0;for(let R=0;R<4;++R){const u=1===R||3===R,y=a.edgeResolutions[R];f(e(y));const S=y+1,E=l(c,a.edgePeerNeighbors[R]);if(St(c,E,R)){ot(t,R,E);continue}const j=null!=E;f(!j||E.level===c.level),f(!j||x(c,E)<=0);const F=E?.renderData,Q=F?.geometryState;if(m){const t=c.surface;if(!E&&t&&!t.updatingRootTiles){const e=g[R],n=c.findNeighborTile(e,t=>t.loaded||t.leaf||t.level===c.level);n?n.intersectsClippingArea&&(f(!n.loaded),f(!n.leaf),f(n.level===d)):f(null==t?.rootTiles||!c.shouldHaveNeighbor(e))}}const X=1===R?p[2]:p[0],Y=E?.extent,Z=Y&&u?1===R?Y[0]:Y[2]:X,$=0===R?p[3]:p[1],_=1===R?1:0,tt=0===R?1:0,et=1===R?B:v,nt=0===R?I:V,st=Math.sin(et),rt=Math.cos(et),it=Math.sin(nt),at=Math.cos(nt),ct=Q?.samplerData,lt=1===ct?.length?ct[0]:null,ut=(t,e,n)=>lt?i(n,e,lt)??0:r(n,e,ct)??0,dt=j?(t,e,n)=>.5*(K(t,e)+ut(t,e,n)):K,ft=s.outerEdgesOffsetAndLength[2*R+0],mt=o&&S>3?S-3:1,gt=null!=J||null!=b&&b.some(t=>null!=t),ht=null!=lt||null!=ct&&ct.some(t=>null!=t),pt=gt||ht,xt=1/y,Mt=n*xt,yt=_*n,Lt=tt*n,vt=ft;f(!Y||h(Y[2]-Y[0],p[2]-p[0]));(()=>{const t=1===R?-1:3===R?1:0,e=0===R?-1:2===R?1:0,n=(p[2]-p[0])*xt,o=t*n,s=e*n,a=u?t*((B-v)*xt):0,c=u?0:e*xt,l=tt,d=u?et+a:et,f=u?Math.sin(d):st,m=u?Math.cos(d):rt,g=u?et-a:et,h=u?Math.sin(g):st,x=u?Math.cos(g):rt,y=u?nt:P(l+c),V=u?it:Math.sin(y),I=u?at:Math.cos(y),E=u?nt:P(l-c),F=u?it:Math.sin(E),K=u?at:Math.cos(E);let Q=0,Y=0,_=0;{const t=0*xt,e=u?X:C*(1-t)+T*t,n=u?Z:e,o=u?U*(1-t)+A*t:$,s=u?et:v*(1-t)+B*t,r=u?st:Math.sin(s),i=u?rt:Math.cos(s),a=u?P(t):nt,c=u?Math.sin(a):it,l=u?Math.cos(a):at,d=L+dt(e,o,n);Q=i*l*d,Y=r*l*d,_=c*d}let ot=0,ut=0,ft=0;{const t=1*xt,e=u?X:C*(1-t)+T*t,n=u?Z:e,o=u?U*(1-t)+A*t:$,s=u?et:v*(1-t)+B*t,r=u?st:Math.sin(s),i=u?rt:Math.cos(s),a=u?P(t):nt,c=u?Math.sin(a):it,l=u?Math.cos(a):at,d=L+dt(e,o,n);ot=i*l*d,ut=r*l*d,ft=c*d}for(let p=1;p<S-1;p+=mt){let t=0,e=0,n=0;{const o=(p+1)*xt,s=u?X:C*(1-o)+T*o,r=u?Z:s,i=u?U*(1-o)+A*o:$,a=u?et:v*(1-o)+B*o,c=u?st:Math.sin(a),l=u?rt:Math.cos(a),d=u?P(o):nt,f=u?Math.sin(d):it,m=u?Math.cos(d):at,g=L+dt(s,i,r);t=l*m*g,e=c*m*g,n=f*g}const a=t,c=e,l=n,d=ot,g=ut,y=ft;ot=a,ut=c,ft=l;{const t=vt+p,e=t*W,n=d-w,o=g-O,s=y-N;q[e]=n,q[e+1]=o,q[e+2]=s,Bt(n,o,s,D);const r=Math.round(p*Mt),i=t*z;k[i]=u?yt:r,k[i+1]=u?r:Lt}const S=Q,E=Y,tt=_;Q=d,Y=g,_=y;const mt=d,gt=g,ht=y,St=1/Math.sqrt(mt*mt+gt*gt+ht*ht),Vt=ht*St;let It=0,bt=0,Ct=0;if(pt&&Vt*Vt<.999){let t=0,e=0,n=0;{const o=0===R?-1:1;t=o*(a-S),e=o*(c-E),n=o*(l-tt)}{const a=p*xt,c=u?X:C*(1-a)+T*a,l=u?Z:c,d=u?U*(1-a)+A*a:$,g=u?et:v*(1-a)+B*a,M=u?st:Math.sin(g),y=u?rt:Math.cos(g),S=u?P(a):nt,D=u?Math.sin(S):it,E=u?Math.cos(S):at;let w=mt,O=gt,N=ht;if(j){const t=l-o,e=d-s,n=L+(lt?i(t,e,lt)??0:r(t,e,ct)??0),a=u?E:K;w=(u?x:y)*a*n,O=(u?h:M)*a*n,N=(u?D:F)*n}{const a=c+o,l=d+s,g=L+(J?i(a,l,J)??0:r(a,l,b)??0),h=u?E:I,p=(u?m:y)*h*g,x=(u?f:M)*h*g,S=(u?D:V)*g;j||(w=2*mt-p,O=2*gt-x,N=2*ht-S);const v=3===R?-1:1,B=v*(w-p),C=v*(O-x),T=v*(N-S);It=n*C-e*T,bt=t*T-n*B,Ct=e*B-t*C;const U=1/Math.sqrt(It*It+bt*bt+Ct*Ct);It*=U,bt*=U,Ct*=U}}}else It=mt*St,bt=gt*St,Ct=ht*St;M(G,vt+p,It,bt,Ct,H)}})()}}function D(t){st(t)}function E(t,e){return Math.PI/2-2*Math.atan(Math.exp(-t/e))}function w(t,e,n,o){return E(t*(1-o)+e*o,n)}function O(t,e,n){return t*(1-n)+e*n}function R(t){const{tile:e}=t;if(e.surface.isWebMercator){const t=e.extent,n=e.ellipsoid.radius;return e=>w(t[1],t[3],n,e)}const n=e.extentInRadians;return t=>O(n[1],n[3],t)}function N(t,e){const{tile:n,geometryState:s,geometry:r}=t,{extent:i,surface:a}=n,{wireframe:c}=s,l=i[0],u=i[1],d=i[2]-l,f=i[3]-u,{numVerticesPerSide:m,clippingArea:g}=s,h=null!=g?Math.max(0,(g[0]-l)/d):0,p=null!=g?Math.max(0,(g[1]-u)/f):0,x=null!=g?Math.min(1,(g[2]-l)/d):1,M=null!=g?Math.min(1,(g[3]-u)/f):1,y=(m-2)**2,S=Vt(s),L=y+4*S,v=a.renderer.tileGeometryCache.acquire(L),{boundingBox:B}=r;o(B),r.numVerticesPerSide=m,r.vertexAttributes=v,r.maxEdgeVertexCount=S,r.minu=h,r.minv=p,r.maxu=x,r.maxv=M,j(t),r.edgeVerticesStartIndex=y,et(t),k(t),Q(r,[],c),t.intersectionData=null}function j(e){const o=e.tile;if(!o.intersectsClippingArea)return;const{geometry:s,geometryState:a,localOrigin:c}=e,{samplerData:l,clippingArea:u,numVerticesPerSide:d}=a,{surface:f,extent:m,ellipsoid:g}=o,{isWebMercatorOnPlateCarree:h}=f,p=null!=u?u:Mt,x=m[0],y=m[1],S=m[2],L=m[3],v=Math.max(x,p[0]),B=Math.min(S,p[2]),V=Math.max(y,p[1]),I=Math.min(L,p[3]),b=g.radius,C=o.horizontalScale,T=d-1,U=d-2,{minu:A,minv:P,maxu:D,maxv:E,boundingBox:w,vertexAttributes:O}=s,{position:R,uv0:N}=O,{typedBuffer:j,typedBufferStride:F}=O.normalCompressed,q=c[0],W=c[1],k=c[2],z=R.typedBuffer,G=R.typedBufferStride;let H=0;const J=t(y,V,I),K=h?(Math.PI/2-2*Math.atan(Math.exp(-J/b)))*b:J*C,Q=1/T,X=t(y*(1-Q)+L*Q,V,I);let Y=K,Z=h?(Math.PI/2-2*Math.atan(Math.exp(-X/b)))*b:X*C;const $=1===l?.length?l[0]:null,_=$?(t,e)=>i(t,e,$)??0:(t,e)=>r(t,e,l)??0;for(let r=1;r<=U;r++){const e=r/T,o=t(y*(1-e)+L*e,V,I),s=t(e,P,E),i=Z,a=(r-1)/T,c=t(y*(1-a)+L*a,V,I),l=Y,u=(r+1)/T,d=t(y*(1-u)+L*u,V,I),f=h?(Math.PI/2-2*Math.atan(Math.exp(-d/b)))*b:d*C,m=t(u,P,E);Y=Z,Z=f;const g=t(x,v,B);let p=g*C,O=_(g,o);const R=1/T,J=t(R,A,D),K=t(x*(1-J)+S*J,v,B);let Q=J,X=K,$=K*C,tt=_(K,o);if(1===r){const e=$-q,o=Y-W,r=tt-k,i=0*G;z[i]=e,z[i+1]=o,z[i+2]=r,Bt(e,o,r,w);const a=t(R,A,D);N.setValues(H,Math.round(a*n),Math.round(s*n))}for(let h=1;h<=U;h++){const e=$,a=tt,u=(h+1)/T,g=t(u,A,D),y=t(x*(1-u)+S*u,v,B),L=X;X=y;{const t=H+1,e=t*G;if(1===r||h===U){const a=y*C,c=_(y,o);if(1===r&&h<U){const o=a-q,r=i-W,l=c-k;z[e]=o,z[e+1]=r,z[e+2]=l,Bt(o,r,l,w),N.setValues(t,Math.round(g*n),Math.round(s*n))}$=a,tt=c}else $=z[e]+q,tt=z[e+2]+k}const V=$,I=tt,b=p,P=O;p=e,O=a;const E=(H-U)*G,R=1===r?_(L,c):z[E+2]+k,J=_(L,d);if(r<U){const t=H+U,o=t*G,s=e-q,r=f-W,i=J-k;z[o]=s,z[o+1]=r,z[o+2]=i,Bt(s,r,i,w);const a=Q;Q=g,N.setValues(t,Math.round(a*n),Math.round(m*n))}{const t=V-b,e=l-f,n=e*(I-P),o=t*(R-J),s=-e*t,r=n*n+o*o+s*s;if(0===r)M(j,H,0,0,1,F);else{const t=1/Math.sqrt(r);M(j,H,n*t,o*t,s*t,F)}}++H}}}function F(t,e){t.tile.intersectsClippingArea&&(G(t),z(t,!0),it(t),t.intersectionData=null)}function q(t,e){t.tile.intersectsClippingArea&&(nt(t),k(t),it(t),at(t),t.intersectionData=null)}function W(t,e){t.tile.intersectsClippingArea&&(k(t),it(t),t.intersectionData=null)}function k(t,e){t.tile.intersectsClippingArea&&(G(t),z(t,!1))}function z(n,o){const{geometry:s,geometryState:a,localOrigin:c}=n,u=n.tile,{surface:d,extent:h}=u,{clippingArea:p,samplerData:M}=a,y=null!=p?p:Mt,S=h[0],L=h[2],v=h[1],B=h[3],V=[B>y[3],L>y[2],v<y[1],S<y[0]],I=u.horizontalScale,b=K(d.isWebMercatorOnPlateCarree,u.ellipsoid.radius,I),{minu:C,minv:T,maxu:U,maxv:A,boundingBox:P}=s,D=Math.max(S,y[0]),E=Math.min(L,y[2]),w=Math.max(v,y[1]),O=Math.min(B,y[3]),R=c[0],N=c[1],j=c[2],F=1===M?.length?M[0]:void 0,q=F?(t,e)=>i(t,e,F)??0:(t,e)=>r(t,e,M)??0;for(let W=0;W<4;++W){const c=1===W||3===W,h=a.edgeResolutions[W];f(e(h));const p=h+1,y=V[W],F=l(u,a.edgePeerNeighbors[W]);if(!y&&St(u,F,W)){ot(n,W,F);continue}const k=null!=F&&!y,z=F?.renderData,G=z?.geometryState;if(m&&(f(!k||F.level===u.level),f(!k||x(u,F)<=0),u&&!F&&!d.updatingRootTiles)){const t=g[W],e=u.findNeighborTile(t,t=>t.loaded||t.leaf||t.level===u.level);d.updatingRootTiles||(e?e.intersectsClippingArea&&(f(!e.loaded),f(!e.leaf),f(e.level===u.level)):f(null==d?.rootTiles||!u.shouldHaveNeighbor(t)))}const H=t(1===W?L:S,D,E),J=t(0===W?B:v,w,O),K=G?.samplerData,Q=o&&p>3?p-3:1,X=t(1===W?1:0,C,U),Y=t(0===W?1:0,T,A),Z=1===K?.length?K[0]:null,$=(t,e)=>Z?i(t,e,Z)??0:r(t,e,K)??0,_=k?(t,e)=>.5*($(t,e)+q(t,e)):q,tt=(L-S)/h,et=c?1===W?tt:-tt:0,nt=c?0:0===W?tt:-tt,st=-et,rt=-nt;let it=0,at=0,ct=0;{const e=0/h,n=c?H:t(S*(1-e)+L*e,D,E),o=c?t(v*(1-e)+B*e,w,O):J,s=_(n,o);it=n*I,at=b(o),ct=s}let lt=0,ut=0,dt=0;{const e=1/h,n=c?H:t(S*(1-e)+L*e,D,E),o=c?t(v*(1-e)+B*e,w,O):J,s=_(n,o);lt=n*I,ut=b(o),dt=s}for(let e=1;e<p-1;e+=Q){const n=e/h,o=lt,i=ut,a=dt;{const r=c?X:t(n,C,U),l=c?t(n,T,A):Y,u=o-R,d=i-N,f=a-j;Bt(o,d,f,P),s.setEdgeVertexFromValuesRawPositionUV(W,e,u,d,f,r,l)}{const n=(e+1)/h,o=c?H:t(S*(1-n)+L*n,D,E),s=c?t(v*(1-n)+B*n,w,O):J,r=_(o,s);lt=o*I,ut=b(s),dt=r}const l=lt,u=dt,d=it,f=at,m=ct;it=o,at=i,ct=a;let g=0,p=0,x=0;if(c){const e=ut-i,s=u-a,c=f-i,l=m-a,d=t(v*(1-n)+B*n,w,O),h=H+st,y=h*I-o,S=r(h,d,M)-a,L=3===W?-1:1;if(g=L*(-c+e)*S,p=L*y*(-l+s),x=-L*y*(-c+e),k){const t=H+et,n=t*I-o;g=(-c+e)*(S-(r(t,d,K)-a)),p=(y-n)*(-l+s),x=-(y-n)*(-c+e)}}else{const e=l-o,s=u-a,c=d-o,f=m-a,h=t(S*(1-n)+L*n,D,E),y=J+rt,v=r(h,y,M)-a,B=b(y)-i,V=2===W?-1:1;if(g=V*B*(-f+s),p=V*(-c+e)*v,x=-V*B*(-c+e),k){const t=h,n=J+nt,o=b(n)-i;g=(-B+o)*(-f+s),p=(-c+e)*(-v+(r(t,n,K)-a)),x=-(-B+o)*(-c+e)}}const y=1/Math.sqrt(g*g+p*p+x*x);s.setEdgeNormalFromValues(W,e,g*y,p*y,x*y)}}}function G(t,e){st(t)}function H(t,e){return(Math.PI/2-2*Math.atan(Math.exp(-t/e)))*e}function J(t,e){return t*e}function K(t,e,n){return t?t=>H(t,e):t=>J(t,n)}function Q(t,e,n){const{numVerticesPerSide:o,vertexAttributes:s,maxEdgeVertexCount:r}=t,i=o-1,a=s.count,l=2*(o-3)*(o-3),u=4*(i+r-3),d=c.reduce((e,n)=>e+(i+t.getEdgeCount(n)-3),0),f=e.reduce((t,e)=>t+i*(2*(e.latitudeResolution-1)+1),0),m=3*(n?2:1),g=(l+u+f)*m,h=a>=y?new Uint32Array(g):new Uint16Array(g);for(let c=0;c<g;++c)h[c]=0;t.indices=h,t.indexCount=(l+d+f)*m,t.poleIndicesStartIndex=l*m,t.edgeIndicesStartIndex=(l+f)*m,n?($(t),_(t,e),tt(t)):(X(t),Y(t,e),Z(t))}function X(t){const{numVerticesPerSide:e,indices:n,vertexAttributes:o}=t,{position:s}=o,{typedBuffer:r,typedBufferStride:i}=s,a=e-2,c=e-3,l=0,u=e-3;let d=0;for(let f=0;f<c;++f){const t=f*a;for(let e=l;e<u;++e){const o=t+e,s=o+1,c=s+a,l=c-1;It(o,s,c,l,i,r)?(n[d]=o,n[d+1]=s,n[d+2]=c,n[d+3]=c,n[d+4]=l,n[d+5]=o):(n[d]=o,n[d+1]=s,n[d+2]=l,n[d+3]=l,n[d+4]=s,n[d+5]=c),d+=6}}}function Y(t,e){const{numVerticesPerSide:n,indices:o,poleIndicesStartIndex:s}=t,r=n-1;let i=s;for(const a of e){const e=a.isNorth?1:2,s=a.isNorth?2:1,c=a.isNorth?3:4,l=a.isNorth?4:3;let u=t.getEdgeVertexIndex(a.connectedOuterEdgeOffset,0),d=1;for(let t=0;t<a.latitudeResolution;++t){const f=0===t?a.rowOffset:u+n;for(let n=0;n<r;n++){const r=f+n;o[i]=u,o[i+e]=u+1,o[i+s]=r,t<a.latitudeResolution-1?(o[i+c]=u+1,o[i+l]=r+1,o[i+5]=r,i+=6):i+=3,u+=d}u=f,d=1}}}function Z(t){const{indices:e,numVerticesPerSide:n,edgeIndicesStartIndex:o}=t,s=n-1,r=s-2;let i=o;for(let a=0;a<4;++a){const n=vt[a];let o=0,c=0;const l=t.getEdgeCount(a),u=n.count;f(u===s-1);const d=1===a||2===a,m=d?1:2,g=d?2:1,h=t.getEdgeFirstVertexIndex(a),p=1,x=n.vertex0Index,M=n.stride;for(;o<l-1||c<u-1;){const t=x+c*M,n=h+o*p,a=o<l-1,d=c<u-1,f=a&&(!d||(a?0+s*(o+.5)/(l-1):0)<=(d?1+r*(c+.5)/(u-1):0));f?++o:++c;const y=f?n+p:t+M;e[i]=t,e[i+m]=n,e[i+g]=y,i+=3}}t.indexCount=i}function $(t){const{indices:e,numVerticesPerSide:n,vertexAttributes:o}=t,{position:s}=o,{typedBuffer:r,typedBufferStride:i}=s,a=n-2;let c=0;for(let l=0;l<n-3;++l){const t=l*a;for(let o=0;o<n-3;++o){const n=l*a+o,s=n+1,u=s+a,d=u-1,f=t+o,m=f+1,g=m+a;It(f,m,g,g-1,i,r)?(bt(e,c,n,s,u),c+=6,bt(e,c,u,d,n)):(bt(e,c,n,s,d),c+=6,bt(e,c,d,u,s)),c+=6}}}function _(t,e){const{indices:n,numVerticesPerSide:o,poleIndicesStartIndex:s}=t,r=o-1;let i=s;for(const a of e){const e=a.connectedOuterEdgeOffset;let s=t.getEdgeVertexIndex(e,0),c=1;for(let t=0;t<a.latitudeResolution;++t){const e=0===t?a.rowOffset:s+o;for(let o=0;o<r;o++)bt(n,i,s,s+1,e+o),i+=6,t<a.latitudeResolution-1&&(bt(n,i,s+1,e+o+1,e+o),i+=6),s+=c;s=e,c=1}}}function tt(t){const{indices:e,numVerticesPerSide:n,edgeIndicesStartIndex:o}=t,s=n-1,r=s-2;let i=o;for(let a=0;a<4;++a){const n=vt[a];let o=0,c=0;const l=t.getEdgeCount(a),u=n.count;f(u===s-1);const d=1===a||2===a,m=d?1:3,g=d?3:1,h=t.getEdgeFirstVertexIndex(a),p=1,x=n.vertex0Index,M=n.stride;for(;o<l-1||c<u-1;){const t=x+c*M,n=h+o*p,a=o<l-1,d=c<u-1,f=a&&(!d||(a?0+s*(o+.5)/(l-1):0)<=(d?1+r*(c+.5)/(u-1):0));f?++o:++c;const y=f?n+p:t+M;e[i]=t,e[i+m]=n,e[i+m+1]=n,e[i+g]=y,e[i+g+1]=y,e[i+5]=t,i+=6}}t.indexCount=i}function et(t){const{geometry:e,geometryState:n}=t,{edgeResolutions:o}=n,{numVerticesPerSide:s,edgeVerticesStartIndex:r}=e,i=s-2;let a=r;for(let c=0;c<4;++c){{const t=0===c||2===c,e=(0===c?i-1:0)*i+(1===c?i-1:0),n=(t?0:1)*i+(t?1:0),o=vt[c];o.vertex0Index=e,o.stride=n,o.count=i}{const t=o[c]+1;e.outerEdgesOffsetAndLength[2*c+0]=a,e.outerEdgesOffsetAndLength[2*c+1]=t,a+=t}}}function nt(t){et(t),t.geometryState.wireframe?tt(t.geometry):Z(t.geometry)}function ot(o,s,r){const{geometryState:i,geometry:a,tile:c,localOrigin:l}=o,u=1===s||3===s,d=i.edgeResolutions[s];f(e(d));const m=d+1,{boundingBox:g,minu:h,minv:p,maxu:x,maxv:M,vertexAttributes:y}=a,S=t(1===s?1:0,h,x),L=t(0===s?1:0,p,M),v=r.renderData,B=v.geometryState,V=v.geometry,I=(s+2)%4,b=V.getEdgeCount(I),C=c.getNeighborEdgeStartVertexIndex(s,r)*d,T=d*2**(c.level-r.level);f(B.edgeResolutions[I]===T),f(b-1===T);const U=v.localOrigin[0]-l[0],A=v.localOrigin[1]-l[1],P=v.localOrigin[2]-l[2],D=a.getEdgeFirstVertexIndex(s),{position:E,uv0:w}=y,O=E.typedBuffer,R=E.typedBufferStride,N=y.normalCompressed,j=N.typedBuffer,F=N.typedBufferStride,q=V.vertexAttributes,W=V.getEdgeFirstVertexIndex(I),k=q.position.typedBuffer,z=q.position.typedBufferStride,G=q.normalCompressed.typedBuffer,H=q.normalCompressed.typedBufferStride;for(let e=1;e<m-1;++e){const o=D+e,s=W+(C+e),r=o*R,i=s*z,a=k[i]+U,c=k[i+1]+A,l=k[i+2]+P;O[r]=a,O[r+1]=c,O[r+2]=l,Bt(a,c,l,g);const f=o*F,m=s*H;j[f]=G[m],j[f+1]=G[m+1];const y=e/d,v=u?S:t(y,h,x),B=u?t(y,p,M):L;w.setValues(o,Math.round(v*n),Math.round(B*n))}}function st(e){const{geometry:o,geometryState:s,localOrigin:i}=e,{clippingArea:a,samplerData:c}=s,{minu:l,minv:u,maxu:d,maxv:m,boundingBox:g,vertexAttributes:h}=o,p=e.tile,{surface:M,ellipsoid:y,extent:S,extentInRadians:L,horizontalScale:v}=p,B="local"===M.view?.viewingMode,V=y.radius;let I=0,b=0,C=0;const T=(t,e,n)=>{const o=L[0===e?1:3],s=L[0===t?0:2],r=Math.cos(o),i=Math.sin(o),a=Math.sin(s),c=Math.cos(s),l=V+n;I=c*r*l,b=a*r*l,C=i*l},U=B?(()=>{const e=a,n=null!=e&&(S[3]>e[3]||S[2]>e[2]||S[1]<e[1]||S[0]<e[0]),o=K(M.isWebMercatorOnPlateCarree,V,v);return(s,r,i)=>{const a=0===s?S[0]:S[2],c=0===r?S[1]:S[3],l=n?t(a,e[0],e[2]):a,u=n?t(c,e[1],e[3]):c,d=i;I=l*v,b=o(u),C=d}})():T;let A=0,P=0,D=0,E=0,w=0,O=0,N=0,j=0,F=0;const q=B&&M.isWebMercatorOnPlateCarree,W=(t,e,n,o,s)=>{let r=0,i=0,a=0;if(B){const t=e*v,s=q?(Math.PI/2-2*Math.atan(Math.exp(-n/V)))*V:n*v;r=t-I,i=s-b,a=o-C}else{const s=R(t),c=t.tile,l=c.extent,u=c.extentInRadians,d=(e-l[0])/(l[2]-l[0]),f=(n-l[1])/(l[3]-l[1]),m=u[0]*(1-d)+u[2]*d,g=s(f),h=Math.cos(g),p=Math.sin(g),x=Math.sin(m),M=Math.cos(m),y=V+o;r=M*h*y-I,i=x*h*y-b,a=p*y-C}switch(s){case 0:N+=r,j+=i,F+=a;break;case 1:E-=r,w-=i,O-=a;break;case 2:N-=r,j-=i,F-=a;break;case 3:E+=r,w+=i,O+=a}},k=a??Mt,z=S[0],G=S[2],H=S[1],J=S[3],Q=[J>k[3],G>k[2],H<k[1],z<k[0]],X=Math.max(z,k[0]),Y=Math.min(G,k[2]),Z=Math.max(H,k[1]),$=Math.min(J,k[3]),_=t=>Math.max(k[0],Math.min(k[2],t)),tt=t=>Math.max(k[1],Math.min(k[3],t)),et=t=>{const e=s.cornerNeighborCornerTiles;A=0,P=0,D=1,E=0,w=0,O=0,N=0,j=0,F=0;let n=1/0;for(let s=0;s<4;++s){const o=e[4*t+s];n=Math.min(n,o?.level??1/0)}for(let s=0;s<4;++s){const o=e[4*t+s];yt[s]=o?.level===n?o:null}let o=1,i=0;for(let s=0;s<4;++s){const t=yt[s];t&&(o=Math.max(o,t?.renderData.geometryState.numVerticesPerSide),i=t.extent[2]-t.extent[0])}const a=i,c=o;f(c>1);const l=a/c;for(let s=0;s<4;++s){const t=yt[(s+3)%4],e=yt[s%4];if(!t&&!e)continue;const n=0===s?1:1===s?2:2===s?3:0,o=0===s?2:1===s?3:2===s?0:1;if(t&&e){const i=lt[s][0]*l,a=lt[s][1]*l,c=t.extent,u=_(c[0===n||1===n?2:0]+i),d=tt(c[0===n||3===n?3:1]+a),f=e.extent,m=_(f[0===o||1===o?2:0]+i),g=tt(f[0===o||3===o?3:1]+a),h=t.renderData,p=e.renderData,x=r(u,d,h.geometryState.samplerData),M=r(m,g,p.geometryState.samplerData);W(h,u,d,.5*(x+M),s)}else{const i=t??e,a=t?n:o,c=i.extent,u=lt[s],d=_(c[0===a||1===a?2:0]+u[0]*l),f=tt(c[0===a||3===a?3:1]+u[1]*l),m=i.renderData,g=r(d,f,m.geometryState.samplerData);W(m,d,f,g,s)}}if(!B){const t=Math.sqrt(I*I+b*b+C*C);A=I/t,P=b/t,D=C/t}if(B||D*D<.999){const t=Math.sqrt(E*E+w*w+O*O);E/=t,w/=t,O/=t;const e=Math.sqrt(N*N+j*j+F*F);N/=e,j/=e,F/=e,A=O*j-w*F,P=E*F-O*N,D=w*N-E*j;const n=1/Math.sqrt(A*A+P*P+D*D);A*=n,P*=n,D*=n}},nt=s.cornerNeighborCornerTiles;for(let R=0;R<4;++R){const e=R,a=(R+1)%4,M=0===R||1===R?1:0,y=0===R||3===R?1:0,S=t(M,l,d),L=t(y,u,m),v=o.getEdgeFirstVertexIndex(e),B=o.getEdgeCount(e),V=0===R||3===R?B-1:0,T=o.getEdgeFirstVertexIndex(a),E=o.getEdgeCount(a),w=0===R||1===R?E-1:0;let O=-1;for(let t=0;t<4;++t){const e=nt[4*R+t],n=nt[4*R+O];e&&(-1===O||x(n,e)>0)&&(O=t)}const N=O,j=nt[4*R+N];if(j!==p){const t=p.level-j.level,e=2**t,o=[j.lij[0]+t,j.lij[1]*e,j.lij[2]*e],r=[o[1]+e===p.lij[1],0===R&&(1===N||0===N&&j!==nt[4*R+3])||1===R&&(0===N||1===N&&j!==nt[4*R+2]),o[1]===p.lij[1]+1,2===R&&(3===N||2===N&&j!==nt[4*R+1])||3===R&&(2===N||3===N&&j!==nt[4*R+0])],a=r.reduce((t,e)=>t+(e?1:0),0);f(1===a||2===a);let c=-1,l=-1;const u=j.renderData;if(1===a){const t=r.findIndex(t=>t);f(0<=t&&t<=3),c=(t+2)%4;const e=s.edgeResolutions[t];l=p.getNeighborEdgeStartVertexIndex(t,j)*e+e*(0===t&&0===R||1===t&&0===R||2===t&&1===R||3===t&&3===R?1:0)}else{f(r[1]||r[3]),c=r[1]?3:1;const t=u.geometryState.edgeResolutions[c];l=0===R||3===R?0:t}const d=u.geometry;{const t=v+V,e=T+w,o=d.getEdgeFirstVertexIndex(c)+l,s=d.vertexAttributes,r=u.localOrigin,a=s.position,f=a.typedBuffer,m=o*a.typedBufferStride,p=f[m]+r[0]-i[0],x=f[m+1]+r[1]-i[1],M=f[m+2]+r[2]-i[2];Bt(p,x,M,g);const y=h.position,B=y.typedBuffer,I=t*y.typedBufferStride;B[I]=p,B[I+1]=x,B[I+2]=M;const b=e*y.typedBufferStride;B[b]=p,B[b+1]=x,B[b+2]=M;const C=h.uv0;C.setValues(t,Math.round(S*n),Math.round(L*n)),C.setValues(e,Math.round(S*n),Math.round(L*n));{const n=s.normalCompressed.typedBuffer,r=o*s.normalCompressed.typedBufferStride,i=h.normalCompressed,a=i.typedBuffer;{const e=t*i.typedBufferStride;a[e]=n[r],a[e+1]=n[r+1]}{const t=e*i.typedBufferStride;a[t]=n[r],a[t+1]=n[r+1]}}}}else{const n=Q[e],s=Q[a];let l;if(n||s){const e=t(z*(1-M)+G*M,X,Y),n=t(H*(1-y)+J*y,Z,$);l=r(e,n,c)}else l=rt(nt,R);U(M,y,l),et(R);const u=I-i[0],d=b-i[1],f=C-i[2];Bt(u,d,f,g),o.setEdgeVertexFromValuesRawPositionUVNormal(e,V,u,d,f,S,L,A,P,D),o.setEdgeVertexFromValuesRawPositionUVNormal(a,w,u,d,f,S,L,A,P,D)}}for(let t=0;t<4;++t)yt[t]=null}function rt(t,e){const n=4*e,o=c.reduce((e,o)=>Math.min(e,t[n+o]?.level??1/0),1/0);m&&(f(!t[n+0]||!t[n+2]||p(t[n+0],t[n+2],5)),f(!t[n+1]||!t[n+3]||p(t[n+1],t[n+3],7)));let s=0,i=0;for(let c=0;c<4;++c){const e=t[n+c];if(e?.level===o){const t=0===c||1===c,n=0===c||3===c,o=e.extent,a=o[t?0:2],l=o[n?1:3],u=e.renderData?.geometryState?.samplerData;i+=r(a,l,u),s++}}const a=s?i/s:0;return f(null!=a),a}function it(t){const{vao:e,geometry:n}=t,{vertexAttributes:o,edgeVerticesStartIndex:s}=n,r=o.position.typedBuffer;e.buffer()?.setSubData(r,s,s,r.length)}function at(t){const{vao:e,geometry:n}=t,{indices:o,indexCount:s,edgeIndicesStartIndex:r}=n;e.indexBuffer.setSubData(o,r,r,s)}class ct{constructor(t,e,n,o,s){this.isNorth=t,this.connectedRowOffset=e,this.connectedOuterEdgeOffset=n,this.rowOffset=o,this.latitudeResolution=s}}const lt=[[0,1],[1,0],[0,-1],[-1,0]],ut=new a,dt=.5*d,ft=new Uint16Array(u+1),mt=new Int32Array(u+1),gt=new Int32Array(u+1),ht=new Int32Array(u+1),pt=new Float64Array(u+1),xt=new Float64Array(u+1),Mt=s(-1/0,-1/0,1/0,1/0),yt=[null,null,null,null];function St(t,e,n){if(!e)return!1;const o=x(t,e);return o>0||0===o&&n>=2}class Lt{constructor(){this.vertex0Index=0,this.stride=1,this.count=0}getVertexIndex(t){return f(0<=t&&t<this.count),this.vertex0Index+this.stride*t}}const vt=[new Lt,new Lt,new Lt,new Lt];function Bt(t,e,n,o){t<o[0]?o[0]=t:t>o[3]&&(o[3]=t),e<o[1]?o[1]=e:e>o[4]&&(o[4]=e),n<o[2]?o[2]=n:n>o[5]&&(o[5]=n)}function Vt(t){const{edgeResolutions:e,numVerticesPerSide:n}=t,o=1+Math.max(...e);return Math.max(n,o)}function It(t,e,n,o,s,r){const i=t*s,a=r[i],c=r[i+1],l=r[i+2],u=e*s,d=r[u],f=r[u+1],m=r[u+2],g=n*s,h=r[g],p=r[g+1],x=r[g+2],M=o*s,y=r[M],S=r[M+1],L=r[M+2];return(d-y)*(d-y)+(f-S)*(f-S)+(m-L)*(m-L)>(a-h)*(a-h)+(c-p)*(c-p)+(l-x)*(l-x)}function bt(t,e,n,o,s){t[e]=n,t[e+1]=o,t[e+2]=o,t[e+3]=s,t[e+4]=s,t[e+5]=n}const Ct=6;export{N as createPlanarGlobePatch,S as createSphericalGlobePatch,U as updateCornerSpherical,F as updateCornersPlanar,q as updateEdgeElevationsAndResolutionsPlanar,T as updateEdgeElevationsAndResolutionsSpherical,W as updateEdgesAndCornersPlanar,C as updateEdgesAndCornersSpherical};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
class t{constructor(t,a,e,r){this._material=t,this._drawParameters=a,this.geometry=e,this.meta=r}get material(){return this._material}destroy(){this._material.destroy(),this._drawParameters.destroy(),this.geometry.destroy()}get drawParameters(){return this._drawParameters}updateMaterial(t){this._material=t}get opacity(){return this.drawParameters.opacity}updateOpacity(t){
|
|
2
|
+
class t{constructor(t,a,e,r){this._material=t,this._drawParameters=a,this.geometry=e,this.meta=r}get material(){return this._material}destroy(){this._material.destroy(),this._drawParameters.destroy(),this.geometry.destroy()}get drawParameters(){return this._drawParameters}updateMaterial(t){this._material=t}get opacity(){return this.drawParameters.opacity}updateOpacity(t){this._drawParameters.opacity=t}updateComponentParametersUniform(t){this._drawParameters.updateComponentParameters(t,null)}updateComponentParametersVarying(t,a){this._drawParameters.updateComponentParameters(t,a)}}class a{constructor(t){this.gpuMemoryEstimate=t,this.cameraDepthSquared=.5}}export{t as Renderable,a as RenderableMeta};
|
|
@@ -1,6 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{isColor as e}from"../ShaderOutput.js";import{VertexTextureCoordinates as r}from"../attributes/VertexTextureCoordinates.glsl.js";import{glsl as
|
|
3
|
-
vec4 readBaseColorTexture() {
|
|
4
|
-
return ${s?"textureLookup(baseColorTexture, vuv0)":"vec4(1.0)"};
|
|
5
|
-
}
|
|
6
|
-
`)}export{u as ReadBaseColorTexture};
|
|
2
|
+
import{isColor as e}from"../ShaderOutput.js";import{VertexTextureCoordinates as r}from"../attributes/VertexTextureCoordinates.glsl.js";import{glsl as o}from"../../shaderModules/glsl.js";import{Texture2DDrawUniform as t}from"../../shaderModules/Texture2DDrawUniform.js";function u(u,a){a.hasColorTexture&&(e(a.output)||1!==a.alphaDiscardMode)?(u.include(r,a),u.fragment.uniforms.add(new t("baseColorTexture",e=>e.texture,e=>e.textureSampler)).code.add(o`vec4 readBaseColorTexture() { return textureLookup(baseColorTexture, vuv0); }`)):u.fragment.code.add(o`vec4 readBaseColorTexture() { return vec4(1.0); }`)}export{u as ReadBaseColorTexture};
|
|
@@ -1,6 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{FloatDrawUniform as
|
|
3
|
-
void discardOrAdjustAlpha(inout vec4 color) {
|
|
4
|
-
${1===l?"color.a = 1.0;":`if (color.a < ${u?r.float(a):"textureAlphaCutoff"}) {\n discard;\n } ${e(2===l,"else { color.a = 1.0; }")}`}
|
|
5
|
-
}
|
|
6
|
-
`)}export{s as DiscardOrAdjustAlphaDraw,f as DiscardOrAdjustAlphaPass};
|
|
2
|
+
import{FloatDrawUniform as a}from"../../shaderModules/FloatDrawUniform.js";import{FloatPassUniform as o}from"../../shaderModules/FloatPassUniform.js";import{alphaCutoff as d}from"../../../shaders/alphaCutoff.glsl.js";function e(a,d){t(a,d,new o("textureAlphaCutoff",a=>a.textureAlphaCutoff))}function r(o,d){t(o,d,new a("textureAlphaCutoff",a=>a.textureAlphaCutoff))}function t(a,o,e){const r=a.fragment;switch(r.code.add("void discardOrAdjustAlpha(inout vec4 color) {"),o.alphaDiscardMode){case 1:r.code.add("color.a = 1.0;");break;case 0:r.include(d),r.code.add("if (color.a < alphaCutoff) discard;");break;case 3:r.uniforms.add(e).code.add("if (color.a < textureAlphaCutoff) discard;");break;case 2:r.uniforms.add(e).code.add("\n if (color.a < textureAlphaCutoff) discard;\n color.a = 1.0;\n ");break;case 4:break;default:o.alphaDiscardMode}r.code.add("}")}export{r as DiscardOrAdjustAlphaDraw,e as DiscardOrAdjustAlphaPass};
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{ColorConversion as
|
|
2
|
+
import{ColorConversion as t}from"./ColorConversion.glsl.js";import{glsl as e}from"../../shaderModules/glsl.js";function n(n){n.include(t),n.code.add(e`
|
|
3
3
|
vec3 mixExternalColor(vec3 internalColor, vec3 textureColor, vec3 externalColor, int mode) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
vec3 internalMixed = internalColor * textureColor;
|
|
7
|
-
vec3 allMixed = internalMixed * externalColor;
|
|
8
|
-
|
|
9
|
-
if (mode == ${t.int(1)}) {
|
|
10
|
-
return allMixed;
|
|
4
|
+
if (mode == ${e.int(3)}) {
|
|
5
|
+
return externalColor;
|
|
11
6
|
}
|
|
12
|
-
|
|
7
|
+
|
|
8
|
+
vec3 internalMixed = internalColor * textureColor;
|
|
9
|
+
if (mode == ${e.int(2)}) {
|
|
13
10
|
return internalMixed;
|
|
14
11
|
}
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
|
|
13
|
+
if (mode == ${e.int(1)}) {
|
|
14
|
+
return internalMixed * externalColor;
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
// tint (or something invalid)
|
|
@@ -24,19 +22,16 @@ import{ColorConversion as e}from"./ColorConversion.glsl.js";import{glsl as t}fro
|
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
float mixExternalOpacity(float internalOpacity, float textureOpacity, float externalOpacity, int mode) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
float allMixed = internalMixed * externalOpacity;
|
|
25
|
+
if (mode == ${e.int(3)}) {
|
|
26
|
+
return externalOpacity;
|
|
27
|
+
}
|
|
31
28
|
|
|
32
|
-
|
|
29
|
+
float internalMixed = internalOpacity * textureOpacity;
|
|
30
|
+
if (mode == ${e.int(2)}) {
|
|
33
31
|
return internalMixed;
|
|
34
32
|
}
|
|
35
|
-
if (mode == ${t.int(3)}) {
|
|
36
|
-
return externalOpacity;
|
|
37
|
-
}
|
|
38
33
|
|
|
39
34
|
// multiply or tint (or something invalid)
|
|
40
|
-
return
|
|
35
|
+
return internalMixed * externalOpacity;
|
|
41
36
|
}
|
|
42
|
-
`)}export{
|
|
37
|
+
`)}export{n as MixExternalColor};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import"../../../../../core/has.js";import{releaseMaybe as t,disposeMaybe as
|
|
2
|
+
import{__decorate as e}from"tslib";import"../../../../../core/has.js";import{releaseMaybe as t,disposeMaybe as r}from"../../../../../core/maybe.js";import{watch as i,initial as s}from"../../../../../core/reactiveUtils.js";import{property as o,subclass as h}from"../../../../../core/accessorSupport/decorators.js";import{set as n}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{InternalRenderCategory as l}from"../../../webgl.js";import a from"../../../webgl/RenderNode.js";import{HighlightApplyTechnique as g}from"./HighlightApplyTechnique.js";import{H as c}from"../../../../../chunks/HighlightBlur.glsl.js";import{HighlightBlurTechnique as u}from"./HighlightBlurTechnique.js";import{H as m,g as p}from"../../../../../chunks/HighlightDownsample.glsl.js";import{HighlightDownsampleTechnique as d}from"./HighlightDownsampleTechnique.js";import{HighlightPassParameters as f}from"./HighlightPassParameters.js";import{HighlightToSingleTechnique as b}from"./HighlightToSingleTechnique.js";import{NoVertex as w}from"../../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as x}from"../../lib/VertexArrayObject.js";import{BufferObject as T}from"../../../../webgl/BufferObject.js";import{ColorAttachment0 as C,PrimitiveType as _,DataType as v}from"../../../../webgl/enums.js";import O from"../../../../webgl/Texture.js";import{TextureDescriptor as j}from"../../../../webgl/TextureDescriptor.js";import{VertexBuffer as H}from"../../../../webgl/VertexBuffer.js";let q=class extends a{constructor(){super(...arguments),this.produces=l.HIGHLIGHT_COLOR,this.consumes={required:[l.HIGHLIGHT_COLOR,"highlights"]},this._downsampleDrawParameters=new m,this._passParameters=new f,this._highlightBlurDrawParameters=new c,this._grid=new P}initialize(){this.addHandles([i(()=>this._updateOptionsTexture(),()=>{},s)])}destroy(){this._grid.coverage=t(this._grid.coverage),this._grid.vao=r(this._grid.vao),this._passParameters.highlightOptionsTexture=t(this._passParameters.highlightOptionsTexture)}_updateOptionsTexture(){if(null==this._passParameters.highlightOptionsTexture){const e=new j(16,2);e.internalFormat=6408,e.samplingMode=9728,this._passParameters.highlightOptionsTexture=new O(this.renderingContext,e,null)}this._passParameters.highlightOptionsTexture.setData(D(this.view.state.highlights)),this.requestRender(1)}precompile(){this.bindParameters.decorations&&(this.techniques.precompile(d),this.techniques.precompile(b),this.techniques.precompile(u),this.techniques.precompile(g))}render(e){const t=e.find(({name:e})=>e===l.HIGHLIGHT_COLOR),{techniques:r,bindParameters:i,fboCache:s,_passParameters:o,renderingContext:h}=this;if(!i.decorations)return t;const a=r.getCompiled(d),c=r.getCompiled(b),m=r.getCompiled(u),p=r.getCompiled(g);if(!(a&&p&&m&&c))return this.requestRender(1),t;const f=e.find(({name:e})=>"highlights"===e).getTexture();o.highlightTexture=f;const w=this._prepareAndDownSample(f),{width:x,height:T}=f.descriptor;o.highlightTexture=f;const{camera:_}=i,{fullWidth:v,fullHeight:O,pixelRatio:j,fullViewport:H}=_,q=Math.ceil(v/j),P=Math.ceil(O/j),{_highlightBlurDrawParameters:D}=this,y=this.view.stage.renderView.renderer,{highlights:I}=i;for(let l=0;l<I.length;++l){const{name:e}=I[l];if(!y.hasHighlight(e))continue;o.highlightLevel=l,h.setClearColor(0,0,0,0);const r=s.acquire(x,T,"single highlight",2);h.bindFramebuffer(r.fbo),h.setViewport(0,0,x,T),h.clear(16384),h.bindTechnique(c,i,o),this._renderGrid(w),D.blurInput=r.getTexture(),n(D.blurSize,1/q,0);const a=s.acquire(q,P,"single highlight blur",2);h.unbindTexture(a.fbo?.colorTexture),h.bindFramebuffer(a.fbo),h.setViewport(0,0,q,P),h.clear(16384),h.bindTechnique(m,i,o,D),this._renderGrid(w),r.release(),n(D.blurSize,0,1/P),o.highlightBlurTexture=a.getTexture(),h.bindFramebuffer(t.fbo),h.setDrawBuffers([C]),h.setViewport4fv(H),h.bindTechnique(p,i,o,D),this._renderGrid(w),a.release()}return o.coverageTexture=o.highlightTexture=null,t}_prepareAndDownSample(e){this._gridUpdateResources(e);const t=this.techniques.get(d),r=this._gridComputeCoverage(t,e),{horizontalCellCount:i,verticalCellCount:s}=r,o=this._passParameters;return o.horizontalCellCount=i,o.verticalCellCount=s,o.coverageTexture=r.coverage?.getTexture(),r}_renderGrid(e){const t=e.verticalCellCount*e.horizontalCellCount;this.renderingContext.bindVAO(e.vao),this.renderingContext.drawElementsInstanced(_.TRIANGLES,6,v.UNSIGNED_BYTE,0,t)}_gridUpdateResources(e){const t=this._grid,{width:r,height:i}=e.descriptor;if(t.horizontalCellCount=Math.ceil(r/p),t.verticalCellCount=Math.ceil(i/p),t.vao)return;const s=this.renderingContext,o=T.createIndex(s,35044,R);t.vao=new x(s,new H(s,w),o)}_gridComputeCoverage(e,t){const r=this.renderingContext,i=this._grid,s=t.descriptor,o=Math.ceil(s.width/p),h=Math.ceil(s.height/p);this._downsampleDrawParameters.input=t;const{highlights:n}=this.bindParameters;i.coverage?.release();const l=this.fboCache.acquire(o,h,"highlight coverage",n.length>L?3:1);return i.coverage=l,r.bindFramebuffer(l.fbo),r.bindTechnique(e,this.bindParameters,this._passParameters,this._downsampleDrawParameters),r.setViewport(0,0,o,h),r.screen.draw(),i}get test(){}};e([o()],q.prototype,"produces",void 0),e([o()],q.prototype,"consumes",void 0),q=e([h("esri.views.3d.webgl-engine.effects.highlight.Highlight")],q);class P{constructor(){this.coverage=null,this.vao=null,this.verticalCellCount=0,this.horizontalCellCount=0,this.viewportWidth=0,this.viewportHeight=0}}function D(e){const t=new Uint8Array(128);let r=0;for(const i of e){const e=4*r,s=4*r+64;++r;const{color:o}=i,h=i.haloColor??o;t[e+0]=o.r,t[e+1]=o.g,t[e+2]=o.b,t[e+3]=i.fillOpacity*o.a*255,t[s+0]=h.r,t[s+1]=h.g,t[s+2]=h.b,t[s+3]=i.haloOpacity*h.a*255}return t}let y=0;function I(e){let t=0;for(const i of e){const{name:e}=i;t+=e.length;const{color:r,fillOpacity:s,haloColor:o,haloOpacity:h}=i;t+=r.r+r.g+r.b+r.a+s,t+=o?o.r+o.g+o.b+o.a+h:0}const r=e.at(0);if(r){const{shadowOpacity:e,shadowDifference:i,shadowColor:s}=r;t+=e+i+s.r+s.g+s.b+s.a}return y+++(t>=0?0:1)}const R=new Uint8Array([0,1,2,2,1,3]);function G(e,t,r,i,s,o,h=0){const{highlights:l}=s,a=l.length>1?t.acquire(r,i,"highlight mix",l.length>L?3:1):null,{gl:g}=e;if(a){const t=e.boundFramebuffer;e.bindFramebuffer(a.fbo),g.clearBufferuiv(g.COLOR,0,[0,0,0,0]),e.bindFramebuffer(t)}const c=a?.getTexture();s.highlightMixTexture=c,n(s.highlightMixOrigin,h,0),l.forEach((t,n)=>{if(n>0){const t=O.TEXTURE_UNIT_FOR_UPDATES;e.bindTexture(c,t),e.setActiveTexture(t),g.copyTexSubImage2D(3553,0,0,0,h,0,r,i),e.bindTexture(null,t)}e.clear(256),s.highlightLevel=n,o()}),s.highlightLevel=null,s.highlightMixTexture=null,a?.release()}const L=4;export{q as Highlight,L as maxHighlightsPerChannel,G as renderHighlightBuffer,I as trackHighlightOptions};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{smoothstep as t,clamp as
|
|
2
|
+
import{__decorate as e}from"tslib";import{smoothstep as t,clamp as s}from"../../../../../core/mathUtils.js";import{watch as i,syncAndInitial as r}from"../../../../../core/reactiveUtils.js";import{property as a,subclass as h}from"../../../../../core/accessorSupport/decorators.js";import{normalize as o,set as c,dot as n}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as p}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{RenderNodeOutput as d}from"../../../webgl.js";import m from"../../../webgl/RenderNode.js";import{ShadowHighlightPassParameters as l,ShadowHighlightTechnique as u}from"./ShadowHighlightTechnique.js";import{defaultShadowOpacity as g,defaultShadowDifference as f,defaultShadowColor as w}from"../../../../support/HighlightDefaults.js";import{ColorAttachment0 as _}from"../../../../webgl/enums.js";const O=1/512,y=4e4,P=5e4;let b=class extends m{constructor(e){super(e),this.produces=d.COMPOSITE,this.consumes={required:[d.COMPOSITE,"highlights"]},this._passParameters=new l,this._maxOpacity=1,this._shadowDifference=.2}initialize(){this.addHandles([i(()=>this.view.defaultHighlight?.shadowOpacity,e=>{this._passParameters.shadowOpacity=e??g,this._updateOccludedShadowOpacity(),this._ensureMaxOpacity()},r),i(()=>this.view.defaultHighlight?.shadowDifference,e=>{this._shadowDifference=e??f,this._updateOccludedShadowOpacity(),this._ensureMaxOpacity()},r),i(()=>this.view.defaultHighlight?.shadowColor,e=>{this._passParameters.shadowColor=(e??w).toUnitRGBA(),this._ensureMaxOpacity()},r)])}_updateOccludedShadowOpacity(){this._passParameters.occludedShadowOpacity=this._passParameters.shadowOpacity*(1-this._shadowDifference)}_ensureMaxOpacity(){const e=Math.max(this._passParameters.shadowOpacity,this._passParameters.occludedShadowOpacity);this._maxOpacity=e*this._passParameters.shadowColor[3],this.requestRender(1)}precompile(){this._ensureIfVisible()&&this.techniques.precompile(u)}render(e){const t=e.find(({name:e})=>e===d.COMPOSITE),s=this.bindParameters;if(!this._ensureIfVisible())return t;const i=this.techniques.getCompiled(u);if(!i)return this.requestRender(1),t;this._passParameters.highlightTexture=e.find(({name:e})=>"highlights"===e)?.getTexture(),this._passParameters.origin=s.camera.center;const r=this.renderingContext,a=t.obtainDepthTexture();return r.bindFramebuffer(t.fbo),r.setDrawBuffers([_]),r.bindTechnique(i,s,this._passParameters),r.screen.draw(),t.attachDepth(a),a?.release(),t}_ensureIfVisible(){const e=this.bindParameters;if(!e.hasShadowHighlights||!e.mainDepth||!e.shadowHighlight?.getTexture())return!1;const{camera:i,lighting:r}=e;this._passParameters.opacityElevation=1-t(y,P,i.relativeElevation);const a=1===this.viewingMode?o(x,i.center):c(x,0,0,1),h=n(a,r.mainLight.direction);return this._passParameters.dayNightTerminator=t(0,1,s(30*h,0,1)),this._maxOpacity*this._passParameters.opacityElevation*this._passParameters.dayNightTerminator>=O}};e([a()],b.prototype,"produces",void 0),e([a()],b.prototype,"consumes",void 0),e([a({constructOnly:!0})],b.prototype,"viewingMode",void 0),b=e([h("esri.views.3d.webgl-engine.effects.highlight.ShadowHighlight")],b);const x=p();export{b as ShadowHighlight};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{createTask as s}from"../../../../../core/asyncUtils.js";import{clamp as i}from"../../../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../../../core/maybe.js";import{watch as t,syncAndInitial as a}from"../../../../../core/reactiveUtils.js";import{createScreenPointArray as o,createRenderScreenPointArray as m,screenPointObjectToArray as n}from"../../../../../core/screenUtils.js";import{isSVG as h}from"../../../../../core/urlUtils.js";import{property as l,subclass as u}from"../../../../../core/accessorSupport/decorators.js";import{requestImage as p}from"../../../../../request/image.js";import{InternalRenderCategory as c}from"../../../webgl.js";import _ from"../../../webgl/RenderNode.js";import{M as g}from"../../../../../chunks/Magnifier.glsl.js";import{MagnifierTechnique as d}from"./MagnifierTechnique.js";import{createQuadVAO as f}from"../../lib/glUtil3D.js";import{loadMagnifierResources as v}from"../../../../magnifier/resources.js";import{PrimitiveType as
|
|
2
|
+
import{__decorate as e}from"tslib";import{createTask as s}from"../../../../../core/asyncUtils.js";import{clamp as i}from"../../../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../../../core/maybe.js";import{watch as t,syncAndInitial as a}from"../../../../../core/reactiveUtils.js";import{createScreenPointArray as o,createRenderScreenPointArray as m,screenPointObjectToArray as n}from"../../../../../core/screenUtils.js";import{isSVG as h}from"../../../../../core/urlUtils.js";import{property as l,subclass as u}from"../../../../../core/accessorSupport/decorators.js";import{requestImage as p}from"../../../../../request/image.js";import{InternalRenderCategory as c}from"../../../webgl.js";import _ from"../../../webgl/RenderNode.js";import{M as g}from"../../../../../chunks/Magnifier.glsl.js";import{MagnifierTechnique as d}from"./MagnifierTechnique.js";import{createQuadVAO as f}from"../../lib/glUtil3D.js";import{loadMagnifierResources as v}from"../../../../magnifier/resources.js";import{ColorAttachment0 as T,PrimitiveType as k}from"../../../../webgl/enums.js";import P from"../../../../webgl/Texture.js";import{TextureDescriptor as y}from"../../../../webgl/TextureDescriptor.js";let x=class extends _{constructor(){super(...arguments),this.produces=c.MAGNIFIER,this.consumes={required:[c.MAGNIFIER]},this._imageSources=null,this._imageLoadTask=null,this._passParameters=new g,this._magnifier=null,this._tmpScreenPoint=o(),this._tmpRenderPoint=m()}initialize(){this.addHandles([t(()=>this.view.magnifier,e=>this._update(e),a)])}_update(e){if(e===this._magnifier)return;this.removeAllHandles(),this._magnifier=e;const s=()=>{const e=this._validMagnifier;e?(this._loadResources(e),this.produces=c.MAGNIFIER):this.produces="disabled",this.requestRender()};this._magnifier&&this.addHandles(t(()=>this._magnifier?.version,s)),s()}get _validMagnifier(){return this._magnifier?.visible&&this._magnifier?.position&&this._magnifier?.size>0?this._magnifier:null}get _factor(){return this._magnifier?.factor||1}destroy(){this._magnifier=null,null!=this._imageLoadTask&&(this._imageLoadTask.task.abort(),this._imageLoadTask=null),this._disposeTextures(),this._vao=r(this._vao)}_disposeTextures(){this._passParameters.mask=r(this._passParameters.mask),this._passParameters.overlay=r(this._passParameters.overlay),this._passParameters.input=r(this._passParameters.input)}precompile(){this._imageSources&&this.techniques.precompile(d)}render(e){const s=this._validMagnifier,r=e.find(({name:e})=>e===c.MAGNIFIER);if(null==s)return r;if(null==this._imageSources)return this.requestRender(1),r;const t=this.renderingContext,a=this.camera.pixelRatio,o=Math.ceil(a*s.size);this._vao??=f(t,0,0,1);const m=this.techniques.getCompiled(d);if(this._ensureTextureResources(t,o),!m||!this._passParameters.input)return this.requestRender(1),r;const h=Math.ceil(1/this._factor*o),l=this._passParameters.input;l.resize(h,h),n(s.position,this._tmpScreenPoint);const u=this.camera.screenToRender(this._tmpScreenPoint,this._tmpRenderPoint),p=this.camera.fullWidth,_=this.camera.fullHeight,g=.5*h,v=.5*h;u[0]=i(u[0],g,p-g-1),u[1]=i(u[1],v,_-v-1);const P=Math.floor(u[0]-g),y=Math.floor(u[1]-v);t.bindFramebuffer(r.fbo);return m.program.bindTexture("textureInput",l),t.gl.copyTexImage2D(l.descriptor.target,0,l.descriptor.pixelFormat,P,y,h,h,0),this._passParameters.magnifier=s,t.bindTechnique(m,this.bindParameters,this._passParameters),t.setDrawBuffers([T]),t.bindVAO(this._vao),t.drawArrays(k.TRIANGLE_STRIP,0,4),r}_loadResources(e){const{maskUrl:i,overlayUrl:r}=e;this._imageLoadTask?.maskUrl===i&&this._imageLoadTask?.overlayUrl===r||(this._imageLoadTask?.task.abort(),this._imageLoadTask=this._imageSources=null),this._imageSources||this._imageLoadTask||(this._imageLoadTask={maskUrl:i,overlayUrl:r,task:s(async e=>{const s=null==i||null==r?v(e):null,t=null!=i?p(i,{signal:e}):s.then(e=>e.mask),a=null!=r?p(r,{signal:e}):s.then(e=>e.overlay);this._imageSources={mask:await t,overlay:await a}})})}_ensureTextureResources(e,s){null==this._imageSources||this._passParameters.size===s&&this._passParameters.input&&this._passParameters.mask&&this._passParameters.overlay||(this._disposeTextures(),this._imageSources.overlay.width=this._imageSources.mask.width=s,this._imageSources.overlay.height=this._imageSources.mask.height=s,this._passParameters.overlay=new P(e,this._createTextureDescriptor(s,6408,this._imageSources.overlay),this._imageSources.overlay),this._passParameters.mask=new P(e,this._createTextureDescriptor(s,6406,this._imageSources.mask),this._imageSources.mask),this._passParameters.input=new P(e,this._createTextureDescriptor(s,6408,null)))}_createTextureDescriptor(e,s,i){const r=this.renderingContext,t=new y(e);return t.pixelFormat=t.internalFormat=s,t.wrapMode=33071,t.flipped=!!i,t.preMultiplyAlpha=!(6408!==s||!i||h(i.src)&&r.driverTest.svgPremultipliesAlpha.result),t}};e([l()],x.prototype,"produces",void 0),e([l()],x.prototype,"consumes",void 0),e([l()],x.prototype,"_imageSources",void 0),e([l()],x.prototype,"_imageLoadTask",void 0),x=e([u("esri.views.3d.webgl-engine.effects.magnifier.Magnifier")],x);export{x as Magnifier};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{disposeMaybe as s}from"../../../../core/maybe.js";import{property as i,subclass as
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{disposeMaybe as s}from"../../../../core/maybe.js";import{property as i,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{exactEquals as a,copy as o}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{createQuadVAO as n}from"./glUtil3D.js";import{S as h}from"../../../../chunks/ShadowCastVisualize.glsl.js";import{ShadowCastVisualizeTechnique as d}from"../shaders/ShadowCastVisualizeTechnique.js";import{ShadowCastVisualizeTechniqueConfiguration as l}from"../shaders/ShadowCastVisualizeTechniqueConfiguration.js";import{ColorAttachment0 as _}from"../../../webgl/enums.js";const m=4e4,p=5e4,u=1/512;let c=class extends t{constructor(e,t,s,i){super({}),this._techniques=e,this._rctx=t,this._data=s,this._requestRender=i,this._passParameters=new h(this._data),this._configuration=new l,this._enabled=!1,this._vao=n(t)}dispose(){this._stop(),this._vao=s(this._vao)}precompile(){this._showVisualization&&this._techniques.precompile(d,this._configuration)}render(e){if(!this._showVisualization)return;const[t,s]=this._data.computedSamples;this._passParameters.sampleScale=[t?1/t:0,s?1/s:0];const i=this._techniques.get(d,this._configuration);this._rctx.bindVAO(this._vao),this._rctx.bindTechnique(i,e,this._passParameters),this._rctx.setDrawBuffers([_]),this._rctx.drawArrays(i.primitiveType,0,this._vao.vertexCount("geometry"))}setOptions(e){void 0!==e.enabled&&this._setEnabled(e.enabled),void 0!==e.thresholdColor&&this._setThresholdColor(e.thresholdColor),void 0!==e.gradientColor&&this._setGradientColor(e.gradientColor),void 0!==e.bandedGradientColor&&this._setBandedGradientColor(e.bandedGradientColor),void 0!==e.threshold&&(this._threshold=e.threshold),void 0!==e.visualization&&(this._visualization=e.visualization),void 0!==e.bandSize&&(this._bandSize=e.bandSize)}get opacityFromElevation(){return this._passParameters.opacityFromElevation}set opacityFromElevation(e){this._passParameters.opacityFromElevation!==e&&(this._passParameters.opacityFromElevation=e,this.notifyChange("opacityFromElevation"))}get _showVisualization(){return this._enabled&&(this._data.computedSamples[0]>0||this._data.computedSamples[1]>0)&&this.opacityFromElevation>u}get _threshold(){return this._passParameters.threshold}set _threshold(e){this._threshold!==e&&(this._passParameters.threshold=e,this._requestRenderIfEnabled())}get _visualization(){return this._configuration.visualization}set _visualization(e){e!==this._visualization&&(this._configuration.visualization=e,this._requestRenderIfEnabled())}get _bandSize(){return this._passParameters.bandSize}set _bandSize(e){e!==this._bandSize&&(this._passParameters.bandSize=e,this._requestRenderIfEnabled())}_setThresholdColor(e){const t=this._passParameters.thresholdColor;a(e,t)||(o(this._passParameters.thresholdColor,e),this._requestRenderIfEnabled())}_setGradientColor(e){const t=this._passParameters.gradientColor;a(e,t)||(o(this._passParameters.gradientColor,e),this._requestRenderIfEnabled())}_setBandedGradientColor(e){const t=this._passParameters.bandedGradientColor;a(e,t)||(o(this._passParameters.bandedGradientColor,e),this._requestRenderIfEnabled())}_setEnabled(e){e!==this._enabled&&(e?this._start():this._stop())}_requestRenderIfEnabled(){this._enabled&&this._requestRender()}_start(){this._enabled=!0,this._requestRender()}_stop(){this._enabled=!1,this._requestRender()}};e([i()],c.prototype,"opacityFromElevation",null),c=e([r("esri.views.3d.webgl-engine.lib.ShadowCastRenderer")],c);export{c as ShadowCastRenderer,p as shadowCastDisableElevationMax,m as shadowCastDisableElevationMin,u as shadowCastDisabledElevationThreshold};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
2
|
import{glsl as e}from"../core/shaderModules/glsl.js";function a(a){a.code.add(e`float mapChannel(float x, vec2 p) {
|
|
3
|
-
|
|
3
|
+
if((x < p.x) && (p.x == 0.0) || !(x < p.x) && (p.x == 1.0)) {
|
|
4
|
+
return 0.0;
|
|
5
|
+
}
|
|
6
|
+
float result = (x < p.x) ? mix(0.0, p.y, x/p.x) : mix(p.y, 1.0, (x - p.x) / (1.0 - p.x) );
|
|
7
|
+
return max(result, 0.0);
|
|
4
8
|
}`),a.code.add(e`vec3 blackLevelSoftCompression(vec3 color, float averageAmbientRadiance) {
|
|
5
9
|
vec2 p = vec2(0.02, 0.0075) * averageAmbientRadiance;
|
|
6
10
|
return vec3(mapChannel(color.x, p), mapChannel(color.y, p), mapChannel(color.z, p));
|