@arcgis/core 4.32.0-next.20241021 → 4.32.0-next.20241023
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/applications/MapViewer/templateUtils.d.ts +4 -0
- package/applications/MapViewer/templateUtils.js +5 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0b7ee57bec7ffac312f2.js +1 -0
- package/assets/esri/core/workers/chunks/{1ba1d9c867ec6a492af9.js → 0f3912bca9fe25eea75c.js} +1 -1
- package/assets/esri/core/workers/chunks/{842ebde78db9bfcaf07b.js → 1678d1d0ecb9b2af69a8.js} +1 -1
- package/assets/esri/core/workers/chunks/1d16ca7791f64dd7c7fb.js +1 -0
- package/assets/esri/core/workers/chunks/1d4be734ff961e313257.js +1 -0
- package/assets/esri/core/workers/chunks/{b292758308dfac4ba8ee.js → 2d8aa31dc96bbd014036.js} +1 -1
- package/assets/esri/core/workers/chunks/{53f648321c5fde26bfe4.js → 319e06888467f9f460ab.js} +1 -1
- package/assets/esri/core/workers/chunks/33cae7ece52a77394b05.js +1 -0
- package/assets/esri/core/workers/chunks/{210a954f5299fe105e0b.js → 539060ffb7f230fb1bd0.js} +1 -1
- package/assets/esri/core/workers/chunks/545441dcc8e915e63ff1.js +1 -0
- package/assets/esri/core/workers/chunks/{303f39b9b7bd33109df8.js → 587df97288a83721d251.js} +1 -1
- package/assets/esri/core/workers/chunks/5caa02a7a85d05e253b4.js +1 -0
- package/assets/esri/core/workers/chunks/5cfecb320e1dcd258b2e.js +1 -0
- package/assets/esri/core/workers/chunks/67018ef25736f0722f6e.js +1 -0
- package/assets/esri/core/workers/chunks/89f74819ac1b5884c149.js +1 -0
- package/assets/esri/core/workers/chunks/92b2d81ef16877341f97.js +1 -0
- package/assets/esri/core/workers/chunks/{e6e77cbdeb99d90caad1.js → 97f62fad6d416a666319.js} +1 -1
- package/assets/esri/core/workers/chunks/98c1956b2e27058c8a51.js +1 -0
- package/assets/esri/core/workers/chunks/9c8a910b6261a4d5da77.js +1 -0
- package/assets/esri/core/workers/chunks/ab6eaa3ae2e233f91a5e.js +1 -0
- package/assets/esri/core/workers/chunks/{63719f892a7d1025c7d3.js → b42c1ab7579a3c464f72.js} +1 -1
- package/assets/esri/core/workers/chunks/{03eba36affe6ed1f5a11.js → bc4ef18d0a02354186e3.js} +7 -7
- package/assets/esri/core/workers/chunks/{c71304c88fce556340ef.js → c859f73b57a764e99b02.js} +1 -1
- package/assets/esri/core/workers/chunks/cb3038ec3ef0d86bf2a0.js +1 -0
- package/assets/esri/core/workers/chunks/{ae20ca2008a2ea6a46b2.js → d8f4bd2b4366388f8a28.js} +1 -1
- package/assets/esri/core/workers/chunks/e71fa25ed45bae5a1adb.js +320 -0
- package/assets/esri/core/workers/chunks/{9c9a8a529494c6d1dfa3.js → ec9d5af8887854e821c8.js} +1 -1
- package/assets/esri/libs/parquet/pkg/arcgis_parquet_bg.wasm +0 -0
- package/assets/esri/themes/base/widgets/_BatchAttributeForm.scss +14 -0
- package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +1 -1
- 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/chunks/Bufferer-BhkgvSV4.js +5 -0
- package/chunks/{Distance2DCalculator-DM4OojiI.js → Distance2DCalculator-BX0Ep7eP.js} +1 -1
- package/chunks/{GeodeticDistanceCalculator-DzvUOSaR.js → GeodeticDistanceCalculator-B5uO-Y_z.js} +1 -1
- package/chunks/OperatorCrosses.js +5 -0
- package/chunks/OperatorCut.js +1 -1
- package/chunks/OperatorGeodesicBuffer.js +1 -1
- package/chunks/OperatorGeodeticArea.js +1 -1
- package/chunks/OperatorGeodeticDensifyByLength.js +1 -1
- package/chunks/OperatorGeodeticDistance.js +1 -1
- package/chunks/OperatorGeodeticLength.js +1 -1
- package/chunks/OperatorIntersects.js +5 -0
- package/chunks/OperatorMultiPartToSinglePart.js +1 -1
- package/chunks/OperatorOverlaps.js +5 -0
- package/chunks/OperatorProximity.js +1 -1
- package/chunks/OperatorProximityGeodesic.js +1 -1
- package/chunks/OperatorShapePreservingLength.js +1 -1
- package/chunks/OperatorTouches.js +5 -0
- package/chunks/OperatorWithin.js +5 -0
- package/chunks/QuadraticBezier.js +1 -1
- package/chunks/SSAOBlur.glsl.js +5 -5
- package/chunks/SideCalculator2D-CoWc8Oe3.js +1 -1
- package/chunks/Transformation2D.js +1 -1
- package/core/MemCache.js +1 -1
- package/core/MemCachePool.js +1 -1
- package/core/unitUtils.js +1 -1
- package/geometry/Mesh.js +1 -1
- package/geometry/operators/affineTransformOperator.js +1 -1
- package/geometry/operators/alphaShapeOperator.js +1 -1
- package/geometry/operators/areaOperator.js +1 -1
- package/geometry/operators/autoCompleteOperator.js +1 -1
- package/geometry/operators/boundaryOperator.js +1 -1
- package/geometry/operators/bufferOperator.js +1 -1
- package/geometry/operators/centroidOperator.js +1 -1
- package/geometry/operators/clipOperator.js +1 -1
- package/geometry/operators/containsOperator.js +1 -1
- package/geometry/operators/convexHullOperator.js +1 -1
- package/geometry/operators/crossesOperator.js +1 -1
- package/geometry/operators/cutOperator.js +1 -1
- package/geometry/operators/densifyOperator.js +1 -1
- package/geometry/operators/differenceOperator.js +1 -1
- package/geometry/operators/disjointOperator.js +1 -1
- package/geometry/operators/distanceOperator.js +1 -1
- package/geometry/operators/equalsOperator.js +1 -1
- package/geometry/operators/extendOperator.js +1 -1
- package/geometry/operators/generalizeOperator.js +1 -1
- package/geometry/operators/geodesicBufferOperator.js +1 -1
- package/geometry/operators/geodesicProximityOperator.js +1 -1
- package/geometry/operators/geodeticAreaOperator.js +1 -1
- package/geometry/operators/geodeticDensifyOperator.js +1 -1
- package/geometry/operators/geodeticDistanceOperator.js +1 -1
- package/geometry/operators/geodeticLengthOperator.js +1 -1
- package/geometry/operators/graphicBufferOperator.js +1 -1
- package/geometry/operators/gx/operatorAlphaShape.js +1 -1
- package/geometry/operators/gx/operatorAutoComplete.js +1 -1
- package/geometry/operators/gx/operatorBoundary.js +1 -1
- package/geometry/operators/gx/operatorBuffer.js +1 -1
- package/geometry/operators/gx/operatorConvexHull.js +1 -1
- package/geometry/operators/gx/operatorDifference.js +1 -1
- package/geometry/operators/gx/operatorGeodesicBuffer.js +1 -1
- package/geometry/operators/gx/operatorGeodeticArea.js +1 -1
- package/geometry/operators/gx/operatorGeodeticDensify.js +1 -1
- package/geometry/operators/gx/operatorGeodeticDistance.js +1 -1
- package/geometry/operators/gx/operatorGeodeticLength.js +1 -1
- package/geometry/operators/gx/operatorGraphicBuffer.js +1 -1
- package/geometry/operators/gx/operatorIntegrate.js +1 -1
- package/geometry/operators/gx/operatorIntersection.js +1 -1
- package/geometry/operators/gx/operatorLabelPoint.js +1 -1
- package/geometry/operators/gx/operatorLinesToPolygons.js +1 -1
- package/geometry/operators/gx/operatorLocateBetween.js +1 -1
- package/geometry/operators/gx/operatorOffset.js +1 -1
- package/geometry/operators/gx/operatorPolygonOverlay.js +1 -1
- package/geometry/operators/gx/operatorPolygonSlicer.js +1 -1
- package/geometry/operators/gx/operatorProject.js +1 -1
- package/geometry/operators/gx/operatorProximityGeodesic.js +1 -1
- package/geometry/operators/gx/operatorSimplify.js +1 -1
- package/geometry/operators/gx/operatorSymmetricDifference.js +1 -1
- package/geometry/operators/gx/operatorUnion.js +1 -1
- package/geometry/operators/integrateOperator.js +1 -1
- package/geometry/operators/intersectionOperator.js +1 -1
- package/geometry/operators/intersectsOperator.js +1 -1
- package/geometry/operators/isNearOperator.js +1 -1
- package/geometry/operators/json/containsOperator.js +5 -0
- package/geometry/operators/json/crossesOperator.js +5 -0
- package/geometry/operators/json/disjointOperator.js +5 -0
- package/geometry/operators/json/intersectsOperator.js +5 -0
- package/geometry/operators/json/offsetOperator.js +5 -0
- package/geometry/operators/json/overlapsOperator.js +5 -0
- package/geometry/operators/json/touchesOperator.js +5 -0
- package/geometry/operators/json/withinOperator.js +5 -0
- package/geometry/operators/labelPointOperator.js +1 -1
- package/geometry/operators/lengthOperator.js +1 -1
- package/geometry/operators/linesToPolygonsOperator.js +1 -1
- package/geometry/operators/locateBetweenOperator.js +1 -1
- package/geometry/operators/minimumBoundingCircleOperator.js +1 -1
- package/geometry/operators/multiPartToSinglePartOperator.js +1 -1
- package/geometry/operators/offsetOperator.js +1 -1
- package/geometry/operators/overlapsOperator.js +1 -1
- package/geometry/operators/polygonOverlayOperator.js +1 -1
- package/geometry/operators/polygonSlicerOperator.js +1 -1
- package/geometry/operators/projectOperator.js +1 -1
- package/geometry/operators/proximityOperator.js +1 -1
- package/geometry/operators/relateOperator.js +1 -1
- package/geometry/operators/reshapeOperator.js +1 -1
- package/geometry/operators/simplifyOperator.js +1 -1
- package/geometry/operators/singlePartToMultiPartOperator.js +1 -1
- package/geometry/operators/support/apiConverter.js +5 -0
- package/geometry/operators/support/initNoPeFactory.js +5 -0
- package/geometry/operators/support/jsonConverter.js +5 -0
- package/geometry/operators/support/proximityResult.js +1 -1
- package/geometry/operators/symmetricDifferenceOperator.js +1 -1
- package/geometry/operators/touchesOperator.js +1 -1
- package/geometry/operators/unionOperator.js +1 -1
- package/geometry/operators/withinOperator.js +1 -1
- package/geometry/support/MeshVertexAttributes.js +1 -1
- package/interfaces.d.ts +134 -0
- package/layers/LinkChartLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/graphics/OptimizedGeometry.js +1 -1
- package/layers/graphics/sources/ParquetSource.js +1 -1
- package/layers/knowledgeGraph/supportUtils.js +1 -1
- package/layers/support/ElevationQueryTileCache.js +1 -1
- package/layers/support/ElevationTileData.js +1 -1
- package/layers/support/mediaUtils.js +1 -1
- package/layers/support/parquetLayerUtils.js +1 -1
- package/layers/support/rasterFunctions/ClipFunction.js +1 -1
- package/layers/support/rasterFunctions/clipUtils.js +1 -1
- package/layers/support/rasterFunctions/localUtils.js +1 -1
- package/libs/parquet/parquet.js +1 -1
- package/linkChart/LinkChartProperties.js +1 -1
- package/package.json +1 -1
- package/smartMapping/raster/renderers/classBreaks.js +1 -1
- package/smartMapping/raster/renderers/rgb.js +1 -1
- package/smartMapping/raster/renderers/stretch.js +1 -1
- package/smartMapping/raster/support/adapters/ImageryTileLayerAdapter.js +1 -1
- package/smartMapping/raster/support/adapters/RasterLayerAdapter.js +1 -1
- package/smartMapping/renderers/support/rendererUtils.d.ts +4 -0
- package/support/revision.js +1 -1
- package/symbols/cim/effects/EffectControlMeasureLine.js +1 -1
- package/views/2d/engine/vectorTiles/RenderBucket.js +1 -1
- package/views/2d/engine/vectorTiles/TileHandler3D.js +1 -1
- package/views/2d/engine/vectorTiles/VectorTile.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedMarkerShader.js +1 -1
- package/views/2d/grid/GridView2D.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/2d/layers/features/layerAdapters/ParquetLayerAdapter.js +1 -1
- package/views/2d/layers/features/schema/processor/symbols/ComplexSymbolSchema.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderParquet.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
- package/views/3d/camera/constraintUtils/tilt.js +1 -1
- package/views/3d/glTF/loader.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DSymbol.js +1 -1
- package/views/3d/layers/graphics/Graphics3DWebStyleSymbol.js +1 -1
- package/views/3d/layers/graphics/ObjectResourceCache.js +1 -1
- package/views/3d/layers/graphics/wosrLoader.js +1 -1
- package/views/3d/layers/i3s/CachedMeshData.js +5 -0
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/layers/i3s/PointRenderer.js +1 -1
- package/views/3d/layers/support/FeatureTile.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
- package/views/3d/state/ViewStateManager.js +1 -1
- package/views/3d/state/controllers/FovController.js +1 -1
- package/views/3d/support/buffer/InterleavedLayout.js +1 -1
- package/views/3d/terrain/Tile.js +1 -1
- package/views/3d/terrain/TileTexture.js +1 -1
- package/views/3d/webgl/ManagedFBO.js +1 -1
- package/views/3d/webgl/ManagedFBOAttachment.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/core/FBOPool.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/materials/ProceduralTextureRepository.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
- package/views/3d/webgl-engine/shaders/SSAOBlur.glsl.js +1 -1
- package/views/input/BrowserEventSource.js +1 -1
- package/views/webgl/Texture.js +1 -1
- package/views/webgl/VertexArrayObject.js +1 -1
- package/webdoc/support/webdocSaveUtils.js +1 -1
- package/widgets/Attribution/AttributionViewModel.js +1 -1
- package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
- package/widgets/BatchAttributeForm/css.js +1 -1
- package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
- package/widgets/BatchAttributeForm.js +1 -1
- package/widgets/ElevationProfile/support/ElevationProfileView2D.js +1 -1
- package/widgets/ElevationProfile/support/ProfileLine2D.js +5 -0
- package/widgets/ElevationProfile/support/ProfileLines3D.js +1 -1
- package/widgets/ElevationProfile/support/constants.js +1 -1
- package/widgets/ElevationProfile/support/visualizationUtils.js +5 -0
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
- package/widgets/FeatureTable/support/columnUtils.js +1 -1
- package/widgets/FeatureTable/support/tableUtils.js +1 -1
- package/widgets/FeatureTable/support/templateUtils.js +5 -0
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/support/GridControls/GridControlsViewModel.js +1 -1
- package/widgets/support/GridControls.js +1 -1
- package/assets/esri/core/workers/chunks/03d0394fff1463c224f9.js +0 -1
- package/assets/esri/core/workers/chunks/0c40cac18711f79f0a7d.js +0 -1
- package/assets/esri/core/workers/chunks/1a97f98facfc62a9fc69.js +0 -1
- package/assets/esri/core/workers/chunks/1e3ed3ee48c2977cff6f.js +0 -1
- package/assets/esri/core/workers/chunks/1fc064e37d030e449d5e.js +0 -1
- package/assets/esri/core/workers/chunks/4daab36de5efa03a8cbb.js +0 -1
- package/assets/esri/core/workers/chunks/77d129134c2a66cd86d8.js +0 -1
- package/assets/esri/core/workers/chunks/88bd9e023764da377aa7.js +0 -1
- package/assets/esri/core/workers/chunks/92ce57cb12d9a7a3699e.js +0 -1
- package/assets/esri/core/workers/chunks/a5675c989d00b7400f98.js +0 -1
- package/assets/esri/core/workers/chunks/c06c5c815b5e37717fa1.js +0 -1
- package/assets/esri/core/workers/chunks/ca1385e165aae8a32ca2.js +0 -1
- package/assets/esri/core/workers/chunks/ce8c1208916f54af7e68.js +0 -320
- package/assets/esri/core/workers/chunks/df51c93b2dbcc89efc23.js +0 -1
- package/assets/esri/core/workers/chunks/efa3c919261672871f2f.js +0 -1
- package/chunks/Bufferer-fr1_Nc47.js +0 -5
- package/geometry/operators/support/converterAPI.js +0 -5
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{someMap as t}from"../../../core/MapUtils.js";import{releaseMaybe as e}from"../../../core/maybe.js";import{RenderCategory as h}from"../webgl.js";import{isManagedDepthTexture as
|
|
5
|
+
import{someMap as t}from"../../../core/MapUtils.js";import{releaseMaybe as e}from"../../../core/maybe.js";import{RenderCategory as h}from"../webgl.js";import{isManagedDepthTexture as r}from"./ManagedDepthTexture.js";import{ManagedFBObject as s,AttachmentType as o}from"./ManagedFBObject.js";import{DepthStencilAttachment as i,ColorAttachment as a}from"../../webgl/enums.js";class c extends s{constructor(t,e,r,s,i,a){super(t,a),this.type=o.FBO,this._colors=new Map,this._name=h.COMPOSITE,this.acquireDepth=null,this.acquireColor=null,this._name=e,this.fbo=r,this.acquireDepth=s,this.acquireColor=i}dispose(){this.fbo?.dispose()}get cachedMemory(){return this.fbo?.usedMemory||0}get numberOfColorAttachments(){return this._colors.size}get name(){return this._name}setName(t){this._name=t}getTexture(t=a.COLOR_ATTACHMENT0){return t===i?this.fbo?.depthStencilTexture:this.fbo?.getColorTexture(t)}getAttachment(t=a.COLOR_ATTACHMENT0){return t===i?this._depth:this._colors.get(t)}hasAttachment(e){return t(this._colors,(t=>t.name===e))}attachDepth(t){return t?.retain(),this.detachDepth(),t&&this.fbo?.attachDepthStencil(t.attachment),this._depth=t,this}detachDepth(){this.fbo?.detachDepthStencilTexture(),this.fbo?.detachDepthStencilBuffer(),this._depth=e(this._depth)}obtainDepthTexture(){const t=this._depth;return r(t)?(this.fbo?.detachDepthStencilTexture(),this._depth=null,t):null}attachColor(t,e){return t.retain(),this.detachColor(e),this.fbo?.attachColorTexture(t.attachment,e),this._colors.set(e,t),this}detachColor(t){this.fbo?.detachColorTexture(t);const e=this._colors.get(t);this._colors.delete(t),e?.release()}detachAll(){this._colors.forEach(((t,e)=>this.detachColor(e))),this.detachDepth()}}export{c as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{ManagedFBObject as t}from"./ManagedFBObject.js";class e extends t{constructor(t,e,s){super(t,s),this.attachment=e,this.name=""}dispose(){this.attachment.dispose()}get
|
|
5
|
+
import{ManagedFBObject as t}from"./ManagedFBObject.js";class e extends t{constructor(t,e,s){super(t,s),this.attachment=e,this.name=""}dispose(){this.attachment.dispose()}get cachedMemory(){return this.attachment.usedMemory}}export{e as ManagedFBOAttachment};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../core/Error.js";import{ColorFormat as t,DepthFormat as r}from"../../webgl/formats.js";import{ManagedColorAttachment as a}from"../../webgl/ManagedColorAttachment.js";import{ManagedDepthAttachment as o}from"../../webgl/ManagedDepthAttachment.js";import
|
|
5
|
+
import e from"../../../../core/Error.js";import{ColorFormat as t,DepthFormat as r}from"../../webgl/formats.js";import{ManagedColorAttachment as a}from"../../webgl/ManagedColorAttachment.js";import{ManagedDepthAttachment as o}from"../../webgl/ManagedDepthAttachment.js";import c from"../../webgl/ManagedFBO.js";import{AttachmentType as i}from"../../webgl/ManagedFBObject.js";import{FBOPool as h}from"./FBOPool.js";import{PixelFormat as n,SizedPixelFormat as s,TextureWrapMode as d,PixelType as l,TextureSamplingMode as m,RenderbufferFormat as _,ColorAttachment as u}from"../../../webgl/enums.js";import{FramebufferObject as p}from"../../../webgl/FramebufferObject.js";import{Renderbuffer as f}from"../../../webgl/Renderbuffer.js";import{RenderbufferDescriptor as w}from"../../../webgl/RenderbufferDescriptor.js";import{Texture as C}from"../../../webgl/Texture.js";import{TextureDescriptor as E}from"../../../webgl/TextureDescriptor.js";class T{constructor(e){this.rctx=e,this._acquired=new Set,this._cache=new h(e.newCache,"FBOCache"),this._depthCache=new h(e.newCache,"DepthAttachmentCache"),this._colorCache=new h(e.newCache,"ColorAttachmentCache")}destroy(){this._cache.destroy(),this._depthCache.destroy(),this._colorCache.destroy()}clean(){this._cache.clean(),this._colorCache.clean(),this._depthCache.clean()}frameStart(){this._cache.frame(),this._colorCache.frame(),this._depthCache.frame(),this.debugCallback&&this.debugCallback()}frameEnd(){const e=this.debugCallback;e&&this._acquired.forEach((t=>t.type===i.FBO&&e(t.name,t.fbo,t.numberOfColorAttachments)))}get usedMemory(){return Array.from(this._acquired.values()).reduce(((e,t)=>e+("getTexture"in t?t.getTexture()?.usedMemory??0:t.cachedMemory)),this._cache.usedMemory+this._colorCache.usedMemory+this._depthCache.usedMemory)}set interactive(e){this._cache.interactive=this._colorCache.interactive=this._depthCache.interactive=e}acquire(a,o,i,h=t.RGBA){const n=A(h,a,o);let s=this._cache.pop(n);if(s){s.retain(),s.setName(i);const t=this.rctx.getBoundFramebufferObject();if(this.rctx.bindFramebuffer(s.fbo),this.rctx.setDrawBuffers([u.COLOR_ATTACHMENT0]),!s.fbo)throw new e("attempt to use a not existing framebuffer");this.rctx.unbindTexture(s.fbo.colorTexture),this.rctx.bindFramebuffer(t)}else s=new c(n,i,new p(this.rctx,{...G[h],width:a,height:o}),(e=>{e??=r.DEPTH_STENCIL_TEXTURE;const t=this._acquireDepth(e,s.fbo.width,s.fbo.height,`${s.name} depth`);return s.attachDepth(t),t.release(),s}),((e,r,c)=>{r??=t.RGBA;const i=this._acquireColor(r,a,o,c??`${s.name} color ${e}`);return this.rctx.unbindTexture(i.attachment),s.attachColor(i,e),i.release(),s}),(()=>{this.debugCallback&&this.debugCallback(s.name,s.fbo,s.numberOfColorAttachments),this._acquired.delete(s),s.detachAll(),this._cache.put(s)}));return this._trackHandle(s)}acquireDepth(e,t,r,a){return this._acquireDepth(e,t,r,a)}_acquireDepth(e,t,a,c){const i=A(e,t,a),h=this._depthCache.pop(i);if(h)return h.retain(),h.name=c,this._trackHandle(h);const n=e===r.DEPTH_STENCIL_TEXTURE?new o(i,new C(this.rctx,{...P[e],width:t,height:a}),(()=>{this._acquired.delete(n),this._depthCache.put(n)})):new o(i,new f(this.rctx,{...P[e],width:t,height:a}),(()=>{this._acquired.delete(n),this._depthCache.put(n)}));return n.name=c,this._trackHandle(n)}_acquireColor(e,t,r,o){const c=A(e,t,r),i=this._colorCache.pop(c);if(i)return i.retain(),i.name=o,this._trackHandle(i);const h=new a(c,new C(this.rctx,{...G[e],width:t,height:r}),(()=>{this._acquired.delete(h),this._colorCache.put(h)}));return h.name=o,this._trackHandle(h)}_trackHandle(e){return this._acquired.add(e),e}}const b=new c("default","default",null,(()=>b),(()=>b),(()=>{}));function A(e,t,r){return`${e}x${t}x${r}`}b.release=()=>!1;const g=new E;g.pixelFormat=n.RED,g.internalFormat=s.R8,g.wrapMode=d.CLAMP_TO_EDGE;const M=new E;M.pixelFormat=n.RG,M.internalFormat=s.RG8,M.wrapMode=d.CLAMP_TO_EDGE;const R=new E;R.internalFormat=s.RGBA4,R.dataType=l.UNSIGNED_SHORT_4_4_4_4,R.wrapMode=d.CLAMP_TO_EDGE;const F=new E;F.wrapMode=d.CLAMP_TO_EDGE;const x=new E;x.wrapMode=d.CLAMP_TO_EDGE,x.samplingMode=m.LINEAR_MIPMAP_LINEAR,x.hasMipmap=!0,x.maxAnisotropy=8;const D=new E;D.pixelFormat=n.RED,D.dataType=l.HALF_FLOAT,D.internalFormat=s.R16F,D.samplingMode=m.NEAREST;const O=new E;O.dataType=l.HALF_FLOAT,O.internalFormat=s.RGBA16F,O.samplingMode=m.NEAREST;const G={[t.RED]:g,[t.RG]:M,[t.RGBA4]:R,[t.RGBA]:F,[t.RGBA_MIPMAP]:x,[t.R16F]:D,[t.RGBA16F]:O},N=new E;N.pixelFormat=n.DEPTH_STENCIL,N.dataType=l.UNSIGNED_INT_24_8,N.samplingMode=m.NEAREST,N.wrapMode=d.CLAMP_TO_EDGE,N.internalFormat=n.DEPTH24_STENCIL8;const P={[r.DEPTH_STENCIL_TEXTURE]:N,[r.DEPTH16_BUFFER]:new w(_.DEPTH_COMPONENT16,4)};export{T as FBOCache,b as defaultWebGLFBO};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{MemCachePool as t}from"../../../../core/MemCachePool.js";import s from"../../../../core/PooledArray.js";class i{constructor(i,e){this._last=new s,this._incarnation=0,this._cache=new t(i,e)}destroy(){this._last?.forAll((t=>t.dispose())),this._last=null,this._cache.destroy()}set interactive(t){t&&!this._last?this._last=new s:t||(this._last?.forAll((t=>t.dispose())),this._last=null)}clean(){this._last?.filterInPlace((t=>!(t.incarnation<this._incarnation)||(this._cache.put(t.key,t),!1)))}frame(){++this._incarnation}pop(t){if(this._last){const s=this._last.find((s=>s.key===t));if(s)return this._last.removeUnordered(s),s}return this._cache.pop(t)}put(t){t.incarnation=this._incarnation,this._last?this._last.push(t):this._cache.put(t.key,t)}get usedMemory(){return this._last?.reduce(((t,s)=>t+s.
|
|
5
|
+
import{MemCachePool as t}from"../../../../core/MemCachePool.js";import s from"../../../../core/PooledArray.js";class i{constructor(i,e){this._last=new s,this._incarnation=0,this._cache=new t(i,e)}destroy(){this._last?.forAll((t=>t.dispose())),this._last=null,this._cache.destroy()}set interactive(t){t&&!this._last?this._last=new s:t||(this._last?.forAll((t=>t.dispose())),this._last=null)}clean(){this._last?.filterInPlace((t=>!(t.incarnation<this._incarnation)||(this._cache.put(t.key,t),!1)))}frame(){++this._incarnation}pop(t){if(this._last){const s=this._last.find((s=>s.key===t));if(s)return this._last.removeUnordered(s),s}return this._cache.pop(t)}put(t){t.incarnation=this._incarnation,this._last?this._last.push(t):this._cache.put(t.key,t)}get usedMemory(){return this._last?.reduce(((t,s)=>t+s.cachedMemory),0)??0}}export{i as FBOPool};
|
|
@@ -26,7 +26,7 @@ fragHighlight = combinedHighlight;
|
|
|
26
26
|
}
|
|
27
27
|
bool isHighlightOccluded() {
|
|
28
28
|
float sceneDepth = texelFetch(depthTexture, ivec2(gl_FragCoord.xy), 0).x;
|
|
29
|
-
return gl_FragCoord.z > sceneDepth + 5e-
|
|
29
|
+
return gl_FragCoord.z > sceneDepth + 5e-7;
|
|
30
30
|
}
|
|
31
31
|
void calculateOcclusionAndOutputHighlight() {
|
|
32
32
|
outputHighlight(isHighlightOccluded());
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{equals as r,binaryIndexOf as s}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import n from"../../../../../core/Logger.js";import{clamp as i}from"../../../../../core/mathUtils.js";import{disposeMaybe as o,destroyMaybe as a}from"../../../../../core/maybe.js";import{isAbortError as c,onAbortOrThrow as l}from"../../../../../core/promiseUtils.js";import{property as d}from"../../../../../core/accessorSupport/decorators/property.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as u,transpose as m,invert as g}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as f}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as p}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{i as _,c as b,a as y,f as j}from"../../../../../chunks/vec32.js";import{create as O,clone as w}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as E}from"../../../../../core/support/UpdatingHandles.js";import{a as v,g as x}from"../../../../../chunks/sphere.js";import{c as M}from"../../../../../chunks/vec33.js";import{ViewingMode as R}from"../../../../ViewingMode.js";import{encodeElevationOffset as T}from"../../collections/Component/Material/shader/ComponentData.glsl.js";import{TwoVectorPosition as A}from"../../core/util/TwoVectorPosition.js";import{Attribute as C}from"../Attribute.js";import{GridLocalOriginFactory as D}from"../GridLocalOriginFactory.js";import{applyToModelMatrix as P}from"../localOriginHelper.js";import{LocalOriginManager as U}from"../LocalOriginManager.js";import{Object3D as L}from"../Object3D.js";import{VertexArrayObject as k}from"../VertexArrayObject.js";import{VertexAttribute as I}from"../VertexAttribute.js";import{VertexLayout as S,EdgeInputBufferLayout as B,vertexAttributeLocations as V,glVertexLayout as q}from"./bufferLayouts.js";import{RegularEdgeBufferWriter as H,SilhouetteEdgeBufferWriter as G}from"./edgeBufferWriters.js";import{EdgeRenderer as N,lineWidthFractionFactor as W,extensionLengthOffset as z}from"./EdgeRenderer.js";import{EdgePassParameters as F}from"./EdgeShaderParameters.js";import{EdgeWorkerHandle as K}from"./EdgeWorkerHandle.js";import"./interfaces.js";import{generateStrokesTexture as J}from"./strokes.js";import{determineRendererType as Q,determineEdgeTransparency as X,determineObjectTransparency as Y,fillComponentBufferIndices as Z}from"./util.js";import{BufferManager as $}from"../TextureBackedBuffer/BufferManager.js";import{EdgeSilhouette as ee}from"../../shaders/sources/edgeRenderer/EdgeUtil.glsl.js";import{BufferObject as te}from"../../../../webgl/BufferObject.js";import{Usage as re}from"../../../../webgl/enums.js";const se=128;let ne=class extends t{constructor(e){super(e),this._updatingHandles=new E,this._objectEntries=new Map,this._pendingDeletions=new Map,this._renderers=new Map,this._gpuMemoryUsage=0,this._workerAbort=new AbortController,this._tmpModelPosition=O(),this._localOrigins=new U(new D(e.renderSR));const t=S.createBuffer(4);for(let r=0;r<4;r++)t.sideness.set(r,0,0===r||3===r?0:1),t.sideness.set(r,1,0===r||1===r?0:1);this._verticesBufferObject=te.createVertex(e.rctx,re.STATIC_DRAW,t.buffer)}initialize(){this._worker=new K(this.schedule),this._componentColorManager=new $(this.rctx,3)}destroy(){this.destroyed||(this._objectEntries.forEach((e=>this._discardObjectEntry(e))),this._objectEntries.clear(),this._pendingDeletions.forEach((e=>this._discardObjectEntry(e))),this._pendingDeletions.clear(),this._strokesTexture=o(this._strokesTexture),this._componentColorManager=a(this._componentColorManager),this._workerAbort.abort(),this._worker.destroy(),this._verticesBufferObject.dispose(),this._renderers.clear(),this._updatingHandles.destroy(),this._set("schedule",we))}get updating(){return this._updatingHandles.updating}get usedMemory(){return this._gpuMemoryUsage}shouldRender(){return this._renderers.size>0}async addComponentObject(e,t,r,s,n,i,o){if(this.hasObject(e))return this._getObjectMemoryUsage(e);let a;const c=new ae(null,new Promise((e=>a=e)),e.obb.center,e.obb.radius);this._objectEntries.set(e,c);const l=await this._updatingHandles.addPromise(this._addComponentGeometry(e.transform,c,t,r,s,n,i,o));return this.setNeedsRender(),a(),l}async addOrUpdateObject3D(e,t,r,s){if(this.destroyed)return void n.getLogger(this).warn("Attempt to add an object to a destroyed instance");const i=new AbortController;let o;const a=e.boundingVolumeWorldSpace.bounds,l=new ae(i,new Promise((e=>o=e)),v(a),x(a)),d=this._objectEntries.get(e);d&&(this._pendingDeletions.has(e)?this._discardObjectEntry(d):this._pendingDeletions.set(e,d)),this._objectEntries.set(e,l);try{const n=new Array;if(e.geometries.length>1&&oe(e))n.push(this._addObjectMergedGeometries(e,l,t,r,s));else for(const i of e.geometries)i.material.supportsEdges&&n.push(this._addGeometry(e,l,i,t,r,s));await this._updatingHandles.addPromise(Promise.all(n)),this._removePendingDeletion(e)}catch(h){c(h)?this._discardObjectEntry(l):this._removePendingDeletion(e)}finally{this.setNeedsRender(),o()}}removeObject(e){const t=this._objectEntries.get(e);this._objectEntries.delete(e),this._discardObjectEntry(t),this._removePendingDeletion(e)}_removePendingDeletion(e){const t=this._pendingDeletions.get(e);this._pendingDeletions.delete(e),this._discardObjectEntry(t)}async _getObjectEntry(e){const t=this._objectEntries.get(e);if(!t)throw new Error("no object");return await t.loaded,null==t.loaded?null:t}fastUpdateObject3DEdgesTransform(e){if(this.destroyed)return!1;const t=this._objectEntries.get(e);if(!t)return!1;const{geometries:r}=e,{renderables:s}=t;if(0===r.length||0===s.length)return!0;if(s.length>1)return!1;const[n]=s,i=n.transform;if(!(i instanceof de))return!1;const[o]=r;if(o.localOrigin!==i.origin.origin)return!1;const a=p(),c=this._computeModelTransformWithLocalOrigin(e,o,a);return n.transform=new de(a,c),this.setNeedsRender(),!0}_discardObjectEntry(e){e&&(e.abort?.abort(),e.renderables.length&&(e.renderables.forEach((e=>this._removeRenderable(e))),this.setNeedsRender()),e.loaded=null)}hasObject(e){return this._objectEntries.has(e)}async updateAllComponentOpacities(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));if(null==r)return;const s=Array.isArray(t)?e=>t[e]:()=>t;r.renderables.forEach((e=>{const t=e.components.meta.length;for(let r=0;r<t;r++){const t=s(r),n=e.components.meta[r],i=n.index;n.material.opacity=t,e.components.buffer.textureBuffer.setDataElement(i,1,3,255*t)}this._updateTransparency(e)})),this.setNeedsRender()}async _getObjectMemoryUsage(e){const t=await this._getObjectEntry(e);return t?t.renderables.reduce(((e,t)=>e+t.statistics.gpuMemoryUsage),0):0}async updateAllComponentMaterials(e,t,r,s){const n=e instanceof L,i=Q(t),o=N.getKey(i,r,n),a=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=a&&(a.renderables.forEach((e=>{if(o!==e.rendererKey){const t=this._renderers.get(e.rendererKey),s=this._acquireRenderer(i,r,n);t.removeRenderable(e),--t.refCount,e.rendererKey=o,s.addRenderable(e)}if(Array.isArray(t))for(let r=0;r<t.length;r++)e.components.meta[r].material=t[r];else e.components.meta[0].material=t;s&&me(e.components),this._updateTransparency(e)})),this.setNeedsRender())}async updateAllVerticalOffsets(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&this._updateAllVerticalOffsets(r,t)}_updateAllVerticalOffsets(e,t){e.renderables.forEach((e=>{const r=e.components.meta;for(let s=0;s<r.length;s++)e.components.meta[s].verticalOffset=t?.[s]??0;me(e.components)})),this.setNeedsRender()}async updateObjectVisibility(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));r&&(r.renderables.forEach((e=>e.visible=t)),this.setNeedsRender())}render(e,t){if(null==this._componentColorManager)return;this._localOrigins.updateViewMatrices(e.camera.viewMatrix);const r=e.camera.viewInverseTransposeMatrix,s=O(),n=new A;let i=0,o=0;if(this._renderers.forEach((r=>{0!==r.refCount?(++this.techniques.precompiling,r.forEachRenderable((t=>{t.visible&&(i+=t.statistics.averageEdgeLength,o++,t.regular&&r.acquireTechnique(e,!1).release(),t.silhouette&&r.acquireTechnique(e,!0).release())}),t),--this.techniques.precompiling):this._renderers.delete(r.key)})),this._componentColorManager.garbageCollect(),this._componentColorManager.updateTextures(),0===o)return;const a=new F(40*i/o,t);_(s,r[3],r[7],r[11]),n.set(s),b(a.transformWorldFromViewTH,n.high),b(a.transformWorldFromViewTL,n.low),u(a.transformViewFromCameraRelativeRS,e.camera.viewMatrix),m(Oe,a.transformViewFromCameraRelativeRS),g(a.transformNormalViewFromGlobal,Oe),a.transformProjFromView=e.camera.projectionMatrix,this._updateObjectCameraDistances(e),this._renderers.forEach((t=>{ge(t,e,a),fe(t,e,a)}))}_updateTransparency(e){const t=X(e.components.meta),r=Y(e.components.meta);t===e.edgeTransparency&&r===e.objectTransparency||(e.edgeTransparency=t,e.objectTransparency=r,this._renderers.get(e.rendererKey).setRenderablesDirty())}_computeModelTransformWithLocalOrigin(e,t,r){e.getCombinedShaderTransformation(t,r);const s=null!=t.localOrigin?this._localOrigins.register(t.localOrigin):this._localOrigins.acquire(_(this._tmpModelPosition,r[12],r[13],r[14]));return t.localOrigin=s.origin,P(s.origin.vec3,r),s}_createComponentBuffers(e){if(null==this._componentColorManager)return null;const t=new Array,r=this._componentColorManager.getBuffer(e.length);for(let n=0;n<e.length;n++){const s=e[n],i=r.acquireIndex();t.push({index:i,verticalOffset:0,material:s})}const s=new ce(r,t);return me(s),s}_extractEdges(e,t,r,s,n,i,o=i.length){return o<se&&(n=!0),this._worker.process({data:r,indices:i,indicesLength:o,writerSettings:t,skipDeduplicate:s},e,n)}_createRenderable(e,t,r,s,n){const i=t=>new le(new k(this.rctx,V,new Map([["vertices",q],["instances",t===ee.REGULAR?H.glLayout:G.glLayout]]),new Map([["vertices",this._verticesBufferObject],["instances",te.createVertex(this.rctx,re.STATIC_DRAW,t===ee.REGULAR?e.regular.instancesData.buffer:e.silhouette.instancesData.buffer)]])),t===ee.REGULAR?e.regular.lodInfo:e.silhouette.lodInfo),o=e.regular.lodInfo.lengths.length>0?i(ee.REGULAR):null,a=e.silhouette.lodInfo.lengths.length>0?i(ee.SILHOUETTE):null,c=(o?.vao.usedMemory??0)+(a?.vao.usedMemory??0);return new he(o,a,{gpuMemoryUsage:c,externalMemoryUsage:n,averageEdgeLength:e.averageEdgeLength},r,X(t.meta),Y(t.meta),t,s)}async _addGeometry(e,t,r,s,n,i){if(r.edgeIndicesLength<=0)return;const o=r.attributes.get(I.POSITION),a=p(),c=this._computeModelTransformWithLocalOrigin(e,r,a),l=new je(o,a,c);return this._addPositionData(t,l,r.edgeIndicesLength,s,n,i)}async _addPositionData(e,t,r,s,n,i=!1){if(null==e.loaded)return;const o=this._createComponentBuffers([s]);if(null==o)return;const a=this._acquireRenderer(s.type,n,!0),{modelTransform:c,origin:l}=t,d=t.position.indices,h=t.position,u=h.data.length/h.size,m=B.createBuffer(u);for(let p=0;p<u;p++)m.position.set(p,0,h.data[p*h.size]),m.position.set(p,1,h.data[p*h.size+1]),m.position.set(p,2,h.data[p*h.size+2]);Z(o.meta,[0,m.componentIndex.count],m.componentIndex);const g=await this._updatingHandles.addPromise(this._extractEdges(e.abort?.signal||this._workerAbort.signal,a.writerSettings,m,!1,i,d,r));if(null==e.loaded)return;const f=this._createRenderable(g,o,new de(c,l),a.key,!1);e.renderables.push(f),a.addRenderable(f),this._gpuMemoryUsage+=f.statistics.gpuMemoryUsage}async _addComponentGeometry(e,t,r,s,n,i,o,a){if(null==t.loaded)return 0;const c=this._createComponentBuffers(i);if(null==c)return 0;const l=Q(i),d=this._acquireRenderer(l,o||!1,!1),h=B.createBuffer(r.length/3);M(h.position.typedBuffer,r,h.position.typedBufferStride,3),Z(c.meta,n,h.componentIndex,s);const u=!0,m=d.writerSettings,g=await this._updatingHandles.addPromise(this._extractEdges(this._workerAbort.signal,m,h,u,!1,s));if(null==t.loaded)return 0;const f=this._createRenderable(g,c,e,d.key,!0);return t.renderables.push(f),d.addRenderable(f),this._updateAllVerticalOffsets(t,a),f.statistics.gpuMemoryUsage}async _addObjectMergedGeometries(e,t,r,s,n){const i=new Map;let o=0,a=0,c=null;const l=e.geometries.filter((e=>{if(e.edgeIndicesLength<=0||!e.material.supportsEdges)return!1;!c&&e.localOrigin&&(c=e);const t=e.attributes.get(I.POSITION);return a+=t.data.length/t.size,o+=e.edgeIndicesLength,!0}));if(0===l.length)return;const d=a>=65536?Uint32Array:Uint16Array,h=o?new d(o):null,u=[];let m=0;l.forEach((e=>{const t=e.attributes.get(I.POSITION),r=t.indices;let s=i.get(t.data);if(null==s){s=u.length/3;for(let e=0;e<t.data.length;e+=t.size)u.push(t.data[e]),u.push(t.data[e+1]),u.push(t.data[e+2]);i.set(t.data,s)}for(let n=0;n<e.edgeIndicesLength;n++)h[m++]=s+r[n]}));const g=c||e.geometries[0],f=p(),_=this._computeModelTransformWithLocalOrigin(e,g,f);for(let p=0;p<e.geometries.length;p++)e.geometries[p].localOrigin=_.origin;const b=new je(new C(u,h,3),f,_);await this._updatingHandles.addPromise(this._addPositionData(t,b,h.length,r,s,n))}_acquireRenderer(e,t,r){const s=N.getKey(e,t,r);let n=this._renderers.get(s);return null==this._strokesTexture&&(this._strokesTexture=J(this.rctx)),n||(n=new N(this.rctx,this.techniques,{type:e,hasSlicePlane:t,strokesTexture:this._strokesTexture,legacy:r,spherical:this.viewingMode===R.Global}),this._renderers.set(s,n)),++n.refCount,n}_removeRenderable(e){ie(e.regular),ie(e.silhouette);const t=this._renderers.get(e.rendererKey);if(t){t.removeRenderable(e),--t.refCount,this._localOrigins.release(e.transform.origin),this._gpuMemoryUsage-=e.statistics.externalMemoryUsage?0:e.statistics.gpuMemoryUsage;for(const t of e.components.meta)e.components.buffer.releaseIndex(t.index)}}_updateObjectCameraDistances(e){const t=e.camera.eye,r=e.camera.viewForward,s=O(),n=e=>{y(s,e.center,t);const n=j(s,r),i=e.radius,o=n<-i?1/0:n<i?0:n-i;e.renderables.forEach((e=>e.distanceToCamera=o))};this._objectEntries.forEach(n),this._pendingDeletions.forEach(n)}get test(){}};function ie(e){e?.vao&&(e.vao.vertexBuffers.get("instances")?.dispose(),e.vao.disposeVAOOnly(),e.vao=null)}function oe(e){let t=null,s=null;for(const n of e.geometries){if(n.material.supportsEdges){if(t){if(!r(t,n.transformation))return!1}else t=n.transformation;if(s||null==n.localOrigin){if(null!=s?.localOrigin&&null!=n.localOrigin&&s.localOrigin.id!==n.localOrigin.id)return!1}else s=n}}return!0}e([d({constructOnly:!0})],ne.prototype,"rctx",void 0),e([d({constructOnly:!0})],ne.prototype,"renderSR",void 0),e([d({constructOnly:!0})],ne.prototype,"viewingMode",void 0),e([d({constructOnly:!0})],ne.prototype,"techniques",void 0),e([d({constructOnly:!0})],ne.prototype,"setNeedsRender",void 0),e([d({constructOnly:!0})],ne.prototype,"schedule",void 0),e([d({readOnly:!0})],ne.prototype,"_updatingHandles",void 0),e([d({readOnly:!0})],ne.prototype,"updating",null),ne=e([h("esri.views.3d.webgl-engine.lib.edgeRendering.EdgeView")],ne);class ae{constructor(e,t,r,s){this.abort=e,this.radius=s,this.renderables=new Array;const n=e?l(e.signal,(()=>e.abort())):null;this.loaded=t,this.loaded.then((()=>{null!=this.loaded&&(this.loaded=!0),this.abort=null,n?.remove()})),this.center=w(r)}}class ce{constructor(e,t){this.buffer=e,this.meta=t}}class le{constructor(e,t){this.vao=e,this.lod=t}}class de{constructor(e,t){this.modelMatrix=e,this.origin=t}}class he{constructor(e,t,r,s,n,i,o,a){this.regular=e,this.silhouette=t,this.statistics=r,this.transform=s,this.edgeTransparency=n,this.objectTransparency=i,this.components=o,this.rendererKey=a,this.distanceToCamera=0,this.visible=!0}}class ue extends he{}function me(e){const{meta:t,buffer:r}=e,s=new Uint8Array(4);for(let n=0;n<t.length;n++){const e=t[n].material,o=t[n].index,a=i(Math.round(e.size*W),0,255),c=i(e.extensionLength,-z,255-z)+z,l=255*e.opacity,d=e.color,h=255*d[0],u=255*d[1],m=255*d[2],g=255*d[3];r.textureBuffer.setData(o,0,h,u,m,g),r.textureBuffer.setData(o,1,a,c,e.type,l),T(t[n].verticalOffset,s),r.textureBuffer.setData(o,2,s[0],s[1],s[2],s[3])}}function ge(e,t,r){let s,n;const i=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((i=>{if(!pe(i)||!i.visible)return;s??=e.acquireTechnique(t,!1),n??=e.rctx.bindTechnique(s,t,r);const a=ye(i.regular.lod.lengths,i.distanceToCamera,o);e.renderRegularEdges(n,i,r,t,a)}),i),s?.release()}function fe(e,t,r){let s,n;const i=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((i=>{if(!be(i)||!i.visible)return;s??=e.acquireTechnique(t,!0),n??=e.rctx.bindTechnique(s,t,r);const a=ye(i.silhouette.lod.lengths,i.distanceToCamera,o);e.renderSilhouetteEdges(n,i,r,t,a)}),i),s?.release()}function pe(e){return null!=e.regular}class _e extends he{}function be(e){return null!=e.silhouette}function ye(e,t,r){const n=t*r,i=s(e,n,!0);return-1===i?n<e[0]?e.length:0:e.length-i}class je{constructor(e,t,r){this.position=e,this.modelTransform=t,this.origin=r}}const Oe=f(),we=()=>Promise.reject();export{ne as EdgeView,de as LegacyTransform,ue as RegularRenderable,he as Renderable,_e as SilhouetteRenderable};
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{equals as r,binaryIndexOf as s}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import n from"../../../../../core/Logger.js";import{clamp as i}from"../../../../../core/mathUtils.js";import{disposeMaybe as o,destroyMaybe as a}from"../../../../../core/maybe.js";import{isAbortError as c,onAbortOrThrow as l}from"../../../../../core/promiseUtils.js";import{property as d}from"../../../../../core/accessorSupport/decorators/property.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as u,transpose as m,invert as g}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as f}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as p}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{i as _,c as b,a as y,f as j}from"../../../../../chunks/vec32.js";import{create as O,clone as w}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as E}from"../../../../../core/support/UpdatingHandles.js";import{a as v,g as x}from"../../../../../chunks/sphere.js";import{c as M}from"../../../../../chunks/vec33.js";import{ViewingMode as R}from"../../../../ViewingMode.js";import{encodeElevationOffset as T}from"../../collections/Component/Material/shader/ComponentData.glsl.js";import{TwoVectorPosition as A}from"../../core/util/TwoVectorPosition.js";import{Attribute as C}from"../Attribute.js";import{GridLocalOriginFactory as D}from"../GridLocalOriginFactory.js";import{applyToModelMatrix as P}from"../localOriginHelper.js";import{LocalOriginManager as U}from"../LocalOriginManager.js";import{Object3D as L}from"../Object3D.js";import{VertexArrayObject as k}from"../VertexArrayObject.js";import{VertexAttribute as I}from"../VertexAttribute.js";import{VertexLayout as S,EdgeInputBufferLayout as B,vertexAttributeLocations as V,glVertexLayout as q}from"./bufferLayouts.js";import{RegularEdgeBufferWriter as H,SilhouetteEdgeBufferWriter as G}from"./edgeBufferWriters.js";import{EdgeRenderer as N,lineWidthFractionFactor as W,extensionLengthOffset as z}from"./EdgeRenderer.js";import{EdgePassParameters as F}from"./EdgeShaderParameters.js";import{EdgeWorkerHandle as K}from"./EdgeWorkerHandle.js";import"./interfaces.js";import{generateStrokesTexture as J}from"./strokes.js";import{determineRendererType as Q,determineEdgeTransparency as X,determineObjectTransparency as Y,fillComponentBufferIndices as Z}from"./util.js";import{BufferManager as $}from"../TextureBackedBuffer/BufferManager.js";import{EdgeSilhouette as ee}from"../../shaders/sources/edgeRenderer/EdgeUtil.glsl.js";import{BufferObject as te}from"../../../../webgl/BufferObject.js";import{Usage as re}from"../../../../webgl/enums.js";const se=128;let ne=class extends t{constructor(e){super(e),this._updatingHandles=new E,this._objectEntries=new Map,this._pendingDeletions=new Map,this._renderers=new Map,this._gpuMemoryUsage=0,this._workerAbort=new AbortController,this._tmpModelPosition=O(),this._localOrigins=new U(new D(e.renderSR));const t=S.createBuffer(4);for(let r=0;r<4;r++)t.sideness.set(r,0,0===r||3===r?0:1),t.sideness.set(r,1,0===r||1===r?0:1);this._verticesBufferObject=te.createVertex(e.rctx,re.STATIC_DRAW,t.buffer)}initialize(){this._worker=new K(this.schedule),this._componentColorManager=new $(this.rctx,3)}destroy(){this.destroyed||(this._objectEntries.forEach((e=>this._discardObjectEntry(e))),this._objectEntries.clear(),this._pendingDeletions.forEach((e=>this._discardObjectEntry(e))),this._pendingDeletions.clear(),this._strokesTexture=o(this._strokesTexture),this._componentColorManager=a(this._componentColorManager),this._workerAbort.abort(),this._worker.destroy(),this._verticesBufferObject.dispose(),this._renderers.clear(),this._updatingHandles.destroy(),this._set("schedule",we))}get updating(){return this._updatingHandles.updating}get usedMemory(){return this._gpuMemoryUsage}shouldRender(){return this._renderers.size>0}async addComponentObject(e,t,r,s,n,i,o){if(this.hasObject(e))return this._getObjectMemoryUsage(e);let a;const c=new ae(null,new Promise((e=>a=e)),e.obb.center,e.obb.radius);this._objectEntries.set(e,c);const l=await this._updatingHandles.addPromise(this._addComponentGeometry(e.transform,c,t,r,s,n,i,o));return this.setNeedsRender(),a(),l}async addOrUpdateObject3D(e,t,r,s){if(this.destroyed)return void n.getLogger(this).warn("Attempt to add an object to a destroyed instance");const i=new AbortController;let o;const a=e.boundingVolumeWorldSpace.bounds,l=new ae(i,new Promise((e=>o=e)),v(a),x(a)),d=this._objectEntries.get(e);d&&(this._pendingDeletions.has(e)?this._discardObjectEntry(d):this._pendingDeletions.set(e,d)),this._objectEntries.set(e,l);try{const n=new Array;if(e.geometries.length>1&&oe(e))n.push(this._addObjectMergedGeometries(e,l,t,r,s));else for(const i of e.geometries)i.material.supportsEdges&&n.push(this._addGeometry(e,l,i,t,r,s));await this._updatingHandles.addPromise(Promise.all(n)),this._removePendingDeletion(e)}catch(h){c(h)?this._discardObjectEntry(l):this._removePendingDeletion(e)}finally{this.setNeedsRender(),o()}}removeObject(e){const t=this._objectEntries.get(e);this._objectEntries.delete(e),this._discardObjectEntry(t),this._removePendingDeletion(e)}_removePendingDeletion(e){const t=this._pendingDeletions.get(e);this._pendingDeletions.delete(e),this._discardObjectEntry(t)}async _getObjectEntry(e){const t=this._objectEntries.get(e);if(!t)throw new Error("no object");return await t.loaded,null==t.loaded?null:t}fastUpdateObject3DEdgesTransform(e){if(this.destroyed)return!1;const t=this._objectEntries.get(e);if(!t)return!1;const{geometries:r}=e,{renderables:s}=t;if(0===r.length||0===s.length)return!0;if(s.length>1)return!1;const[n]=s,i=n.transform;if(!(i instanceof de))return!1;const[o]=r;if(o.localOrigin!==i.origin.origin)return!1;const a=p(),c=this._computeModelTransformWithLocalOrigin(e,o,a);return n.transform=new de(a,c),this.setNeedsRender(),!0}_discardObjectEntry(e){e&&(e.abort?.abort(),e.renderables.length&&(e.renderables.forEach((e=>this._removeRenderable(e))),this.setNeedsRender()),e.loaded=null)}hasObject(e){return this._objectEntries.has(e)}async updateAllComponentOpacities(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));if(null==r)return;const s=Array.isArray(t)?e=>t[e]:()=>t;r.renderables.forEach((e=>{const t=e.components.meta.length;for(let r=0;r<t;r++){const t=s(r),n=e.components.meta[r],i=n.index;n.material.opacity=t,e.components.buffer.textureBuffer.setDataElement(i,1,3,255*t)}this._updateTransparency(e)})),this.setNeedsRender()}async _getObjectMemoryUsage(e){const t=await this._getObjectEntry(e);return t?t.renderables.reduce(((e,t)=>e+t.statistics.gpuMemoryUsage),0):0}async updateAllComponentMaterials(e,t,r,s){const n=e instanceof L,i=Q(t),o=N.getKey(i,r,n),a=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=a&&(a.renderables.forEach((e=>{if(o!==e.rendererKey){const t=this._renderers.get(e.rendererKey),s=this._acquireRenderer(i,r,n);t.removeRenderable(e),--t.refCount,e.rendererKey=o,s.addRenderable(e)}if(Array.isArray(t))for(let r=0;r<t.length;r++)e.components.meta[r].material=t[r];else e.components.meta[0].material=t;s&&me(e.components),this._updateTransparency(e)})),this.setNeedsRender())}async updateAllVerticalOffsets(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&this._updateAllVerticalOffsets(r,t)}_updateAllVerticalOffsets(e,t){e.renderables.forEach((e=>{const r=e.components.meta;for(let s=0;s<r.length;s++)e.components.meta[s].verticalOffset=t?.[s]??0;me(e.components)})),this.setNeedsRender()}async updateObjectVisibility(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));r&&(r.renderables.forEach((e=>e.visible=t)),this.setNeedsRender())}render(e,t){if(null==this._componentColorManager)return;this._localOrigins.updateViewMatrices(e.camera.viewMatrix);const r=e.camera.viewInverseTransposeMatrix,s=O(),n=new A;let i=0,o=0;if(this._renderers.forEach((r=>{0!==r.refCount?(++this.techniques.precompiling,r.forEachRenderable((t=>{t.visible&&(i+=t.statistics.averageEdgeLength,o++,t.regular&&r.acquireTechnique(e,!1).release(),t.silhouette&&r.acquireTechnique(e,!0).release())}),t),--this.techniques.precompiling):this._renderers.delete(r.key)})),this._componentColorManager.garbageCollect(),this._componentColorManager.updateTextures(),0===o)return;const a=new F(40*i/o,t);_(s,r[3],r[7],r[11]),n.set(s),b(a.transformWorldFromViewTH,n.high),b(a.transformWorldFromViewTL,n.low),u(a.transformViewFromCameraRelativeRS,e.camera.viewMatrix),m(Oe,a.transformViewFromCameraRelativeRS),g(a.transformNormalViewFromGlobal,Oe),a.transformProjFromView=e.camera.projectionMatrix,this._updateObjectCameraDistances(e),this._renderers.forEach((t=>{ge(t,e,a),fe(t,e,a)}))}_updateTransparency(e){const t=X(e.components.meta),r=Y(e.components.meta);t===e.edgeTransparency&&r===e.objectTransparency||(e.edgeTransparency=t,e.objectTransparency=r,this._renderers.get(e.rendererKey).setRenderablesDirty())}_computeModelTransformWithLocalOrigin(e,t,r){e.getCombinedShaderTransformation(t,r);const s=null!=t.localOrigin?this._localOrigins.register(t.localOrigin):this._localOrigins.acquire(_(this._tmpModelPosition,r[12],r[13],r[14]));return t.localOrigin=s.origin,P(s.origin.vec3,r),s}_createComponentBuffers(e){if(null==this._componentColorManager)return null;const t=new Array,r=this._componentColorManager.getBuffer(e.length);for(let n=0;n<e.length;n++){const s=e[n],i=r.acquireIndex();t.push({index:i,verticalOffset:0,material:s})}const s=new ce(r,t);return me(s),s}_extractEdges(e,t,r,s,n,i,o=i.length){return o<se&&(n=!0),this._worker.process({data:r,indices:i,indicesLength:o,writerSettings:t,skipDeduplicate:s},e,n)}_createRenderable(e,t,r,s,n){const i=t=>new le(new k(this.rctx,V,new Map([["vertices",q],["instances",t===ee.REGULAR?H.glLayout:G.glLayout]]),new Map([["vertices",this._verticesBufferObject],["instances",te.createVertex(this.rctx,re.STATIC_DRAW,t===ee.REGULAR?e.regular.instancesData.buffer:e.silhouette.instancesData.buffer)]])),t===ee.REGULAR?e.regular.lodInfo:e.silhouette.lodInfo),o=e.regular.lodInfo.lengths.length>0?i(ee.REGULAR):null,a=e.silhouette.lodInfo.lengths.length>0?i(ee.SILHOUETTE):null,c=(o?.vao.cachedMemory??0)+(a?.vao.cachedMemory??0);return new he(o,a,{gpuMemoryUsage:c,externalMemoryUsage:n,averageEdgeLength:e.averageEdgeLength},r,X(t.meta),Y(t.meta),t,s)}async _addGeometry(e,t,r,s,n,i){if(r.edgeIndicesLength<=0)return;const o=r.attributes.get(I.POSITION),a=p(),c=this._computeModelTransformWithLocalOrigin(e,r,a),l=new je(o,a,c);return this._addPositionData(t,l,r.edgeIndicesLength,s,n,i)}async _addPositionData(e,t,r,s,n,i=!1){if(null==e.loaded)return;const o=this._createComponentBuffers([s]);if(null==o)return;const a=this._acquireRenderer(s.type,n,!0),{modelTransform:c,origin:l}=t,d=t.position.indices,h=t.position,u=h.data.length/h.size,m=B.createBuffer(u);for(let p=0;p<u;p++)m.position.set(p,0,h.data[p*h.size]),m.position.set(p,1,h.data[p*h.size+1]),m.position.set(p,2,h.data[p*h.size+2]);Z(o.meta,[0,m.componentIndex.count],m.componentIndex);const g=await this._updatingHandles.addPromise(this._extractEdges(e.abort?.signal||this._workerAbort.signal,a.writerSettings,m,!1,i,d,r));if(null==e.loaded)return;const f=this._createRenderable(g,o,new de(c,l),a.key,!1);e.renderables.push(f),a.addRenderable(f),this._gpuMemoryUsage+=f.statistics.gpuMemoryUsage}async _addComponentGeometry(e,t,r,s,n,i,o,a){if(null==t.loaded)return 0;const c=this._createComponentBuffers(i);if(null==c)return 0;const l=Q(i),d=this._acquireRenderer(l,o||!1,!1),h=B.createBuffer(r.length/3);M(h.position.typedBuffer,r,h.position.typedBufferStride,3),Z(c.meta,n,h.componentIndex,s);const u=!0,m=d.writerSettings,g=await this._updatingHandles.addPromise(this._extractEdges(this._workerAbort.signal,m,h,u,!1,s));if(null==t.loaded)return 0;const f=this._createRenderable(g,c,e,d.key,!0);return t.renderables.push(f),d.addRenderable(f),this._updateAllVerticalOffsets(t,a),f.statistics.gpuMemoryUsage}async _addObjectMergedGeometries(e,t,r,s,n){const i=new Map;let o=0,a=0,c=null;const l=e.geometries.filter((e=>{if(e.edgeIndicesLength<=0||!e.material.supportsEdges)return!1;!c&&e.localOrigin&&(c=e);const t=e.attributes.get(I.POSITION);return a+=t.data.length/t.size,o+=e.edgeIndicesLength,!0}));if(0===l.length)return;const d=a>=65536?Uint32Array:Uint16Array,h=o?new d(o):null,u=[];let m=0;l.forEach((e=>{const t=e.attributes.get(I.POSITION),r=t.indices;let s=i.get(t.data);if(null==s){s=u.length/3;for(let e=0;e<t.data.length;e+=t.size)u.push(t.data[e]),u.push(t.data[e+1]),u.push(t.data[e+2]);i.set(t.data,s)}for(let n=0;n<e.edgeIndicesLength;n++)h[m++]=s+r[n]}));const g=c||e.geometries[0],f=p(),_=this._computeModelTransformWithLocalOrigin(e,g,f);for(let p=0;p<e.geometries.length;p++)e.geometries[p].localOrigin=_.origin;const b=new je(new C(u,h,3),f,_);await this._updatingHandles.addPromise(this._addPositionData(t,b,h.length,r,s,n))}_acquireRenderer(e,t,r){const s=N.getKey(e,t,r);let n=this._renderers.get(s);return null==this._strokesTexture&&(this._strokesTexture=J(this.rctx)),n||(n=new N(this.rctx,this.techniques,{type:e,hasSlicePlane:t,strokesTexture:this._strokesTexture,legacy:r,spherical:this.viewingMode===R.Global}),this._renderers.set(s,n)),++n.refCount,n}_removeRenderable(e){ie(e.regular),ie(e.silhouette);const t=this._renderers.get(e.rendererKey);if(t){t.removeRenderable(e),--t.refCount,this._localOrigins.release(e.transform.origin),this._gpuMemoryUsage-=e.statistics.externalMemoryUsage?0:e.statistics.gpuMemoryUsage;for(const t of e.components.meta)e.components.buffer.releaseIndex(t.index)}}_updateObjectCameraDistances(e){const t=e.camera.eye,r=e.camera.viewForward,s=O(),n=e=>{y(s,e.center,t);const n=j(s,r),i=e.radius,o=n<-i?1/0:n<i?0:n-i;e.renderables.forEach((e=>e.distanceToCamera=o))};this._objectEntries.forEach(n),this._pendingDeletions.forEach(n)}get test(){}};function ie(e){e?.vao&&(e.vao.vertexBuffers.get("instances")?.dispose(),e.vao.disposeVAOOnly(),e.vao=null)}function oe(e){let t=null,s=null;for(const n of e.geometries){if(n.material.supportsEdges){if(t){if(!r(t,n.transformation))return!1}else t=n.transformation;if(s||null==n.localOrigin){if(null!=s?.localOrigin&&null!=n.localOrigin&&s.localOrigin.id!==n.localOrigin.id)return!1}else s=n}}return!0}e([d({constructOnly:!0})],ne.prototype,"rctx",void 0),e([d({constructOnly:!0})],ne.prototype,"renderSR",void 0),e([d({constructOnly:!0})],ne.prototype,"viewingMode",void 0),e([d({constructOnly:!0})],ne.prototype,"techniques",void 0),e([d({constructOnly:!0})],ne.prototype,"setNeedsRender",void 0),e([d({constructOnly:!0})],ne.prototype,"schedule",void 0),e([d({readOnly:!0})],ne.prototype,"_updatingHandles",void 0),e([d({readOnly:!0})],ne.prototype,"updating",null),ne=e([h("esri.views.3d.webgl-engine.lib.edgeRendering.EdgeView")],ne);class ae{constructor(e,t,r,s){this.abort=e,this.radius=s,this.renderables=new Array;const n=e?l(e.signal,(()=>e.abort())):null;this.loaded=t,this.loaded.then((()=>{null!=this.loaded&&(this.loaded=!0),this.abort=null,n?.remove()})),this.center=w(r)}}class ce{constructor(e,t){this.buffer=e,this.meta=t}}class le{constructor(e,t){this.vao=e,this.lod=t}}class de{constructor(e,t){this.modelMatrix=e,this.origin=t}}class he{constructor(e,t,r,s,n,i,o,a){this.regular=e,this.silhouette=t,this.statistics=r,this.transform=s,this.edgeTransparency=n,this.objectTransparency=i,this.components=o,this.rendererKey=a,this.distanceToCamera=0,this.visible=!0}}class ue extends he{}function me(e){const{meta:t,buffer:r}=e,s=new Uint8Array(4);for(let n=0;n<t.length;n++){const e=t[n].material,o=t[n].index,a=i(Math.round(e.size*W),0,255),c=i(e.extensionLength,-z,255-z)+z,l=255*e.opacity,d=e.color,h=255*d[0],u=255*d[1],m=255*d[2],g=255*d[3];r.textureBuffer.setData(o,0,h,u,m,g),r.textureBuffer.setData(o,1,a,c,e.type,l),T(t[n].verticalOffset,s),r.textureBuffer.setData(o,2,s[0],s[1],s[2],s[3])}}function ge(e,t,r){let s,n;const i=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((i=>{if(!pe(i)||!i.visible)return;s??=e.acquireTechnique(t,!1),n??=e.rctx.bindTechnique(s,t,r);const a=ye(i.regular.lod.lengths,i.distanceToCamera,o);e.renderRegularEdges(n,i,r,t,a)}),i),s?.release()}function fe(e,t,r){let s,n;const i=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((i=>{if(!be(i)||!i.visible)return;s??=e.acquireTechnique(t,!0),n??=e.rctx.bindTechnique(s,t,r);const a=ye(i.silhouette.lod.lengths,i.distanceToCamera,o);e.renderSilhouetteEdges(n,i,r,t,a)}),i),s?.release()}function pe(e){return null!=e.regular}class _e extends he{}function be(e){return null!=e.silhouette}function ye(e,t,r){const n=t*r,i=s(e,n,!0);return-1===i?n<e[0]?e.length:0:e.length-i}class je{constructor(e,t,r){this.position=e,this.modelTransform=t,this.origin=r}}const Oe=f(),we=()=>Promise.reject();export{ne as EdgeView,de as LegacyTransform,ue as RegularRenderable,he as Renderable,_e as SilhouetteRenderable};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{generateUID as e}from"../../../../core/uid.js";class t{constructor(t,r,s){this._createTexture=t,this._parametersKey=r,this._repository=new Map,this._orphanCache=s.newCache(`procedural-texture-repository:${e()}`,(e=>e.dispose()))}destroy(){for(const{texture:e}of this._repository.values())e.dispose();this._repository.clear(),this._orphanCache.destroy()}swap(e,t=null){const r=this._acquire(e);return this.release(t),r}release(e){if(null==e)return;const t=this._parametersKey(e),r=this._repository.get(t);if(r&&(r.refCount--,0===r.refCount)){this._repository.delete(t);const{texture:e}=r
|
|
5
|
+
import{generateUID as e}from"../../../../core/uid.js";class t{constructor(t,r,s){this._createTexture=t,this._parametersKey=r,this._repository=new Map,this._orphanCache=s.newCache(`procedural-texture-repository:${e()}`,(e=>e.dispose()))}destroy(){for(const{texture:e}of this._repository.values())e.dispose();this._repository.clear(),this._orphanCache.destroy()}swap(e,t=null){const r=this._acquire(e);return this.release(t),r}release(e){if(null==e)return;const t=this._parametersKey(e),r=this._repository.get(t);if(r&&(r.refCount--,0===r.refCount)){this._repository.delete(t);const{texture:e}=r;this._orphanCache.put(t,e)}}_acquire(e){if(null==e)return null;const t=this._parametersKey(e),s=this._repository.get(t);if(s)return s.refCount++,s.texture;const o=this._orphanCache.pop(t)??this._createTexture(e),i=new r(o);return this._repository.set(t,i),o}}class r{constructor(e){this.texture=e,this.refCount=1}}export{t as ProceduralTextureRepository};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{removeUnordered as t,filterInPlace as r}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{nextHighestPowerOfTwo as i}from"../../../../../core/mathUtils.js";import{disposeMaybe as s}from"../../../../../core/maybe.js";import{NestedMap as o}from"../../../../../core/NestedMap.js";import a from"../../../../../core/PooledArray.js";import{addMany as n}from"../../../../../core/SetUtils.js";import{property as l}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import{subclass as u}from"../../../../../core/accessorSupport/decorators/subclass.js";import{copy as h,invert as f,transpose as c}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{glLayout as d}from"../../../support/buffer/glUtil.js";import{ShaderOutput as g}from"../../core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as p}from"../../effects/RenderPlugin.js";import{GLMaterials as y}from"../../lib/GLMaterials.js";import{DirtyState as _}from"../../lib/ModelDirtyTypes.js";import{RenderSlot as b}from"../../lib/RenderSlot.js";import{assert as w}from"../../lib/Util.js";import{DrawParameters as v}from"../DrawParameters.js";import{BufferRange as C,mergeAdjacentRanges as O}from"./BufferRange.js";import{Instance as A}from"./Instance.js";import{PerBufferData as E,hasVao as B}from"./PerBufferData.js";import{PerOriginData as S}from"./PerOriginData.js";let x=class extends p{get _hasAnyHighlight(){return this._highlightGroups.size>0}constructor(e){super(e),this._dataByOrigin=new Map,this._drawParameters=new v,this._highlightGroups=new Set,this.drapedPriority=0,this._produces=new Map,this._hasOccludees=!1}destroy(){this._glMaterials=s(this._glMaterials),this._dataByOrigin.forEach((e=>e.dispose())),this._dataByOrigin.clear(),this._vaoCache=null}initialize(){this.material.produces.forEach(((e,t)=>{this._produces.set(t,(t=>!(0===this._dataByOrigin.size||!(t!==g.Highlight&&t!==g.ShadowHighlight||this._hasAnyHighlight))&&e(t)))}))}initializeRenderContext(e,t){this._glMaterials=new y(this.material,t??e.materials),this._bufferWriter=this.material.createBufferWriter(),this._vaoCache=e.renderContext.rctx.getVaoCache(this.material.vertexAttributeLocations,d(this._bufferWriter.vertexBufferLayout))}uninitializeRenderContext(){}get produces(){return this._produces}get hasOccludees(){return this._hasOccludees}get hasEmissions(){return this.material.hasEmissions}get isDecoration(){return this.material.parameters.isDecoration}queryRenderOccludedState(e){return this.material.queryRenderOccludedState(e)}get numGeometries(){let e=0;return this._dataByOrigin.forEach((t=>e+=t.buffers.reduce(((e,t)=>e+t.instances.size),0))),e}get usedMemory(){let e=0;return this._dataByOrigin.forEach((t=>e+=t.buffers.reduce(((e,t)=>e+t.vao.usedMemory),0))),e}forEachGeometry(e){this._dataByOrigin.forEach((t=>t.buffers.forEach((t=>t.instances.forEach((({geometry:t})=>e(t)))))))}modify(e){this._updateGeometries(e.updates),this._addAndRemoveGeometries(e.adds,e.removes),this._updateDrawCommands()}_updateGeometries(e){const t=this._bufferWriter;if(null==t)return;const r=t.vertexBufferLayout.stride/4;for(const i of e){const e=i.renderGeometry,s=this._dataByOrigin.get(e.localOrigin.id),o=s?.findBuffer(e.id);if(null==o)return;const a=o.instances.get(e.id);if(i.updateType&(_.GEOMETRY|_.TRANSFORMATION)){const i=W(t.elementCount(a.geometry.geometry.attributes)*r),s=t.vertexBufferLayout.createView(i.buffer);this._writeGeometry(e,s,0),o.vao.vertexBuffers.get("geometry").setSubData(i,a.from*r,0,a.numElements*r)}i.updateType&(_.HIGHLIGHT|_.OCCLUDEE|_.VISIBILITY)&&(o.drawCommandsDirty=!0)}}_computeDeltas(e,t){const r=new o;for(const i of e){const e=i.localOrigin;if(null==e)continue;let t=r.get(e.id,null);null==t&&(t=new D(e.vec3),r.set(e.id,null,t)),t.changes.push(i)}for(const i of t){const e=i.localOrigin;if(null==e)continue;const t=this._dataByOrigin.get(e.id),s=t?.findBuffer(i.id);if(null==s)continue;let o=r.get(e.id,s);null==o&&(o=new D(e.vec3),r.set(e.id,s,o)),o.changes.push(i)}return r}_addAndRemoveGeometries(e,r){if(null==this._bufferWriter||null==this._vaoCache)return;const{_bufferWriter:i,_dataByOrigin:s}=this,o=i.vertexBufferLayout.stride/4,a=this._computeDeltas(e,r);a.forEach(((e,r)=>{const n=e.get(null),l=n?.changes??[];a.delete(r,null);let u=s.get(r);if(e.forEach(((e,n)=>{if(a.delete(r,n),null==n)return void w(!1,"No VAO for removed geometries");if(n.instances.size===e.changes.length)return this._vaoCache.deleteVao(n.vao),t(u.buffers,n),void(0===u.buffers.length&&0===l.length&&s.delete(r));const h=n.numElements,f=n.vao.byteSize/4,c=l.reduce(((e,t)=>e+i.elementCount(t.geometry.attributes)),0),m=e.changes.reduce(((e,t)=>e+i.elementCount(t.geometry.attributes)),0),d=Math.min((h+c-m)*o,z),g=d>f;d>G&&d<f/2?(e.changes.forEach((({id:e})=>n.deleteInstance(e))),n.instances.forEach((({geometry:e})=>l.push(e))),this._vaoCache.deleteVao(n.vao),t(u.buffers,n)):g?this._applyAndRebuild(n,l,e):this._applyRemoves(n,e)})),l.length>0)for(null==u&&(u=new S(n.origin),s.set(r,u)),u.buffers.forEach((e=>this._applyAdds(e,l)));l.length>0;)u.buffers.push(this._applyAndRebuild(new E,l,null))}))}_updateDrawCommands(){this._highlightGroups.clear(),this._hasOccludees=!1,this._dataByOrigin.forEach((e=>{e.buffers.forEach((e=>{e.updateIfDrawCommandsDirty(this._bufferWriter.vertexBufferLayout.stride),e.hasHighlights&&n(this._highlightGroups,e.highlightGroups),this._hasOccludees=this._hasOccludees||e.hasOccludees}))}))}_applyAndRebuild(e,t,r){if(r)for(const m of r.changes)e.deleteInstance(m.id);const i=this._bufferWriter,s=i.vertexBufferLayout.stride,o=s/4,a=Math.floor(z/o);let n=e.numElements;for(;t.length>0;){const r=t.pop(),s=i.elementCount(r.geometry.attributes);if(n+s>a&&n>0){t.push(r);break}n+=s;const o=new A(r,0,0);w(null==e.instances.get(r.id)),e.addInstance(r.id,o)}const l=n*o,u=W(l),h=i.vertexBufferLayout.createView(u.buffer);let f=0;e.resetInstanceSummary(),e.instances.forEach(((t,r)=>{this._writeGeometry(t.geometry,h,f);const s=f;f+=i.elementCount(t.geometry.geometry.attributes),e.updateInstance(r,s,f),e.updateDrawState(t)})),this._vaoCache.deleteVao(e.vao),e.vao=this._vaoCache.newVao(V(l)),e.vao.vertexBuffers.get("geometry").setSubData(u,0,0,f*o),e.holes.clear();const c=e.holes.pushNew();return c.from=f,c.to=Math.floor(e.vao.byteSize/s),e.updateDrawCommands(s),e}_applyRemoves(e,t){if(0===t.changes.length||null==this._bufferWriter)return;for(const a of t.changes){const t=a.id,r=e.instances.get(t);if(!r)continue;e.deleteInstance(t);const i=H.back();if(i){if(i.to===r.from){i.to=r.to;continue}if(i.from===r.to){i.from=r.from;continue}}const s=H.pushNew();s.from=r.from,s.to=r.to}O(H);const r=this._bufferWriter.vertexBufferLayout.stride/4,i=H.reduce(((e,t)=>Math.max(e,t.numElements)),0)*r,s=W(i);s.fill(0,0,i);const o=e.vao.vertexBuffers.get("geometry");H.forAll((e=>o.setSubData(s,e.from*r,0,e.numElements*r))),e.holes.pushArray(H.data,H.length),H.forAll(((e,t)=>H.data[t]=null)),H.clear(),e.drawCommandsDirty=!0}_applyAdds(e,t){if(0===t.length||null==this._bufferWriter)return;if(!B(e))return void this._applyAndRebuild(e,t,null);const i=this._bufferWriter,s=i.vertexBufferLayout.stride/4,o=e.numElements,a=t.reduce(((e,t)=>e+i.elementCount(t.geometry.attributes)),0),n=Math.min((o+a)*s,z),l=4*n;if(e.vao.byteSize<V(z-G)&&l>e.vao.byteSize)return void this._applyAndRebuild(e,t,null);O(e.holes);const u=new Array;for(const r of t){const t=i.elementCount(r.geometry.attributes),s=R(e.holes,t);u.push(s)}const h=e.vao.vertexBuffers.get("geometry");let f=0,c=0,m=0;const d=W(n),g=i.vertexBufferLayout.createView(d.buffer);t.forEach(((t,r)=>{const o=u[r];if(null==o)return;if(!(m===o)){const e=m-c;e>0&&h.setSubData(d,c*s,0,e*s),c=o,f=0}const a=i.elementCount(t.geometry.attributes);this._writeGeometry(t,g,f),f+=a,m=o+a;const n=new A(t,o,o+a);w(null==e.instances.get(t.id)),e.addInstance(t.id,n),e.drawCommandsDirty=!0}));const p=m-c;p>0&&h.setSubData(d,c*s,0,p*s),r(t,((e,t)=>null==u[t]))}_writeGeometry(e,t,r){null!=this._bufferWriter&&(h(j,e.transformation),j[12]-=e.localOrigin.vec3[0],j[13]-=e.localOrigin.vec3[1],j[14]-=e.localOrigin.vec3[2],f(M,j),c(M,M),this._bufferWriter.write(j,M,e.geometry.attributes,e.geometry.objectAndLayerIdColor,t,r))}updateAnimation(e){return this.material.update(e)}acquireTechniques(e){if(!this.material.shouldRender(e))return null;const{output:t,bind:r}=e,i=this.material.produces.get(r.slot);if(!i?.(t))return null;const{highlight:s,slot:o}=r,a=t===g.ShadowHighlight,n=t===g.Highlight,l=n||a,u=s?.name,h=e=>l&&(0===this._highlightGroups.size||n&&!!u&&!e.has(u));if(h(this._highlightGroups))return null;const f=t===g.ShadowExcludeHighlight,c=!(l||f);for(const{buffers:m}of this._dataByOrigin.values())for(const i of m){if(h(i.highlightGroups))continue;const s=a?i.drawCommandsHighlights.size>0:l?u?i.drawCommandsHighlights.get(u):i.drawCommandsHighlights.size>0:((f&&i.needsMultipleCommands()?i.drawCommandsShadowHighlightRest:i.drawCommandsDefault)||null)?.length??!1,n=c&&i.drawCommandsOccludees||null;if(s||n?.length){const i=this._glMaterials.load(e.rctx,o,t),s=i?.beginSlot(r);if(s)return s}}return null}render(e,t){const{output:r,bind:i}=e,{slot:s,highlight:o}=i,a=r===g.Highlight,n=o?.name??"";if(a&&!o)return;const l=r===g.ShadowHighlight,u=a||l,h=r===g.ShadowExcludeHighlight,f=!(u||h),c=s===b.OCCLUDER_MATERIAL||s===b.TRANSPARENT_OCCLUDER_MATERIAL?s:null,{rctx:m}=e;m.runAppleAmdDriverHelper();const d=m.bindTechnique(t,i,this.material.parameters);for(const g of this._dataByOrigin.values())for(const e of g.buffers){if(a&&(!e.hasHighlights||!e.drawCommandsHighlights.has(n)))continue;if(l&&!e.hasHighlights)continue;const r=()=>{const t=[];for(const r of e.drawCommandsHighlights.values())t.push(r);return t},s=u&&!l?e.drawCommandsHighlights.get(n)??null:null,o=l?r():u?s?[s]:U:(h&&e.needsMultipleCommands()?[e.drawCommandsShadowHighlightRest]:[e.drawCommandsDefault])||U,p=o.some((e=>e.length>0)),y=f&&e.drawCommandsOccludees||null;if(p||y?.length){if(this._drawParameters.origin=g.origin,d.bindDraw(i,this.material.parameters,this._drawParameters),t.ensureAttributeLocations(e.vao),m.bindVAO(e.vao),p)for(const e of o)m.setPipelineState(t.getPipeline(!1,c)),e.forAll((e=>m.drawArrays(t.primitiveType,e.first,e.count)));y?.length&&(m.setPipelineState(t.getPipeline(!0,c)),y.forAll((e=>m.drawArrays(t.primitiveType,e.first,e.count))))}}}get test(){}};e([l({constructOnly:!0})],x.prototype,"material",void 0),x=e([u("esri.views.3d.webgl-engine.materials.renderers.MergedRenderer")],x);class D{constructor(e){this.origin=e,this.changes=new Array}}function R(e,t){const r=e.find((e=>e.numElements>=t));if(null==r)return null;const i=r.from;return r.from+=t,r.from>=r.to&&e.removeUnordered(r),i}const j=m(),M=m(),H=new a({allocator:e=>e||new C,deallocator:null}),G=65536,L=4*G,I=1024,T=16777216,z=T/4;let P=new Float32Array(G);function W(e){return P.length<e&&(P=new Float32Array(e)),P}function V(e){const t=4*e;return t<=I?I:t<L?i(t):Math.max(Math.min(Math.ceil(1.5*t/L)*L,T),t)}const U=[];export{x as MergedRenderer,V as sizeForVao};
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{removeUnordered as t,filterInPlace as r}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{nextHighestPowerOfTwo as i}from"../../../../../core/mathUtils.js";import{disposeMaybe as s}from"../../../../../core/maybe.js";import{NestedMap as o}from"../../../../../core/NestedMap.js";import a from"../../../../../core/PooledArray.js";import{addMany as n}from"../../../../../core/SetUtils.js";import{property as l}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/Logger.js";import{subclass as u}from"../../../../../core/accessorSupport/decorators/subclass.js";import{copy as h,invert as c,transpose as f}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{glLayout as d}from"../../../support/buffer/glUtil.js";import{ShaderOutput as g}from"../../core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as p}from"../../effects/RenderPlugin.js";import{GLMaterials as y}from"../../lib/GLMaterials.js";import{DirtyState as _}from"../../lib/ModelDirtyTypes.js";import{RenderSlot as b}from"../../lib/RenderSlot.js";import{assert as w}from"../../lib/Util.js";import{DrawParameters as v}from"../DrawParameters.js";import{BufferRange as C,mergeAdjacentRanges as O}from"./BufferRange.js";import{Instance as A}from"./Instance.js";import{PerBufferData as E,hasVao as B}from"./PerBufferData.js";import{PerOriginData as S}from"./PerOriginData.js";let x=class extends p{get _hasAnyHighlight(){return this._highlightGroups.size>0}constructor(e){super(e),this._dataByOrigin=new Map,this._drawParameters=new v,this._highlightGroups=new Set,this.drapedPriority=0,this._produces=new Map,this._hasOccludees=!1}destroy(){this._glMaterials=s(this._glMaterials),this._dataByOrigin.forEach((e=>e.dispose())),this._dataByOrigin.clear(),this._vaoCache=null}initialize(){this.material.produces.forEach(((e,t)=>{this._produces.set(t,(t=>!(0===this._dataByOrigin.size||!(t!==g.Highlight&&t!==g.ShadowHighlight||this._hasAnyHighlight))&&e(t)))}))}initializeRenderContext(e,t){this._glMaterials=new y(this.material,t??e.materials),this._bufferWriter=this.material.createBufferWriter(),this._vaoCache=e.renderContext.rctx.getVaoCache(this.material.vertexAttributeLocations,d(this._bufferWriter.vertexBufferLayout))}uninitializeRenderContext(){}get produces(){return this._produces}get hasOccludees(){return this._hasOccludees}get hasEmissions(){return this.material.hasEmissions}get isDecoration(){return this.material.parameters.isDecoration}queryRenderOccludedState(e){return this.material.queryRenderOccludedState(e)}get numGeometries(){let e=0;return this._dataByOrigin.forEach((t=>e+=t.buffers.reduce(((e,t)=>e+t.instances.size),0))),e}get usedMemory(){let e=0;return this._dataByOrigin.forEach((t=>e+=t.buffers.reduce(((e,t)=>e+t.vao.cachedMemory),0))),e}forEachGeometry(e){this._dataByOrigin.forEach((t=>t.buffers.forEach((t=>t.instances.forEach((({geometry:t})=>e(t)))))))}modify(e){this._updateGeometries(e.updates),this._addAndRemoveGeometries(e.adds,e.removes),this._updateDrawCommands()}_updateGeometries(e){const t=this._bufferWriter;if(null==t)return;const r=t.vertexBufferLayout.stride/4;for(const i of e){const e=i.renderGeometry,s=this._dataByOrigin.get(e.localOrigin.id),o=s?.findBuffer(e.id);if(null==o)return;const a=o.instances.get(e.id);if(i.updateType&(_.GEOMETRY|_.TRANSFORMATION)){const i=W(t.elementCount(a.geometry.geometry.attributes)*r),s=t.vertexBufferLayout.createView(i.buffer);this._writeGeometry(e,s,0),o.vao.vertexBuffers.get("geometry").setSubData(i,a.from*r,0,a.numElements*r)}i.updateType&(_.HIGHLIGHT|_.OCCLUDEE|_.VISIBILITY)&&(o.drawCommandsDirty=!0)}}_computeDeltas(e,t){const r=new o;for(const i of e){const e=i.localOrigin;if(null==e)continue;let t=r.get(e.id,null);null==t&&(t=new D(e.vec3),r.set(e.id,null,t)),t.changes.push(i)}for(const i of t){const e=i.localOrigin;if(null==e)continue;const t=this._dataByOrigin.get(e.id),s=t?.findBuffer(i.id);if(null==s)continue;let o=r.get(e.id,s);null==o&&(o=new D(e.vec3),r.set(e.id,s,o)),o.changes.push(i)}return r}_addAndRemoveGeometries(e,r){if(null==this._bufferWriter||null==this._vaoCache)return;const{_bufferWriter:i,_dataByOrigin:s}=this,o=i.vertexBufferLayout.stride/4,a=this._computeDeltas(e,r);a.forEach(((e,r)=>{const n=e.get(null),l=n?.changes??[];a.delete(r,null);let u=s.get(r);if(e.forEach(((e,n)=>{if(a.delete(r,n),null==n)return void w(!1,"No VAO for removed geometries");if(n.instances.size===e.changes.length)return this._vaoCache.deleteVao(n.vao),t(u.buffers,n),void(0===u.buffers.length&&0===l.length&&s.delete(r));const h=n.numElements,c=n.vao.byteSize/4,f=l.reduce(((e,t)=>e+i.elementCount(t.geometry.attributes)),0),m=e.changes.reduce(((e,t)=>e+i.elementCount(t.geometry.attributes)),0),d=Math.min((h+f-m)*o,z),g=d>c;d>G&&d<c/2?(e.changes.forEach((({id:e})=>n.deleteInstance(e))),n.instances.forEach((({geometry:e})=>l.push(e))),this._vaoCache.deleteVao(n.vao),t(u.buffers,n)):g?this._applyAndRebuild(n,l,e):this._applyRemoves(n,e)})),l.length>0)for(null==u&&(u=new S(n.origin),s.set(r,u)),u.buffers.forEach((e=>this._applyAdds(e,l)));l.length>0;)u.buffers.push(this._applyAndRebuild(new E,l,null))}))}_updateDrawCommands(){this._highlightGroups.clear(),this._hasOccludees=!1,this._dataByOrigin.forEach((e=>{e.buffers.forEach((e=>{e.updateIfDrawCommandsDirty(this._bufferWriter.vertexBufferLayout.stride),e.hasHighlights&&n(this._highlightGroups,e.highlightGroups),this._hasOccludees=this._hasOccludees||e.hasOccludees}))}))}_applyAndRebuild(e,t,r){if(r)for(const m of r.changes)e.deleteInstance(m.id);const i=this._bufferWriter,s=i.vertexBufferLayout.stride,o=s/4,a=Math.floor(z/o);let n=e.numElements;for(;t.length>0;){const r=t.pop(),s=i.elementCount(r.geometry.attributes);if(n+s>a&&n>0){t.push(r);break}n+=s;const o=new A(r,0,0);w(null==e.instances.get(r.id)),e.addInstance(r.id,o)}const l=n*o,u=W(l),h=i.vertexBufferLayout.createView(u.buffer);let c=0;e.resetInstanceSummary(),e.instances.forEach(((t,r)=>{this._writeGeometry(t.geometry,h,c);const s=c;c+=i.elementCount(t.geometry.geometry.attributes),e.updateInstance(r,s,c),e.updateDrawState(t)})),this._vaoCache.deleteVao(e.vao),e.vao=this._vaoCache.newVao(V(l)),e.vao.vertexBuffers.get("geometry").setSubData(u,0,0,c*o),e.holes.clear();const f=e.holes.pushNew();return f.from=c,f.to=Math.floor(e.vao.byteSize/s),e.updateDrawCommands(s),e}_applyRemoves(e,t){if(0===t.changes.length||null==this._bufferWriter)return;for(const a of t.changes){const t=a.id,r=e.instances.get(t);if(!r)continue;e.deleteInstance(t);const i=H.back();if(i){if(i.to===r.from){i.to=r.to;continue}if(i.from===r.to){i.from=r.from;continue}}const s=H.pushNew();s.from=r.from,s.to=r.to}O(H);const r=this._bufferWriter.vertexBufferLayout.stride/4,i=H.reduce(((e,t)=>Math.max(e,t.numElements)),0)*r,s=W(i);s.fill(0,0,i);const o=e.vao.vertexBuffers.get("geometry");H.forAll((e=>o.setSubData(s,e.from*r,0,e.numElements*r))),e.holes.pushArray(H.data,H.length),H.forAll(((e,t)=>H.data[t]=null)),H.clear(),e.drawCommandsDirty=!0}_applyAdds(e,t){if(0===t.length||null==this._bufferWriter)return;if(!B(e))return void this._applyAndRebuild(e,t,null);const i=this._bufferWriter,s=i.vertexBufferLayout.stride/4,o=e.numElements,a=t.reduce(((e,t)=>e+i.elementCount(t.geometry.attributes)),0),n=Math.min((o+a)*s,z),l=4*n;if(e.vao.byteSize<V(z-G)&&l>e.vao.byteSize)return void this._applyAndRebuild(e,t,null);O(e.holes);const u=new Array;for(const r of t){const t=i.elementCount(r.geometry.attributes),s=R(e.holes,t);u.push(s)}const h=e.vao.vertexBuffers.get("geometry");let c=0,f=0,m=0;const d=W(n),g=i.vertexBufferLayout.createView(d.buffer);t.forEach(((t,r)=>{const o=u[r];if(null==o)return;if(!(m===o)){const e=m-f;e>0&&h.setSubData(d,f*s,0,e*s),f=o,c=0}const a=i.elementCount(t.geometry.attributes);this._writeGeometry(t,g,c),c+=a,m=o+a;const n=new A(t,o,o+a);w(null==e.instances.get(t.id)),e.addInstance(t.id,n),e.drawCommandsDirty=!0}));const p=m-f;p>0&&h.setSubData(d,f*s,0,p*s),r(t,((e,t)=>null==u[t]))}_writeGeometry(e,t,r){null!=this._bufferWriter&&(h(j,e.transformation),j[12]-=e.localOrigin.vec3[0],j[13]-=e.localOrigin.vec3[1],j[14]-=e.localOrigin.vec3[2],c(M,j),f(M,M),this._bufferWriter.write(j,M,e.geometry.attributes,e.geometry.objectAndLayerIdColor,t,r))}updateAnimation(e){return this.material.update(e)}acquireTechniques(e){if(!this.material.shouldRender(e))return null;const{output:t,bind:r}=e,i=this.material.produces.get(r.slot);if(!i?.(t))return null;const{highlight:s,slot:o}=r,a=t===g.ShadowHighlight,n=t===g.Highlight,l=n||a,u=s?.name,h=e=>l&&(0===this._highlightGroups.size||n&&!!u&&!e.has(u));if(h(this._highlightGroups))return null;const c=t===g.ShadowExcludeHighlight,f=!(l||c);for(const{buffers:m}of this._dataByOrigin.values())for(const i of m){if(h(i.highlightGroups))continue;const s=a?i.drawCommandsHighlights.size>0:l?u?i.drawCommandsHighlights.get(u):i.drawCommandsHighlights.size>0:((c&&i.needsMultipleCommands()?i.drawCommandsShadowHighlightRest:i.drawCommandsDefault)||null)?.length??!1,n=f&&i.drawCommandsOccludees||null;if(s||n?.length){const i=this._glMaterials.load(e.rctx,o,t),s=i?.beginSlot(r);if(s)return s}}return null}render(e,t){const{output:r,bind:i}=e,{slot:s,highlight:o}=i,a=r===g.Highlight,n=o?.name??"";if(a&&!o)return;const l=r===g.ShadowHighlight,u=a||l,h=r===g.ShadowExcludeHighlight,c=!(u||h),f=s===b.OCCLUDER_MATERIAL||s===b.TRANSPARENT_OCCLUDER_MATERIAL?s:null,{rctx:m}=e;m.runAppleAmdDriverHelper();const d=m.bindTechnique(t,i,this.material.parameters);for(const g of this._dataByOrigin.values())for(const e of g.buffers){if(a&&(!e.hasHighlights||!e.drawCommandsHighlights.has(n)))continue;if(l&&!e.hasHighlights)continue;const r=()=>{const t=[];for(const r of e.drawCommandsHighlights.values())t.push(r);return t},s=u&&!l?e.drawCommandsHighlights.get(n)??null:null,o=l?r():u?s?[s]:U:(h&&e.needsMultipleCommands()?[e.drawCommandsShadowHighlightRest]:[e.drawCommandsDefault])||U,p=o.some((e=>e.length>0)),y=c&&e.drawCommandsOccludees||null;if(p||y?.length){if(this._drawParameters.origin=g.origin,d.bindDraw(i,this.material.parameters,this._drawParameters),t.ensureAttributeLocations(e.vao),m.bindVAO(e.vao),p)for(const e of o)m.setPipelineState(t.getPipeline(!1,f)),e.forAll((e=>m.drawArrays(t.primitiveType,e.first,e.count)));y?.length&&(m.setPipelineState(t.getPipeline(!0,f)),y.forAll((e=>m.drawArrays(t.primitiveType,e.first,e.count))))}}}get test(){}};e([l({constructOnly:!0})],x.prototype,"material",void 0),x=e([u("esri.views.3d.webgl-engine.materials.renderers.MergedRenderer")],x);class D{constructor(e){this.origin=e,this.changes=new Array}}function R(e,t){const r=e.find((e=>e.numElements>=t));if(null==r)return null;const i=r.from;return r.from+=t,r.from>=r.to&&e.removeUnordered(r),i}const j=m(),M=m(),H=new a({allocator:e=>e||new C,deallocator:null}),G=65536,L=4*G,I=1024,T=16777216,z=T/4;let P=new Float32Array(G);function W(e){return P.length<e&&(P=new Float32Array(e)),P}function V(e){const t=4*e;return t<=I?I:t<L?i(t):Math.max(Math.min(Math.ceil(1.5*t/L)*L,T),t)}const U=[];export{x as MergedRenderer,V as sizeForVao};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"
|
|
5
|
+
import"../core/shaderLibrary/ScreenSpacePass.glsl.js";import"../core/shaderLibrary/output/ReadDepth.glsl.js";import"../core/shaderModules/Float2DrawUniform.js";import"../core/shaderModules/FloatPassUniform.js";import"../core/shaderModules/interfaces.js";import"../core/shaderModules/ShaderBuilder.js";import"../core/shaderModules/Texture2DDrawUniform.js";import"../core/shaderModules/Texture2DPassUniform.js";export{b as build}from"../../../../chunks/SSAOBlur.glsl.js";
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"../../core/has.js";import{destroyMaybe as e}from"../../core/maybe.js";import{GamepadSource as t}from"./gamepad/GamepadSource.js";import{createScreenPointFromNativeEvent as n}from"../support/screenUtils.js";const i=has("edge"),a=has("chrome"),o=has("ff"),s=has("safari"),r="esri-view-surface",h={touchNone:`${r}--touch-none`,touchPan:`${r}--touch-pan`};class l{constructor(e,n){this._input=n,this._active={},this._callback=()=>{},this._activePointerCaptures=new Set,this._keyDownState=new Set,this._eventId=1,this._browserTouchPanningEnabled=!1,this._element=e,e.getAttribute("tabindex")||e.setAttribute("tabindex","0"),this._eventHandlers={"key-down":this._handleKey,"key-up":this._handleKey,"pointer-down":this._handlePointer,"pointer-move":this._handlePointerPreventDefault,"pointer-up":this._handlePointerPreventDefault,"pointer-enter":this._handlePointer,"pointer-leave":this._handlePointer,"pointer-cancel":this._handlePointer,"mouse-wheel":this._handleMouseWheel,"pointer-capture-lost":this._handlePointerCaptureLost},this._updateTouchAction(),this._element.addEventListener("keydown",this._preventAltKeyDefault),this._gamepadSource=new t(e,this._input),this._gamepadSource.onEvent=e=>this._callback("gamepad",e)}destroy(){this._callback=()=>{},this.activeEvents=null,this._activePointerCaptures.forEach((e=>{this._releasePointerCaptureSafe(e)})),this._gamepadSource=e(this._gamepadSource),this._activePointerCaptures=null,this._removeTouchAction(),this._element.removeEventListener("keydown",this._preventAltKeyDefault)}get browserTouchPanningEnabled(){return this._browserTouchPanningEnabled}set browserTouchPanningEnabled(e){this._browserTouchPanningEnabled=e,this._updateTouchAction(),this._updateTouchEventHandling()}set onEventReceived(e){this._callback=e}set activeEvents(e){for(const t in this._active)if(!e||!e.has(t)){const e=this._active[t];this._element.removeEventListener(c[t],e),delete this._active[t]}e&&e.forEach((e=>{if(!this._active[e]&&c[e]){const t=(this._eventHandlers[e]||this._handleDefault).bind(this,e);this._element.addEventListener(c[e],t),this._active[e]=t}})),this._gamepadSource.hasEventListeners=e?.has("gamepad")??!1}setPointerCapture(e,t){t?this._setPointerCatpureSafe(e.pointerId):(this._releasePointerCaptureSafe(e.pointerId),this._activePointerCaptures.delete(e.pointerId))}_updateTouchAction(){this._element.classList.remove(this._browserTouchPanningEnabled?h.touchNone:h.touchPan),this._element.classList.add(this._browserTouchPanningEnabled?h.touchPan:h.touchNone)}_updateTouchEventHandling(){this._browserTouchPanningEnabled?this._element.addEventListener("touchmove",this._preventMultiTouchPanning):this._element.removeEventListener("touchmove",this._preventMultiTouchPanning)}_removeTouchAction(){this._element.classList.remove(h.touchNone),this._element.classList.remove(h.touchPan),this._element.removeEventListener("touchmove",this._preventMultiTouchPanning)}_setPointerCatpureSafe(e){try{this._element.setPointerCapture(e),this._activePointerCaptures.add(e)}catch{}}_releasePointerCaptureSafe(e){try{if(this._element.hasPointerCapture&&!this._element.hasPointerCapture(e))return;this._element.releasePointerCapture(e)}catch(t){}}_updateNormalizedPointerLikeEvent(e,t){const i=n(this._element,e);return l.test.disableSubpixelCoordinates&&(i.x=Math.round(i.x),i.y=Math.round(i.y)),t.x=i.x,t.y=i.y,t}_handleKey(e,t){const{key:n}=t;n&&"key-up"===e&&this._keyDownState.delete(n);const i={native:t,key:n,repeat:!!n&&this._keyDownState.has(n)};n&&"key-down"===e&&this._keyDownState.add(i.key),this._callback(e,i)}_handlePointer(e,t){const n=this._updateNormalizedPointerLikeEvent(t,{native:t,x:0,y:0,pointerType:t.pointerType,button:t.button,buttons:t.buttons,eventId:this._eventId++});this._callback(e,n)}_handlePointerPreventDefault(e,t){const n=this._updateNormalizedPointerLikeEvent(t,{native:t,x:0,y:0,pointerType:t.pointerType,button:t.button,buttons:t.buttons,eventId:this._eventId++});t.preventDefault(),this._callback(e,n)}
|
|
5
|
+
import has from"../../core/has.js";import{destroyMaybe as e}from"../../core/maybe.js";import{GamepadSource as t}from"./gamepad/GamepadSource.js";import{createScreenPointFromNativeEvent as n}from"../support/screenUtils.js";const i=has("edge"),a=has("chrome"),o=has("ff"),s=has("safari"),r="esri-view-surface",h={touchNone:`${r}--touch-none`,touchPan:`${r}--touch-pan`};class l{constructor(e,n){this._input=n,this._active={},this._callback=()=>{},this._activePointerCaptures=new Set,this._keyDownState=new Set,this._eventId=1,this._browserTouchPanningEnabled=!1,this._element=e,e.getAttribute("tabindex")||e.setAttribute("tabindex","0"),this._eventHandlers={"key-down":this._handleKey,"key-up":this._handleKey,"pointer-down":this._handlePointer,"pointer-move":this._handlePointerPreventDefault,"pointer-up":this._handlePointerPreventDefault,"pointer-enter":this._handlePointer,"pointer-leave":this._handlePointer,"pointer-cancel":this._handlePointer,"mouse-wheel":this._handleMouseWheel,"pointer-capture-lost":this._handlePointerCaptureLost},this._updateTouchAction(),this._element.addEventListener("keydown",this._preventAltKeyDefault),this._gamepadSource=new t(e,this._input),this._gamepadSource.onEvent=e=>this._callback("gamepad",e)}destroy(){this._callback=()=>{},this.activeEvents=null,this._activePointerCaptures.forEach((e=>{this._releasePointerCaptureSafe(e)})),this._gamepadSource=e(this._gamepadSource),this._activePointerCaptures=null,this._removeTouchAction(),this._element.removeEventListener("keydown",this._preventAltKeyDefault)}get browserTouchPanningEnabled(){return this._browserTouchPanningEnabled}set browserTouchPanningEnabled(e){this._browserTouchPanningEnabled=e,this._updateTouchAction(),this._updateTouchEventHandling()}set onEventReceived(e){this._callback=e}set activeEvents(e){for(const t in this._active)if(!e||!e.has(t)){const e=this._active[t];this._element.removeEventListener(c[t],e),delete this._active[t]}e&&e.forEach((e=>{if(!this._active[e]&&c[e]){const t=(this._eventHandlers[e]||this._handleDefault).bind(this,e);this._element.addEventListener(c[e],t),this._active[e]=t}})),this._gamepadSource.hasEventListeners=e?.has("gamepad")??!1}setPointerCapture(e,t){t?this._setPointerCatpureSafe(e.pointerId):(this._releasePointerCaptureSafe(e.pointerId),this._activePointerCaptures.delete(e.pointerId))}_updateTouchAction(){this._element.classList.remove(this._browserTouchPanningEnabled?h.touchNone:h.touchPan),this._element.classList.add(this._browserTouchPanningEnabled?h.touchPan:h.touchNone)}_updateTouchEventHandling(){this._browserTouchPanningEnabled?this._element.addEventListener("touchmove",this._preventMultiTouchPanning):this._element.removeEventListener("touchmove",this._preventMultiTouchPanning)}_removeTouchAction(){this._element.classList.remove(h.touchNone),this._element.classList.remove(h.touchPan),this._element.removeEventListener("touchmove",this._preventMultiTouchPanning)}_setPointerCatpureSafe(e){try{this._element.setPointerCapture(e),this._activePointerCaptures.add(e)}catch{}}_releasePointerCaptureSafe(e){try{if(this._element.hasPointerCapture&&!this._element.hasPointerCapture(e))return;this._element.releasePointerCapture(e)}catch(t){}}_updateNormalizedPointerLikeEvent(e,t){const i=n(this._element,e);return l.test.disableSubpixelCoordinates&&(i.x=Math.round(i.x),i.y=Math.round(i.y)),t.x=i.x,t.y=i.y,t}_handleKey(e,t){const{key:n}=t;n&&"key-up"===e&&this._keyDownState.delete(n);const i={native:t,key:n,repeat:!!n&&this._keyDownState.has(n)};n&&"key-down"===e&&this._keyDownState.add(i.key),this._callback(e,i)}_handlePointer(e,t){const n=this._updateNormalizedPointerLikeEvent(t,{native:t,x:0,y:0,pointerType:t.pointerType,button:t.button,buttons:t.buttons,eventId:this._eventId++});this._callback(e,n)}_handlePointerPreventDefault(e,t){const n=this._updateNormalizedPointerLikeEvent(t,{native:t,x:0,y:0,pointerType:t.pointerType,button:t.button,buttons:t.buttons,eventId:this._eventId++});t.preventDefault(),this._callback(e,n)}_getDeltaFromTrackpadOrMouseWheel(e){return e.shiftKey&&has("mac")&&0===e.deltaY?e.deltaX:e.deltaY}_handleMouseWheel(e,t){let n=this._getDeltaFromTrackpadOrMouseWheel(t);switch(t.deltaMode){case 0:i&&(n=n/document.documentElement.clientHeight*600);break;case 1:n*=30;break;case 2:n*=900}i?n*=.7:a||s?n*=.6:o&&(n*=1.375);const r=100,h=Math.abs(n);if(h>r){const e=.02;n=n/h*200/(1+Math.exp(-e*(h-r)))}const l=this._updateNormalizedPointerLikeEvent(t,{native:t,x:0,y:0,deltaY:n});this._callback(e,l)}_handlePointerCaptureLost(e,t){this._activePointerCaptures.delete(t.pointerId),this._handleDefault(e,t)}_handleDefault(e,t){const n={native:t};t.preventDefault(),this._callback(e,n)}_preventAltKeyDefault(e){"Alt"===e.key&&e.preventDefault()}_preventMultiTouchPanning(e){e.touches.length>1&&e.preventDefault()}}l.test={disableSubpixelCoordinates:!1};const c={"key-down":"keydown","key-up":"keyup","pointer-down":"pointerdown","pointer-up":"pointerup","pointer-move":"pointermove","mouse-wheel":"wheel","pointer-capture-got":"gotpointercapture","pointer-capture-lost":"lostpointercapture","context-menu":"contextmenu","pointer-enter":"pointerenter","pointer-leave":"pointerleave","pointer-cancel":"pointercancel",focus:"focus",blur:"blur"};export{l as BrowserEventSource};
|
package/views/webgl/Texture.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../core/Error.js";import"../../core/has.js";import{checkWebGLError as e}from"./checkWebGLError.js";import{TextureType as i,ResourceType as r,TextureSamplingMode as s,PixelFormat as o,PixelType as a,SizedPixelFormat as n,CompressedTextureFormat as l}from"./enums.js";import{GLObjectType as h}from"./GLObjectType.js";import{estimateMemory as p}from"./TextureDescriptor.js";import{ValidatedTextureDescriptor as d}from"./ValidatedTextureDescriptor.js";const _=null;let m=class l{constructor(e,r=null,s=null){if(this.type=h.Texture,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._wasImmutablyAllocated=!1,"context"in e)this._descriptor=e,s=r;else{const i=d.validate(e,r);if(!i)throw new t("Texture descriptor invalid");this._descriptor=i}this._descriptor.target===i.TEXTURE_CUBE_MAP?this._setDataCubeMap(s):this.setData(s)}get glName(){return this._glName}get descriptor(){return this._descriptor}get usedMemory(){return p(this._descriptor)}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty}dispose(){this._glName&&this._descriptor.context.instanceCounter.decrement(r.Texture,this),this._descriptor.context.gl&&this._glName&&(this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null)}release(){this.dispose()}resize(e,r){const s=this._descriptor;if(s.width!==e||s.height!==r){if(this._wasImmutablyAllocated)throw new t("Immutable textures can't be resized!");s.width=e,s.height=r,this._descriptor.target===i.TEXTURE_CUBE_MAP?this._setDataCubeMap(null):this.setData(null)}}_setDataCubeMap(t=null){for(let e=i.TEXTURE_CUBE_MAP_POSITIVE_X;e<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z;e++)this._setData(t,e)}setData(t){this._setData(t)}_setData(i,s){const o=this._descriptor.context?.gl;if(!o)return;e(o),this._glName||(this._glName=o.createTexture(),this._glName&&this._descriptor.context.instanceCounter.increment(r.Texture,this));const a=this._descriptor,n=s??a.target,h=f(n),p=this._descriptor.context.bindTexture(this,l.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(l.TEXTURE_UNIT_FOR_UPDATES),c(a),this._configurePixelStorage(),e(o);const d=this._deriveInternalFormat();if(I(i)){let t="width"in i?i.width:i.codedWidth,r="height"in i?i.height:i.codedHeight;const s=1;i instanceof HTMLVideoElement&&(t=i.videoWidth,r=i.videoHeight),a.width&&a.height,h&&a.depth,a.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(n,d,a.hasMipmap,t,r,s),this._texImage(n,0,d,t,r,s,i),e(o),a.hasMipmap&&(this.generateMipmap(),e(o)),a.width||(a.width=t),a.height||(a.height=r),h&&!a.depth&&(a.depth=s)}else{const{width:r,height:s,depth:l}=a;if(null==r||null==s)throw new t("Width and height must be specified!");if(h&&null==l)throw new t("Depth must be specified!");if(a.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(n,d,a.hasMipmap,r,s,l),M(i)){const e=i.levels,h=R(n,r,s,l),p=Math.min(h-1,e.length-1);o.texParameteri(a.target,this._descriptor.context.gl.TEXTURE_MAX_LEVEL,p);const _=d;if(!x(_))throw new t("Attempting to use compressed data with an uncompressed format!");this._forEachMipmapLevel(((t,i,r,s)=>{const o=e[Math.min(t,e.length-1)];this._compressedTexImage(n,t,_,i,r,s,o)}),p)}else this._texImage(n,0,d,r,s,l,i),e(o),a.hasMipmap&&this.generateMipmap()}u(o,this._descriptor),T(o,this._descriptor),E(this._descriptor.context,this._descriptor),e(o),this._descriptor.context.bindTexture(p,l.TEXTURE_UNIT_FOR_UPDATES)}updateData(e,i,r,s,o,a,n=0){a||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const h=this._descriptor,p=this._deriveInternalFormat(),{context:d,pixelFormat:_,dataType:m,target:c,isImmutable:u}=h;if(u&&!this._wasImmutablyAllocated)throw new t("Cannot update immutable texture before allocation!");const T=d.bindTexture(this,l.TEXTURE_UNIT_FOR_UPDATES,!0);(i<0||r<0||i+s>h.width||r+o>h.height)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:E}=d;n&&E.pixelStorei(E.UNPACK_SKIP_ROWS,n),I(a)?E.texSubImage2D(c,e,i,r,s,o,_,m,a):M(a)?E.compressedTexSubImage2D(c,e,i,r,s,o,p,a.levels[e]):E.texSubImage2D(c,e,i,r,s,o,_,m,a),n&&E.pixelStorei(E.UNPACK_SKIP_ROWS,0),d.bindTexture(T,l.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(e,i,r,s,o,a,n,h){h||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const p=this._descriptor,d=this._deriveInternalFormat(),{context:_,pixelFormat:m,dataType:c,isImmutable:u,target:T}=p;if(u&&!this._wasImmutablyAllocated)throw new t("Cannot update immutable texture before allocation!");f(T)||console.warn("Attempting to set 3D texture data on a non-3D texture");const E=_.bindTexture(this,l.TEXTURE_UNIT_FOR_UPDATES);_.setActiveTexture(l.TEXTURE_UNIT_FOR_UPDATES),(i<0||r<0||s<0||i+o>p.width||r+a>p.height||s+n>p.depth)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:g}=_;if(M(h))h=h.levels[e],g.compressedTexSubImage3D(T,e,i,r,s,o,a,n,d,h);else{const t=h;g.texSubImage3D(T,e,i,r,s,o,a,n,m,c,t)}_.bindTexture(E,l.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const e=this._descriptor;if(!e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("Cannot add mipmaps to immutable texture after allocation");e.hasMipmap=!0,this._samplingModeDirty=!0,c(e)}e.samplingMode===s.LINEAR?(this._samplingModeDirty=!0,e.samplingMode=s.LINEAR_MIPMAP_NEAREST):e.samplingMode===s.NEAREST&&(this._samplingModeDirty=!0,e.samplingMode=s.NEAREST_MIPMAP_NEAREST);const i=this._descriptor.context.bindTexture(this,l.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(l.TEXTURE_UNIT_FOR_UPDATES),this._descriptor.context.gl.generateMipmap(e.target),this._descriptor.context.bindTexture(i,l.TEXTURE_UNIT_FOR_UPDATES)}clearMipmap(){const e=this._descriptor;if(e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("Cannot delete mipmaps to immutable texture after allocation");e.hasMipmap=!1,this._samplingModeDirty=!0,c(e)}e.samplingMode===s.LINEAR_MIPMAP_NEAREST?(this._samplingModeDirty=!0,e.samplingMode=s.LINEAR):e.samplingMode===s.NEAREST_MIPMAP_NEAREST&&(this._samplingModeDirty=!0,e.samplingMode=s.NEAREST)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,c(this._descriptor),this._wrapModeDirty=!0)}applyChanges(){const t=this._descriptor,e=t.context.gl;this._samplingModeDirty&&(u(e,t),this._samplingModeDirty=!1),this._wrapModeDirty&&(T(e,t),this._wrapModeDirty=!1)}_deriveInternalFormat(){if(null!=this._descriptor.internalFormat)return this._descriptor.internalFormat===o.DEPTH_STENCIL&&(this._descriptor.internalFormat=o.DEPTH24_STENCIL8),this._descriptor.internalFormat;switch(this._descriptor.dataType){case a.FLOAT:switch(this._descriptor.pixelFormat){case o.RGBA:return this._descriptor.internalFormat=n.RGBA32F;case o.RGB:return this._descriptor.internalFormat=n.RGB32F;default:throw new t("Unable to derive format")}case a.UNSIGNED_BYTE:switch(this._descriptor.pixelFormat){case o.RGBA:return this._descriptor.internalFormat=n.RGBA8;case o.RGB:return this._descriptor.internalFormat=n.RGB8}}return this._descriptor.internalFormat=this._descriptor.pixelFormat===o.DEPTH_STENCIL?o.DEPTH24_STENCIL8:this._descriptor.pixelFormat}_configurePixelStorage(){const t=this._descriptor.context.gl,{unpackAlignment:e,flipped:i,preMultiplyAlpha:r}=this._descriptor;t.pixelStorei(t.UNPACK_ALIGNMENT,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i?1:0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r?1:0)}_texStorage(e,i,r,s,o,a){const{gl:n}=this._descriptor.context;if(!g(i))throw new t("Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const l=r?R(e,s,o,a):1;if(f(e)){if(null==a)throw new t("Missing depth dimension for 3D texture upload");n.texStorage3D(e,l,i,s,o,a)}else n.texStorage2D(e,l,i,s,o);this._wasImmutablyAllocated=!0}_texImage(e,i,r,s,o,a,n){const l=this._descriptor.context.gl,h=f(e),{isImmutable:p,pixelFormat:d,dataType:_}=this._descriptor;if(p){if(null!=n){const r=n;if(h){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.texSubImage3D(e,i,0,0,0,s,o,a,d,_,r)}else l.texSubImage2D(e,i,0,0,s,o,d,_,r)}}else{const p=n;if(h){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.texImage3D(e,i,r,s,o,a,0,d,_,p)}else l.texImage2D(e,i,r,s,o,0,d,_,p)}}_compressedTexImage(e,i,r,s,o,a,n){const l=this._descriptor.context.gl,h=f(e);if(this._descriptor.isImmutable){if(null!=n)if(h){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.compressedTexSubImage3D(e,i,0,0,0,s,o,a,r,n)}else l.compressedTexSubImage2D(e,i,0,0,s,o,r,n)}else if(h){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.compressedTexImage3D(e,i,r,s,o,a,0,n)}else l.compressedTexImage2D(e,i,r,s,o,0,n)}_forEachMipmapLevel(e,r=1/0){let{width:s,height:o,depth:a,hasMipmap:n,target:l}=this._descriptor;const h=l===i.TEXTURE_3D;if(null==s||null==o||h&&null==a)throw new t("Missing texture dimensions for mipmap calculation");for(let t=0;e(t,s,o,a),n&&(1!==s||1!==o||h&&1!==a)&&!(t>=r);++t)s=Math.max(1,s>>1),o=Math.max(1,o>>1),h&&(a=Math.max(1,a>>1))}};function c(t){(null!=t.width&&t.width<0||null!=t.height&&t.height<0||null!=t.depth&&t.depth<0)&&console.error("Negative dimension parameters are not allowed!")}function u(t,e){let i=e.samplingMode,r=e.samplingMode;i===s.LINEAR_MIPMAP_NEAREST||i===s.LINEAR_MIPMAP_LINEAR?(i=s.LINEAR,e.hasMipmap||(r=s.LINEAR)):i!==s.NEAREST_MIPMAP_NEAREST&&i!==s.NEAREST_MIPMAP_LINEAR||(i=s.NEAREST,e.hasMipmap||(r=s.NEAREST)),t.texParameteri(e.target,t.TEXTURE_MAG_FILTER,i),t.texParameteri(e.target,t.TEXTURE_MIN_FILTER,r)}function T(t,e){"number"==typeof e.wrapMode?(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode)):(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode.s),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode.t))}function E(t,e){const i=t.capabilities.textureFilterAnisotropic;if(!i)return;t.gl.texParameterf(e.target,i.TEXTURE_MAX_ANISOTROPY,e.maxAnisotropy??1)}function g(t){return t in n}function x(t){return t in l}function M(t){return null!=t&&"type"in t&&"compressed"===t.type}function A(t){return null!=t&&"byteLength"in t}function I(t){return null!=t&&!M(t)&&!A(t)}function f(t){return t===i.TEXTURE_3D||t===i.TEXTURE_2D_ARRAY}function R(t,e,r,s=1){let o=Math.max(e,r);return t===i.TEXTURE_3D&&(o=Math.max(o,s)),Math.round(Math.log(o)/Math.LN2)+1}m.TEXTURE_UNIT_FOR_UPDATES=0;export{m as Texture,_ as tracer};
|
|
5
|
+
import t from"../../core/Error.js";import"../../core/has.js";import{checkWebGLError as e}from"./checkWebGLError.js";import{TextureType as i,ResourceType as r,TextureSamplingMode as s,PixelFormat as o,PixelType as a,SizedPixelFormat as n,CompressedTextureFormat as l}from"./enums.js";import{GLObjectType as h}from"./GLObjectType.js";import{estimateMemory as p}from"./TextureDescriptor.js";import{ValidatedTextureDescriptor as d}from"./ValidatedTextureDescriptor.js";const _=null;let m=class l{constructor(e,r=null,s=null){if(this.type=h.Texture,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._wasImmutablyAllocated=!1,"context"in e)this._descriptor=e,s=r;else{const i=d.validate(e,r);if(!i)throw new t("Texture descriptor invalid");this._descriptor=i}this._descriptor.target===i.TEXTURE_CUBE_MAP?this._setDataCubeMap(s):this.setData(s)}get glName(){return this._glName}get descriptor(){return this._descriptor}get usedMemory(){return p(this._descriptor)}get cachedMemory(){return this.usedMemory}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty}dispose(){this._glName&&this._descriptor.context.instanceCounter.decrement(r.Texture,this),this._descriptor.context.gl&&this._glName&&(this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null)}release(){this.dispose()}resize(e,r){const s=this._descriptor;if(s.width!==e||s.height!==r){if(this._wasImmutablyAllocated)throw new t("Immutable textures can't be resized!");s.width=e,s.height=r,this._descriptor.target===i.TEXTURE_CUBE_MAP?this._setDataCubeMap(null):this.setData(null)}}_setDataCubeMap(t=null){for(let e=i.TEXTURE_CUBE_MAP_POSITIVE_X;e<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z;e++)this._setData(t,e)}setData(t){this._setData(t)}_setData(i,s){const o=this._descriptor.context?.gl;if(!o)return;e(o),this._glName||(this._glName=o.createTexture(),this._glName&&this._descriptor.context.instanceCounter.increment(r.Texture,this));const a=this._descriptor,n=s??a.target,h=f(n),p=this._descriptor.context.bindTexture(this,l.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(l.TEXTURE_UNIT_FOR_UPDATES),c(a),this._configurePixelStorage(),e(o);const d=this._deriveInternalFormat();if(I(i)){let t="width"in i?i.width:i.codedWidth,r="height"in i?i.height:i.codedHeight;const s=1;i instanceof HTMLVideoElement&&(t=i.videoWidth,r=i.videoHeight),a.width&&a.height,h&&a.depth,a.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(n,d,a.hasMipmap,t,r,s),this._texImage(n,0,d,t,r,s,i),e(o),a.hasMipmap&&(this.generateMipmap(),e(o)),a.width||(a.width=t),a.height||(a.height=r),h&&!a.depth&&(a.depth=s)}else{const{width:r,height:s,depth:l}=a;if(null==r||null==s)throw new t("Width and height must be specified!");if(h&&null==l)throw new t("Depth must be specified!");if(a.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(n,d,a.hasMipmap,r,s,l),M(i)){const e=i.levels,h=R(n,r,s,l),p=Math.min(h-1,e.length-1);o.texParameteri(a.target,this._descriptor.context.gl.TEXTURE_MAX_LEVEL,p);const _=d;if(!x(_))throw new t("Attempting to use compressed data with an uncompressed format!");this._forEachMipmapLevel(((t,i,r,s)=>{const o=e[Math.min(t,e.length-1)];this._compressedTexImage(n,t,_,i,r,s,o)}),p)}else this._texImage(n,0,d,r,s,l,i),e(o),a.hasMipmap&&this.generateMipmap()}u(o,this._descriptor),T(o,this._descriptor),E(this._descriptor.context,this._descriptor),e(o),this._descriptor.context.bindTexture(p,l.TEXTURE_UNIT_FOR_UPDATES)}updateData(e,i,r,s,o,a,n=0){a||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const h=this._descriptor,p=this._deriveInternalFormat(),{context:d,pixelFormat:_,dataType:m,target:c,isImmutable:u}=h;if(u&&!this._wasImmutablyAllocated)throw new t("Cannot update immutable texture before allocation!");const T=d.bindTexture(this,l.TEXTURE_UNIT_FOR_UPDATES,!0);(i<0||r<0||i+s>h.width||r+o>h.height)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:E}=d;n&&E.pixelStorei(E.UNPACK_SKIP_ROWS,n),I(a)?E.texSubImage2D(c,e,i,r,s,o,_,m,a):M(a)?E.compressedTexSubImage2D(c,e,i,r,s,o,p,a.levels[e]):E.texSubImage2D(c,e,i,r,s,o,_,m,a),n&&E.pixelStorei(E.UNPACK_SKIP_ROWS,0),d.bindTexture(T,l.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(e,i,r,s,o,a,n,h){h||console.error("An attempt to use uninitialized data!"),this._glName||console.error("An attempt to update uninitialized texture!");const p=this._descriptor,d=this._deriveInternalFormat(),{context:_,pixelFormat:m,dataType:c,isImmutable:u,target:T}=p;if(u&&!this._wasImmutablyAllocated)throw new t("Cannot update immutable texture before allocation!");f(T)||console.warn("Attempting to set 3D texture data on a non-3D texture");const E=_.bindTexture(this,l.TEXTURE_UNIT_FOR_UPDATES);_.setActiveTexture(l.TEXTURE_UNIT_FOR_UPDATES),(i<0||r<0||s<0||i+o>p.width||r+a>p.height||s+n>p.depth)&&console.error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:g}=_;if(M(h))h=h.levels[e],g.compressedTexSubImage3D(T,e,i,r,s,o,a,n,d,h);else{const t=h;g.texSubImage3D(T,e,i,r,s,o,a,n,m,c,t)}_.bindTexture(E,l.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const e=this._descriptor;if(!e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("Cannot add mipmaps to immutable texture after allocation");e.hasMipmap=!0,this._samplingModeDirty=!0,c(e)}e.samplingMode===s.LINEAR?(this._samplingModeDirty=!0,e.samplingMode=s.LINEAR_MIPMAP_NEAREST):e.samplingMode===s.NEAREST&&(this._samplingModeDirty=!0,e.samplingMode=s.NEAREST_MIPMAP_NEAREST);const i=this._descriptor.context.bindTexture(this,l.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(l.TEXTURE_UNIT_FOR_UPDATES),this._descriptor.context.gl.generateMipmap(e.target),this._descriptor.context.bindTexture(i,l.TEXTURE_UNIT_FOR_UPDATES)}clearMipmap(){const e=this._descriptor;if(e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("Cannot delete mipmaps to immutable texture after allocation");e.hasMipmap=!1,this._samplingModeDirty=!0,c(e)}e.samplingMode===s.LINEAR_MIPMAP_NEAREST?(this._samplingModeDirty=!0,e.samplingMode=s.LINEAR):e.samplingMode===s.NEAREST_MIPMAP_NEAREST&&(this._samplingModeDirty=!0,e.samplingMode=s.NEAREST)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,c(this._descriptor),this._wrapModeDirty=!0)}applyChanges(){const t=this._descriptor,e=t.context.gl;this._samplingModeDirty&&(u(e,t),this._samplingModeDirty=!1),this._wrapModeDirty&&(T(e,t),this._wrapModeDirty=!1)}_deriveInternalFormat(){if(null!=this._descriptor.internalFormat)return this._descriptor.internalFormat===o.DEPTH_STENCIL&&(this._descriptor.internalFormat=o.DEPTH24_STENCIL8),this._descriptor.internalFormat;switch(this._descriptor.dataType){case a.FLOAT:switch(this._descriptor.pixelFormat){case o.RGBA:return this._descriptor.internalFormat=n.RGBA32F;case o.RGB:return this._descriptor.internalFormat=n.RGB32F;default:throw new t("Unable to derive format")}case a.UNSIGNED_BYTE:switch(this._descriptor.pixelFormat){case o.RGBA:return this._descriptor.internalFormat=n.RGBA8;case o.RGB:return this._descriptor.internalFormat=n.RGB8}}return this._descriptor.internalFormat=this._descriptor.pixelFormat===o.DEPTH_STENCIL?o.DEPTH24_STENCIL8:this._descriptor.pixelFormat}_configurePixelStorage(){const t=this._descriptor.context.gl,{unpackAlignment:e,flipped:i,preMultiplyAlpha:r}=this._descriptor;t.pixelStorei(t.UNPACK_ALIGNMENT,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i?1:0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r?1:0)}_texStorage(e,i,r,s,o,a){const{gl:n}=this._descriptor.context;if(!g(i))throw new t("Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const l=r?R(e,s,o,a):1;if(f(e)){if(null==a)throw new t("Missing depth dimension for 3D texture upload");n.texStorage3D(e,l,i,s,o,a)}else n.texStorage2D(e,l,i,s,o);this._wasImmutablyAllocated=!0}_texImage(e,i,r,s,o,a,n){const l=this._descriptor.context.gl,h=f(e),{isImmutable:p,pixelFormat:d,dataType:_}=this._descriptor;if(p){if(null!=n){const r=n;if(h){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.texSubImage3D(e,i,0,0,0,s,o,a,d,_,r)}else l.texSubImage2D(e,i,0,0,s,o,d,_,r)}}else{const p=n;if(h){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.texImage3D(e,i,r,s,o,a,0,d,_,p)}else l.texImage2D(e,i,r,s,o,0,d,_,p)}}_compressedTexImage(e,i,r,s,o,a,n){const l=this._descriptor.context.gl,h=f(e);if(this._descriptor.isImmutable){if(null!=n)if(h){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.compressedTexSubImage3D(e,i,0,0,0,s,o,a,r,n)}else l.compressedTexSubImage2D(e,i,0,0,s,o,r,n)}else if(h){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.compressedTexImage3D(e,i,r,s,o,a,0,n)}else l.compressedTexImage2D(e,i,r,s,o,0,n)}_forEachMipmapLevel(e,r=1/0){let{width:s,height:o,depth:a,hasMipmap:n,target:l}=this._descriptor;const h=l===i.TEXTURE_3D;if(null==s||null==o||h&&null==a)throw new t("Missing texture dimensions for mipmap calculation");for(let t=0;e(t,s,o,a),n&&(1!==s||1!==o||h&&1!==a)&&!(t>=r);++t)s=Math.max(1,s>>1),o=Math.max(1,o>>1),h&&(a=Math.max(1,a>>1))}};function c(t){(null!=t.width&&t.width<0||null!=t.height&&t.height<0||null!=t.depth&&t.depth<0)&&console.error("Negative dimension parameters are not allowed!")}function u(t,e){let i=e.samplingMode,r=e.samplingMode;i===s.LINEAR_MIPMAP_NEAREST||i===s.LINEAR_MIPMAP_LINEAR?(i=s.LINEAR,e.hasMipmap||(r=s.LINEAR)):i!==s.NEAREST_MIPMAP_NEAREST&&i!==s.NEAREST_MIPMAP_LINEAR||(i=s.NEAREST,e.hasMipmap||(r=s.NEAREST)),t.texParameteri(e.target,t.TEXTURE_MAG_FILTER,i),t.texParameteri(e.target,t.TEXTURE_MIN_FILTER,r)}function T(t,e){"number"==typeof e.wrapMode?(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode)):(t.texParameteri(e.target,t.TEXTURE_WRAP_S,e.wrapMode.s),t.texParameteri(e.target,t.TEXTURE_WRAP_T,e.wrapMode.t))}function E(t,e){const i=t.capabilities.textureFilterAnisotropic;if(!i)return;t.gl.texParameterf(e.target,i.TEXTURE_MAX_ANISOTROPY,e.maxAnisotropy??1)}function g(t){return t in n}function x(t){return t in l}function M(t){return null!=t&&"type"in t&&"compressed"===t.type}function A(t){return null!=t&&"byteLength"in t}function I(t){return null!=t&&!M(t)&&!A(t)}function f(t){return t===i.TEXTURE_3D||t===i.TEXTURE_2D_ARRAY}function R(t,e,r,s=1){let o=Math.max(e,r);return t===i.TEXTURE_3D&&(o=Math.max(o,s)),Math.round(Math.log(o)/Math.LN2)+1}m.TEXTURE_UNIT_FOR_UPDATES=0;export{m as Texture,_ as tracer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../core/Logger.js";import{disposeMaybe as t}from"../../core/maybe.js";import{typedArrayStaticSize as i}from"../../core/typedArrayUtil.js";import{ResourceType as r}from"./enums.js";import{bindVertexBufferLayout as s}from"./Util.js";const n=()=>e.getLogger("esri.views.webgl.VertexArrayObject");let o=class{constructor(e,t,i,r,s=null){this._context=e,this._locations=t,this._layout=i,this._buffers=r,this._indexBuffer=s,this._glName=null,this._initialized=!1}get glName(){return this._glName}get context(){return this._context}get vertexBuffers(){return this._buffers}get indexBuffer(){return this._indexBuffer}get byteSize(){return Array.from(this._buffers.values()).reduce(((e,t)=>e+t.usedMemory),null!=this._indexBuffer?this._indexBuffer.usedMemory:0)}get layout(){return this._layout}get locations(){return this._locations}get usedMemory(){return this.byteSize+(Object.keys(this._buffers).length+(this._indexBuffer?1:0))*i}dispose(){this._context?(this._context.getBoundVAO()===this&&this._context.bindVAO(null),this._buffers.forEach((e=>e.dispose())),this._buffers.clear(),this._indexBuffer=t(this._indexBuffer),this.disposeVAOOnly()):(this._glName||Object.getOwnPropertyNames(this._buffers).length>0)&&n().warn("Leaked WebGL VAO")}disposeVAOOnly(){this._glName&&(this._context.gl.deleteVertexArray(this._glName),this._glName=null,this._context.instanceCounter.decrement(r.VertexArrayObject,this)),this._context=null}initialize(){if(this._initialized)return;const{gl:e}=this._context,t=e.createVertexArray();e.bindVertexArray(t),this._bindLayout(),e.bindVertexArray(null),this._glName=t,this._context.instanceCounter.increment(r.VertexArrayObject,this),this._initialized=!0}bind(){this.initialize(),this._context.gl.bindVertexArray(this.glName)}_bindLayout(){const{_buffers:e,_layout:t,_indexBuffer:i}=this;e||n().error("Vertex buffer dictionary is empty!");const r=this._context.gl;this._buffers.forEach(((e,i)=>{const r=t.get(i);r?s(this._context,this._locations,e,r):n().error("Vertex element descriptor is empty!")})),null!=i&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,i.glName)}unbind(){this.initialize(),this._context.gl.bindVertexArray(null)}};export{o as VertexArrayObject};
|
|
5
|
+
import e from"../../core/Logger.js";import{disposeMaybe as t}from"../../core/maybe.js";import{typedArrayStaticSize as i}from"../../core/typedArrayUtil.js";import{ResourceType as r}from"./enums.js";import{bindVertexBufferLayout as s}from"./Util.js";const n=()=>e.getLogger("esri.views.webgl.VertexArrayObject");let o=class{constructor(e,t,i,r,s=null){this._context=e,this._locations=t,this._layout=i,this._buffers=r,this._indexBuffer=s,this._glName=null,this._initialized=!1}get glName(){return this._glName}get context(){return this._context}get vertexBuffers(){return this._buffers}get indexBuffer(){return this._indexBuffer}get byteSize(){return Array.from(this._buffers.values()).reduce(((e,t)=>e+t.usedMemory),null!=this._indexBuffer?this._indexBuffer.usedMemory:0)}get layout(){return this._layout}get locations(){return this._locations}get usedMemory(){return this.byteSize+(Object.keys(this._buffers).length+(this._indexBuffer?1:0))*i}get cachedMemory(){return this.usedMemory}dispose(){this._context?(this._context.getBoundVAO()===this&&this._context.bindVAO(null),this._buffers.forEach((e=>e.dispose())),this._buffers.clear(),this._indexBuffer=t(this._indexBuffer),this.disposeVAOOnly()):(this._glName||Object.getOwnPropertyNames(this._buffers).length>0)&&n().warn("Leaked WebGL VAO")}disposeVAOOnly(){this._glName&&(this._context.gl.deleteVertexArray(this._glName),this._glName=null,this._context.instanceCounter.decrement(r.VertexArrayObject,this)),this._context=null}initialize(){if(this._initialized)return;const{gl:e}=this._context,t=e.createVertexArray();e.bindVertexArray(t),this._bindLayout(),e.bindVertexArray(null),this._glName=t,this._context.instanceCounter.increment(r.VertexArrayObject,this),this._initialized=!0}bind(){this.initialize(),this._context.gl.bindVertexArray(this.glName)}_bindLayout(){const{_buffers:e,_layout:t,_indexBuffer:i}=this;e||n().error("Vertex buffer dictionary is empty!");const r=this._context.gl;this._buffers.forEach(((e,i)=>{const r=t.get(i);r?s(this._context,this._locations,e,r):n().error("Vertex element descriptor is empty!")})),null!=i&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,i.glName)}unbind(){this.initialize(),this._context.gl.bindVertexArray(null)}};export{o as VertexArrayObject};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../core/Error.js";import{MultiOriginJSONSupport as t}from"../../core/MultiOriginJSONSupport.js";import{whenOnce as o}from"../../core/reactiveUtils.js";import{hasSameCanonicalPortal as r,urlToObject as a}from"../../core/urlUtils.js";import{updateOrigins as i}from"../../core/accessorSupport/originUtils.js";import n from"../../geometry/SpatialReference.js";import{equals as s}from"../../geometry/support/spatialReferenceUtils.js";import{webMercatorToGeographic as l}from"../../geometry/support/webMercatorUtils.js";import{isServerOrServicesAGOLUrl as p}from"../../layers/support/arcgisLayerUrl.js";import{isLayerWithFeatureLayerSource as c,isFeatureCollectionLayer as m}from"../../layers/support/layerUtils.js";import u from"../../portal/Portal.js";import f from"../../portal/PortalItem.js";import{createForItemWrite as d}from"../../portal/support/jsonContext.js";import{typeKeyword as w,removeTypeKeyword as y,addTypeKeyword as h,hasTypeKeyword as g}from"../../portal/support/portalItemUtils.js";import{project as _}from"../../rest/geometryService/project.js";import b from"../../rest/support/ProjectParameters.js";import{hasDeveloperBasemapLayer as j,findSpatialReference as v,isDeveloperBasemapLayer as R}from"../../support/basemapUtils.js";import{saveResources as P}from"./resourceUtils.js";import{validateSaveAPIKey as W}from"./saveAPIKeyUtils.js";import{beforeSave as I,evaluateWriteErrors as S}from"./saveUtils.js";const A=["NatGeo_World_Map","Ocean_Basemap","USA_Topo_Maps","World_Imagery","World_Street_Map","World_Terrain_Base","World_Topo_Map","World_Hillshade","Canvas/World_Light_Gray_Base","Canvas/World_Light_Gray_Reference","Canvas/World_Dark_Gray_Base","Canvas/World_Dark_Gray_Reference","Ocean/World_Ocean_Base","Ocean/World_Ocean_Reference","Reference/World_Boundaries_and_Places","Reference/World_Reference_Overlay","Reference/World_Transportation"].map((e=>e.toLowerCase()));async function O(e,t,r){r??={},C(e,t),await o((()=>!t.updatingFromView)),await t.load(),await V(t),await I(t),await D(e,t);const a=t.portalItem,{json:i,jsonContext:n}=await U(t,a);return S(n,{errorName:`${e.name}:save`},r),await k(t,a),await he(e,t,a,i,n),await Promise.all([t.updateItemThumbnail(),P(t.resourceReferences,n)]),a}async function U(e,t){const o=d(t,"web-map",!0),r=e.write({},o);return await Promise.all(o.resources.pendingOperations),{json:r,jsonContext:o}}async function T(e,t,r,a){a??={};const i=E(e,r);await o((()=>!t.updatingFromView)),await t.load(),await V(t),await I(t),await D(e,t);const{json:n,jsonContext:s}=await U(t,i);S(s,{errorName:`${e.name}:save`},a),await Y(t,i);const l=t.getThumbnailState();return await ge(e,t,i,n,s,a)&&(t.resourceReferences.portalItem=i),t.restoreThumbnailFromState(l),await Promise.all([t.updateItemThumbnail(),P(t.resourceReferences,s)]),i}function C(t,o){if(!o.portalItem)throw new e(`${t.name}:portal-item-not-set`,"Portal item to save to has not been set on the WebMap");W(o.portalItem),M(t,o.portalItem)}function M(t,o){if(o.type!==t.itemType)throw new e(`${t.name}:portal-item-wrong-type`,`Portal item needs to have type "${t.itemType}"`)}async function D(t,r){if(!r.basemap?.baseLayers.length)throw new e(`${t.name}:save`,"Map does not have a valid basemap with a base layer.");let a=null;if(await o((()=>{const e=v(r.initialViewProperties,r.basemap);return a=e.spatialReference,!e.updating})),!s(a,r.initialViewProperties.spatialReference))throw new e(`${t.name}:save`,"The spatial reference of the basemap is not compatible with the one from the map.",{expected:r.initialViewProperties.spatialReference,actual:a})}function E(e,t){let o=f.from(t);return o.id&&(o=o.clone(),o.id=null),o.type||(o.type=e.itemType),o.portal||(o.portal=u.getDefault()),W(o),M(e,o),o}function V(e){const t=[];return e.basemap&&t.push(e.basemap.load()),e.ground&&t.push(e.ground.load()),Promise.allSettled(t).then((()=>{}))}async function k(e,t){t.extent=await ce(e.portalItem,e.initialViewProperties.viewpoint.targetGeometry),await Z(e,t)}const x=w.JSAPI,G="CollectorDisabled",L="Collector",N="Data Editing",$="OfflineDisabled",B="Offline",K="Workforce Project",F="Workforce Worker",H="Workforce Dispatcher",J="Offline Map Areas",q="FieldMapsDisabled",z=w.DEVELOPER_BASEMAP,Q="UtilityNetwork",X="IPS";async function Y(e,t){y(t,G),y(t,q),y(t,w.METADATA),y(t,$),y(t,J),y(t,H),y(t,K),y(t,F),await k(e,t)}async function Z(e,t){h(t,x),await ee(e),ae(e,t),ie(e,t),ne(e,t),se(e,t),le(e,t),pe(e,t),t.typeKeywords&&(t.typeKeywords=t.typeKeywords.filter(((e,t,o)=>o.indexOf(e)===t)))}function ee(e){const t=te(e).map((e=>e.load())).toArray();return Promise.allSettled(t).then((()=>{}))}function te(e){return e.allLayers.concat(e.allTables)}function oe(e){return te(e).some((e=>e.loaded&&c(e)&&e.capabilities.operations.supportsEditing&&e.editingEnabled&&("subtype-group"!==e.type||e.sublayers.some((e=>e.editingEnabled)))))}function re(e){return te(e).filter((e=>"group"!==e.type)).every((t=>t.loaded&&fe(e,t)))}function ae(e,t){g(t,G)||g(t,K)||g(t,F)||g(t,H)||!oe(e)?y(t,L):h(t,L)}function ie(e,t){oe(e)?h(t,N):y(t,N)}function ne(e,t){!g(t,$)&&re(e)?h(t,B):y(t,B)}function se(e,t){j(e.basemap)?h(t,z):y(t,z)}function le(e,t){e.utilityNetworks?.length?h(t,Q):y(t,Q)}function pe(e,t){e.ipsInfo?h(t,X):y(t,X)}async function ce(e,t){const o=t.clone().normalize();let r;if(o.length>1)for(const a of o)r?a.width>r.width&&(r=a):r=a;else r=o[0];return me(e,r)}async function me(e,t){const o=t.spatialReference;if(o.isWGS84)return t.clone();if(o.isWebMercator)return l(t);const{getGeometryServiceURL:r}=await import("../../portal/support/geometryServiceUtils.js"),a=await r(e),i=new b({geometries:[t],outSpatialReference:n.WGS84});return(await _(a,i))[0]}function ue(e){return m(e)||"map-notes"===e.type||"route"===e.type}function fe(e,t){return c(t)&&t.capabilities.operations.supportsSync||ue(t)&&!t.portalItem||de(t)&&!we(t)&&t.spatialReference.equals(e.initialViewProperties.spatialReference)}function de(e){return("tile"===e.type||"vector-tile"===e.type)&&(e.capabilities.operations.supportsExportTiles||ye(e)||R(e))}function we(e){return"vector-tile"===e.type&&Object.keys(e.sourceNameToSource).length>1}function ye(e){return"tile"===e.type&&(p(e.url)&&A.some((t=>e.url?.toLowerCase().includes("/"+t+"/"))))}async function he(e,t,o,r,a){await o.update({data:r}),je(e,t,o,r,a)}async function ge(t,o,r,a,i,n){const s=o.portalItem,l={item:s,authenticated:!(!s?.id||!s.portal.user)},p=r.portal;await p.signIn();const{copyAllowed:c,itemReloaded:m}=await _e(l,p);if(l.authenticated||=m,!c)throw new e(`${t.name}:save-as-copy-not-allowed`,"Owner of this map does not allow others to save a copy");const u=await be(r,l,a,n);return o.portalItem=r,je(t,o,r,a,i),u}async function _e(e,t){const{item:o,authenticated:r}=e;return o?.id&&o.typeKeywords?.includes("useOnly")?o.portal.portalHostname!==t.portalHostname?{copyAllowed:!1,itemReloaded:!1}:(r||await o.reload(),{copyAllowed:"admin"===o.itemControl||"update"===o.itemControl,itemReloaded:!0}):{copyAllowed:!0,itemReloaded:!1}}async function be(e,t,o,a){const i=e.portal,{item:n}=t,{folder:s,copyAllResources:l}=a;let p=!1;if(l&&n?.id&&r(n.portal.url,i.url)&&parseInt(n.portal.currentVersion,10)>=2023){const{total:e}=await n.fetchResources();p=!!e}if(p){const t=await n.copy({copyResources:"all",folder:s});e.id=t.id,e.portal=t.portal;const r=e.toJSON();await e.load(),e.read(r),await e.update({data:o})}else await(i.user?.addItem({item:e,folder:s,data:o}));return p}function je(e,o,r,n,s){t.prototype.read.call(o,{version:n.version,authoringApp:n.authoringApp,authoringAppVersion:n.authoringAppVersion},{origin:e.origin,ignoreDefaults:!0,url:r.itemUrl?a(r.itemUrl):void 0}),i(s),o.resourceInfo=n}export{U as createJSON,be as initializeNewItem,_e as isCopyAllowed,O as save,T as saveAs};
|
|
5
|
+
import e from"../../core/Error.js";import{MultiOriginJSONSupport as t}from"../../core/MultiOriginJSONSupport.js";import{whenOnce as o}from"../../core/reactiveUtils.js";import{hasSameCanonicalPortal as r,urlToObject as a}from"../../core/urlUtils.js";import{updateOrigins as i}from"../../core/accessorSupport/originUtils.js";import n from"../../geometry/SpatialReference.js";import{equals as s}from"../../geometry/support/spatialReferenceUtils.js";import{webMercatorToGeographic as l}from"../../geometry/support/webMercatorUtils.js";import{isServerOrServicesAGOLUrl as p}from"../../layers/support/arcgisLayerUrl.js";import{isLayerWithFeatureLayerSource as c,isFeatureCollectionLayer as m}from"../../layers/support/layerUtils.js";import u from"../../portal/Portal.js";import f from"../../portal/PortalItem.js";import{createForItemWrite as d}from"../../portal/support/jsonContext.js";import{typeKeyword as w,removeTypeKeyword as y,addTypeKeyword as h,hasTypeKeyword as g}from"../../portal/support/portalItemUtils.js";import{project as _}from"../../rest/geometryService/project.js";import b from"../../rest/support/ProjectParameters.js";import{hasDeveloperBasemapLayer as j,findSpatialReference as v,isDeveloperBasemapLayer as R}from"../../support/basemapUtils.js";import{saveResources as P}from"./resourceUtils.js";import{validateSaveAPIKey as W}from"./saveAPIKeyUtils.js";import{beforeSave as I,evaluateWriteErrors as S}from"./saveUtils.js";const A=["NatGeo_World_Map","Ocean_Basemap","USA_Topo_Maps","World_Imagery","World_Street_Map","World_Terrain_Base","World_Topo_Map","World_Hillshade","Canvas/World_Light_Gray_Base","Canvas/World_Light_Gray_Reference","Canvas/World_Dark_Gray_Base","Canvas/World_Dark_Gray_Reference","Ocean/World_Ocean_Base","Ocean/World_Ocean_Reference","Reference/World_Boundaries_and_Places","Reference/World_Reference_Overlay","Reference/World_Transportation"].map((e=>e.toLowerCase()));async function O(e,t,r){r??={},C(e,t),await o((()=>!t.updatingFromView)),await t.load(),await V(t),await I(t),await D(e,t);const a=t.portalItem,{json:i,jsonContext:n}=await U(t,a);return S(n,{errorName:`${e.name}:save`},r),await k(t,a),await he(e,t,a,i,n),await Promise.all([t.updateItemThumbnail(),P(t.resourceReferences,n)]),a}async function U(e,t){const o=d(t,"web-map",!0),r=e.write({},o);return await Promise.all(o.resources.pendingOperations),{json:r,jsonContext:o}}async function T(e,t,r,a){a??={};const i=E(e,r);await o((()=>!t.updatingFromView)),await t.load(),await V(t),await I(t),await D(e,t);const{json:n,jsonContext:s}=await U(t,i);S(s,{errorName:`${e.name}:save`},a),await Y(t,i);const l=t.getThumbnailState();return await ge(e,t,i,n,s,a)&&(t.resourceReferences.portalItem=i),t.restoreThumbnailFromState(l),await Promise.all([t.updateItemThumbnail(),P(t.resourceReferences,s)]),i}function C(t,o){if(!o.portalItem)throw new e(`${t.name}:portal-item-not-set`,"Portal item to save to has not been set on the WebMap");W(o.portalItem),M(t,o.portalItem)}function M(t,o){if(o.type!==t.itemType)throw new e(`${t.name}:portal-item-wrong-type`,`Portal item needs to have type "${t.itemType}"`)}async function D(t,r){if("linkchart"===t.name)return;if(!r.basemap?.baseLayers.length)throw new e(`${t.name}:save`,"Map does not have a valid basemap with a base layer.");let a=null;if(await o((()=>{const e=v(r.initialViewProperties,r.basemap);return a=e.spatialReference,!e.updating})),!s(a,r.initialViewProperties.spatialReference))throw new e(`${t.name}:save`,"The spatial reference of the basemap is not compatible with the one from the map.",{expected:r.initialViewProperties.spatialReference,actual:a})}function E(e,t){let o=f.from(t);return o.id&&(o=o.clone(),o.id=null),o.type||(o.type=e.itemType),o.portal||(o.portal=u.getDefault()),W(o),M(e,o),o}function V(e){const t=[];return e.basemap&&t.push(e.basemap.load()),e.ground&&t.push(e.ground.load()),Promise.allSettled(t).then((()=>{}))}async function k(e,t){t.extent=await ce(e.portalItem,e.initialViewProperties.viewpoint.targetGeometry),await Z(e,t)}const x=w.JSAPI,G="CollectorDisabled",L="Collector",N="Data Editing",$="OfflineDisabled",B="Offline",K="Workforce Project",F="Workforce Worker",H="Workforce Dispatcher",J="Offline Map Areas",q="FieldMapsDisabled",z=w.DEVELOPER_BASEMAP,Q="UtilityNetwork",X="IPS";async function Y(e,t){y(t,G),y(t,q),y(t,w.METADATA),y(t,$),y(t,J),y(t,H),y(t,K),y(t,F),await k(e,t)}async function Z(e,t){h(t,x),await ee(e),ae(e,t),ie(e,t),ne(e,t),se(e,t),le(e,t),pe(e,t),t.typeKeywords&&(t.typeKeywords=t.typeKeywords.filter(((e,t,o)=>o.indexOf(e)===t)))}function ee(e){const t=te(e).map((e=>e.load())).toArray();return Promise.allSettled(t).then((()=>{}))}function te(e){return e.allLayers.concat(e.allTables)}function oe(e){return te(e).some((e=>e.loaded&&c(e)&&e.capabilities.operations.supportsEditing&&e.editingEnabled&&("subtype-group"!==e.type||e.sublayers.some((e=>e.editingEnabled)))))}function re(e){return te(e).filter((e=>"group"!==e.type)).every((t=>t.loaded&&fe(e,t)))}function ae(e,t){g(t,G)||g(t,K)||g(t,F)||g(t,H)||!oe(e)?y(t,L):h(t,L)}function ie(e,t){oe(e)?h(t,N):y(t,N)}function ne(e,t){!g(t,$)&&re(e)?h(t,B):y(t,B)}function se(e,t){j(e.basemap)?h(t,z):y(t,z)}function le(e,t){e.utilityNetworks?.length?h(t,Q):y(t,Q)}function pe(e,t){e.ipsInfo?h(t,X):y(t,X)}async function ce(e,t){const o=t.clone().normalize();let r;if(o.length>1)for(const a of o)r?a.width>r.width&&(r=a):r=a;else r=o[0];return me(e,r)}async function me(e,t){const o=t.spatialReference;if(o.isWGS84)return t.clone();if(o.isWebMercator)return l(t);const{getGeometryServiceURL:r}=await import("../../portal/support/geometryServiceUtils.js"),a=await r(e),i=new b({geometries:[t],outSpatialReference:n.WGS84});return(await _(a,i))[0]}function ue(e){return m(e)||"map-notes"===e.type||"route"===e.type}function fe(e,t){return c(t)&&t.capabilities.operations.supportsSync||ue(t)&&!t.portalItem||de(t)&&!we(t)&&t.spatialReference.equals(e.initialViewProperties.spatialReference)}function de(e){return("tile"===e.type||"vector-tile"===e.type)&&(e.capabilities.operations.supportsExportTiles||ye(e)||R(e))}function we(e){return"vector-tile"===e.type&&Object.keys(e.sourceNameToSource).length>1}function ye(e){return"tile"===e.type&&(p(e.url)&&A.some((t=>e.url?.toLowerCase().includes("/"+t+"/"))))}async function he(e,t,o,r,a){await o.update({data:r}),je(e,t,o,r,a)}async function ge(t,o,r,a,i,n){const s=o.portalItem,l={item:s,authenticated:!(!s?.id||!s.portal.user)},p=r.portal;await p.signIn();const{copyAllowed:c,itemReloaded:m}=await _e(l,p);if(l.authenticated||=m,!c)throw new e(`${t.name}:save-as-copy-not-allowed`,"Owner of this map does not allow others to save a copy");const u=await be(r,l,a,n);return o.portalItem=r,je(t,o,r,a,i),u}async function _e(e,t){const{item:o,authenticated:r}=e;return o?.id&&o.typeKeywords?.includes("useOnly")?o.portal.portalHostname!==t.portalHostname?{copyAllowed:!1,itemReloaded:!1}:(r||await o.reload(),{copyAllowed:"admin"===o.itemControl||"update"===o.itemControl,itemReloaded:!0}):{copyAllowed:!0,itemReloaded:!1}}async function be(e,t,o,a){const i=e.portal,{item:n}=t,{folder:s,copyAllResources:l}=a;let p=!1;if(l&&n?.id&&r(n.portal.url,i.url)&&parseInt(n.portal.currentVersion,10)>=2023){const{total:e}=await n.fetchResources();p=!!e}if(p){const t=await n.copy({copyResources:"all",folder:s});e.id=t.id,e.portal=t.portal;const r=e.toJSON();await e.load(),e.read(r),await e.update({data:o})}else await(i.user?.addItem({item:e,folder:s,data:o}));return p}function je(e,o,r,n,s){t.prototype.read.call(o,{version:n.version,authoringApp:n.authoringApp,authoringAppVersion:n.authoringAppVersion},{origin:e.origin,ignoreDefaults:!0,url:r.itemUrl?a(r.itemUrl):void 0}),i(s),o.resourceInfo=n}export{U as createJSON,be as initializeNewItem,_e as isCopyAllowed,O as save,T as saveAs};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import{result as i}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import{watch as s,on as o,when as n}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import l from"../../geometry/Extent.js";import h from"../../geometry/SpatialReference.js";import{extentContainsPoint as u}from"../../geometry/support/contains.js";import{geographicToWebMercator as d,project as m}from"../../geometry/support/webMercatorUtils.js";import{getLyr3DWasm as p}from"../../views/3d/layers/Lyr3DWasm.js";function f(t,e){return t&&"copyright"in t&&(!e||"function"==typeof t.originOf&&"user"===t.originOf("copyright"))}function y(t,e){return t.length!==e.length||t.some(((t,i)=>t.text!==e[i].text))}function b(t,e,i){if(!i||!e)return;t.find((t=>t.layerView===e&&t.text===i))||t.push({text:i,layerView:e})}function g(t){return"bing-maps"===t.type}const A=[];let _=class extends e{constructor(t){super(t),this._clear=()=>{this._fetchedAttributionData.clear(),this._pendingAttributions.clear(),this.removeHandles("suspension"),this.notifyChange("state")},this._pendingAttributions=new Set,this._fetchedAttributionData=new Map,this.items=new r,this.view=null,this._allLayerViewsChange=t=>{this.removeHandles("suspension"),this.removeHandles("visible-geometry-changed");const e=this.view?.allLayerViews;e&&(this.addHandles(e.map((t=>s((()=>[t.suspended,t.layer?.attributionVisible]),(()=>this._updateAttributionItems())))).toArray(),"suspension"),e.forEach((t=>{"esri.views.3d.layers.Tiles3DLayerView3D"===t.declaredClass&&this.addHandles(t.on("visible-geometry-changed",(()=>this._updateAttributionItems())),"visible-geometry-changed")}))),t?.removed&&t.removed.forEach((t=>{this._pendingAttributions.delete(t),this._fetchedAttributionData.delete(t)})),this._updateAttributionItems()},this.addHandles([o((()=>this.view?.allLayerViews),"change",(t=>this._allLayerViewsChange(t)),{onListenerAdd:()=>this._allLayerViewsChange(),onListenerRemove:this._clear}),n((()=>!0===this.view?.stationary),(()=>this._updateAttributionItems()))])}destroy(){this.view=null,this._fetchedAttributionData.clear(),this._pendingAttributions.clear(),this.items.removeAll()}get state(){return this.view?.ready?this._pendingAttributions.size>0?"loading":"ready":"disabled"}_updateAttributionItems(){const t=this.view,e=t?.allLayerViews;if(A.length=0,!t||!e)return void this._clear();e.forEach((e=>{if(e.suspended||!e.layer?.attributionVisible)return;const i=e.layer;if(f(i,"user"))return void b(A,e,i.copyright);if(i.hasAttributionData){if(this._fetchedAttributionData.has(e)){const r=this._fetchedAttributionData.get(e);return void(r?b(A,e,this._getDynamicAttribution(r,t,i)):f(i)&&b(A,e,i.copyright))}return void this._fetchAttributionData(e)}const r="portalItem"in i?i.portalItem?.accessInformation:void 0;b(A,e,r||i.copyright)}));const i=e.find((t=>"integrated-mesh-3dtiles"===t.layer?.type));if(this.view&&i){const t=p(this.view);if(t){const e=t.getAttributionText();for(let t=0;t<e.length;++t)b(A,i,e[t])}}y(this.items,A)&&(this.items.removeAll(),this.items.addMany(A)),A.length=0,this.notifyChange("state")}async _fetchAttributionData(t){if(this._pendingAttributions.has(t))return;this._pendingAttributions.add(t);const e=await i(t.layer.fetchAttributionData());if(this._pendingAttributions.has(t)){const i=e.ok?this._createContributionIndex(e.value,g(t.layer)):null;this._pendingAttributions.delete(t),this._fetchedAttributionData.set(t,i)}this._updateAttributionItems()}_createContributionIndex(t,e){const i=t.contributors,r={};if(!i)return r;for(let s=0;s<i.length;s++){const t=i[s],o=t.coverageAreas;if(!o)return;for(const i of o){const o=i.bbox,n=i.zoomMin-(e&&i.zoomMin?1:0),a=i.zoomMax-(e&&i.zoomMax?1:0),c=new l({xmin:o[1],ymin:o[0],xmax:o[3],ymax:o[2],spatialReference:h.WGS84}),u={extent:d(c),attribution:t.attribution||"",score:null!=i.score?i.score:100,id:s};for(let t=n;t<=a;t++)r[t]??=[],r[t].push(u)}}return r.maxKey=Math.max.apply(null,Object.keys(r)),r}_getDynamicAttribution(t,e,i){const{extent:r,scale:s}=e;let o=i.tileInfo?.scaleToZoom(s)??0;if(o=Math.min(t.maxKey??0,Math.round(o)),!r||null==o||o<=-1)return"";const n=t[o],a=m(r.center.clone().normalize(),
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import{result as i}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import{watch as s,on as o,when as n}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import l from"../../geometry/Extent.js";import h from"../../geometry/SpatialReference.js";import{extentContainsPoint as u}from"../../geometry/support/contains.js";import{geographicToWebMercator as d,project as m}from"../../geometry/support/webMercatorUtils.js";import{getLyr3DWasm as p}from"../../views/3d/layers/Lyr3DWasm.js";function f(t,e){return t&&"copyright"in t&&(!e||"function"==typeof t.originOf&&"user"===t.originOf("copyright"))}function y(t,e){return t.length!==e.length||t.some(((t,i)=>t.text!==e[i].text))}function b(t,e,i){if(!i||!e)return;t.find((t=>t.layerView===e&&t.text===i))||t.push({text:i,layerView:e})}function g(t){return"bing-maps"===t.type}const A=[];let _=class extends e{constructor(t){super(t),this._clear=()=>{this._fetchedAttributionData.clear(),this._pendingAttributions.clear(),this.removeHandles("suspension"),this.notifyChange("state")},this._pendingAttributions=new Set,this._fetchedAttributionData=new Map,this.items=new r,this.view=null,this._allLayerViewsChange=t=>{this.removeHandles("suspension"),this.removeHandles("visible-geometry-changed");const e=this.view?.allLayerViews;e&&(this.addHandles(e.map((t=>s((()=>[t.suspended,t.layer?.attributionVisible]),(()=>this._updateAttributionItems())))).toArray(),"suspension"),e.forEach((t=>{"esri.views.3d.layers.Tiles3DLayerView3D"===t.declaredClass&&this.addHandles(t.on("visible-geometry-changed",(()=>this._updateAttributionItems())),"visible-geometry-changed")}))),t?.removed&&t.removed.forEach((t=>{this._pendingAttributions.delete(t),this._fetchedAttributionData.delete(t)})),this._updateAttributionItems()},this.addHandles([o((()=>this.view?.allLayerViews),"change",(t=>this._allLayerViewsChange(t)),{onListenerAdd:()=>this._allLayerViewsChange(),onListenerRemove:this._clear}),n((()=>!0===this.view?.stationary),(()=>this._updateAttributionItems()))])}destroy(){this.view=null,this._fetchedAttributionData.clear(),this._pendingAttributions.clear(),this.items.removeAll()}get state(){return this.view?.ready?this._pendingAttributions.size>0?"loading":"ready":"disabled"}_updateAttributionItems(){const t=this.view,e=t?.allLayerViews;if(A.length=0,!t||!e)return void this._clear();e.forEach((e=>{if(e.suspended||!e.layer?.attributionVisible)return;const i=e.layer;if(f(i,"user"))return void b(A,e,i.copyright);if(i.hasAttributionData){if(this._fetchedAttributionData.has(e)){const r=this._fetchedAttributionData.get(e);return void(r?b(A,e,this._getDynamicAttribution(r,t,i)):f(i)&&b(A,e,i.copyright))}return void this._fetchAttributionData(e)}const r="portalItem"in i?i.portalItem?.accessInformation:void 0;b(A,e,r||i.copyright)}));const i=e.find((t=>"integrated-mesh-3dtiles"===t.layer?.type));if(this.view&&i){const t=p(this.view);if(t){const e=t.getAttributionText();for(let t=0;t<e.length;++t)b(A,i,e[t])}}y(this.items,A)&&(this.items.removeAll(),this.items.addMany(A)),A.length=0,this.notifyChange("state")}async _fetchAttributionData(t){if(this._pendingAttributions.has(t))return;this._pendingAttributions.add(t);const e=await i(t.layer.fetchAttributionData());if(this._pendingAttributions.has(t)){const i=e.ok?this._createContributionIndex(e.value,g(t.layer)):null;this._pendingAttributions.delete(t),this._fetchedAttributionData.set(t,i)}this._updateAttributionItems()}_createContributionIndex(t,e){const i=t.contributors,r={};if(!i)return r;for(let s=0;s<i.length;s++){const t=i[s],o=t.coverageAreas;if(!o)return;for(const i of o){const o=i.bbox,n=i.zoomMin-(e&&i.zoomMin?1:0),a=i.zoomMax-(e&&i.zoomMax?1:0),c=new l({xmin:o[1],ymin:o[0],xmax:o[3],ymax:o[2],spatialReference:h.WGS84}),u={extent:d(c),attribution:t.attribution||"",score:null!=i.score?i.score:100,id:s};for(let t=n;t<=a;t++)r[t]??=[],r[t].push(u)}}return r.maxKey=Math.max.apply(null,Object.keys(r)),r}_getDynamicAttribution(t,e,i){const{extent:r,scale:s}=e;let o=i.tileInfo?.scaleToZoom(s)??0;if(o=Math.min(t.maxKey??0,Math.round(o)),!r||null==o||o<=-1)return"";const n=t[o],a=m(r.center.clone().normalize(),h.WebMercator),c=new Set;return n?n.filter((t=>{const e=t.id,i=!c.has(e)&&a&&t.extent&&u(t.extent,a);return i&&c.add(e),i})).sort(((t,e)=>e.score-t.score||t.objectId-e.objectId)).map((t=>t.attribution)).join(", "):""}};t([a({readOnly:!0,type:r})],_.prototype,"items",void 0),t([a({readOnly:!0})],_.prototype,"state",null),t([a()],_.prototype,"view",void 0),_=t([c("esri.widgets.Attribution.AttributionViewModel")],_);const v=_;export{v as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import{createTask as t}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import{referenceSetter as o}from"../../core/collectionUtils.js";import s from"../../core/Error.js";import a from"../../core/Evented.js";import{destroyHandle as i}from"../../core/handleUtils.js";import n from"../../core/Logger.js";import{getOrCreateMapValue as p}from"../../core/MapUtils.js";import{abortMaybe as
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{createTask as t}from"../../core/asyncUtils.js";import r from"../../core/Collection.js";import{referenceSetter as o}from"../../core/collectionUtils.js";import s from"../../core/Error.js";import a from"../../core/Evented.js";import{destroyHandle as i}from"../../core/handleUtils.js";import n from"../../core/Logger.js";import{getOrCreateMapValue as p}from"../../core/MapUtils.js";import{abortMaybe as u}from"../../core/maybe.js";import{throwIfAborted as l}from"../../core/promiseUtils.js";import{mapCollection as m,watch as d,sync as c}from"../../core/reactiveUtils.js";import{property as h}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as F}from"../../core/support/UpdatingHandles.js";import{createReactiveGraphic as v}from"./batchAttributeFormUtils.js";import{ArcadeExecutorProvider as y}from"./expressions/ArcadeExecutorProvider.js";import{BatchFormInputs as g}from"./inputs/BatchFormInputs.js";import{createBatchFormInputsFromBatchFormTemplate as _}from"./inputs/support/createBatchFormInputs.js";import w from"./templates/BatchFormTemplate.js";import{createBatchFormTemplate as j}from"./templates/support/createBatchFormTemplate.js";import{isGroupElementTemplate as I}from"./templates/support/templateUtils.js";const b=new w({elements:[]}),E=new g({inputs:new r}),T=()=>n.getLogger("esri.widgets.BatchAttributeForm.BatchAttributeFormViewModel");let x=class extends a.EventedAccessor{constructor(e){super(e),this.activeFeatureIndex=-1,this.disabled=!1,this.editType="NA",this.sharedForm=E,this.sharedFormTemplate=b,this.userHasChangedValues=!1,this._arcadeExecutorProvider=new y,this._activeFormInputsByFieldName=new Map,this._featureFormMap=new Map,this._prepareTask=null,this._updatingHandles=new F,this._layerTemplateMap=new Map}initialize(){const e=m((()=>this.features),v);this._workingFeatures=e,this.addHandles([i(e),this.features.on("change",(()=>{this._prepare()})),d((()=>this.activeForm),(()=>this._activeFormInputsByFieldName.clear()),c)]),this._prepare()}destroy(){this._prepareTask=u(this._prepareTask)}get activeFeature(){const e=this.activeFeatureIndex;return e<0?null:this.features.at(e)}get activeForm(){if("batch"===this.mode)return this.sharedForm;const e=this._workingFeatures.at(this.activeFeatureIndex);return e?(this._featureFormMap.has(e)||this._featureFormMap.set(e,this._makeBatchFormInputsForFeature(e)),this._featureFormMap.get(e)):E}get activeFormIsValid(){return!0}get allHiddenErrors(){const e=this.hiddenIndividualFormErrors,t=this.hiddenSharedFormErrors;return Array.from(new Set([...e,...t]))}get features(){return this._get("features")??new r}set features(e){this._set("features",o(e,this._get("features")))}get hiddenIndividualFormErrors(){if("batch"===this.mode)return[];const e=[];return this.activeForm.inputs.forEach((t=>{!1!==t.visible||t.valid||e.push(t)})),e}get hiddenSharedFormErrors(){const e=[];return this.sharedForm?.inputs.forEach((t=>{!1!==t.visible||t.valid||e.push(t)})),e}get submittable(){return this.valid,!0}get updating(){return this._updatingHandles.updating}get valid(){return!0}get layers(){const e=new Set;return this.features.forEach((t=>{const r=t.sourceLayer??t.layer;e.add(r)})),Array.from(e)}get mode(){return this.activeFeatureIndex>-1?"single":"batch"}getValues(e){const t=this._workingFeatures.find((({original:t})=>t===e));if(!t)throw new s("feature-not-found","The given feature is not present in the BatchAttributeForm");return{...t.attributes}}setFieldInputValue(e,t){e.setValueFromUser(t),this.emit("value-change",{features:e.features.toArray().map((e=>e.original)),fieldName:e.fieldName,name:"value-change",value:t})}setValue(e,t){const r=p(this._activeFormInputsByFieldName,e,(()=>{const t=this.activeForm.allFieldInputs.find((t=>t.fieldName===e));if(!t)throw new s("no-FieldInput-found",`Cannot set the value of field '${e}' because there is no FieldInput representing it`);return t}));this.setFieldInputValue(r,t)}validate(){return!1}getCodedValueOptions(e){return e.codedValues.map((({name:e,code:t})=>({name:e,value:t})))}_makeBatchFormInputsForFeature(e){const t=this._layerTemplateMap.get(e.layer);if(!t){const{layer:t}=e;return T().error(new s("no-form-template",`No form template found for layer ${t.id}: ${t.title}`)),E}return _(t,new r([e]))}async _prepare(){u(this._prepareTask);const e=t((async e=>{l(e);const t=new Map;for(const o of this.layers){const e=await j(o,{arcadeExecutorProvider:this._arcadeExecutorProvider});this._layerTemplateMap.set(o,e);for(const r of e.elements){const{elementId:e}=r;if(t.has(e)){const s=r.getExpressionExecutorsForLayer(o);if(I(r)){const a=r.elements.map((e=>e.getExpressionExecutorsForLayer(o)));t.get(e).addLayer(o,s,a)}else t.get(e).addLayer(o,s)}else t.set(e,r.clone())}}const r=new w({elements:Array.from(t.values())});this.sharedFormTemplate=r,this.sharedForm=_(r,this._workingFeatures)}));this._updatingHandles.addPromise(e.promise),this._prepareTask=e}};e([h({readOnly:!0})],x.prototype,"activeFeature",null),e([h()],x.prototype,"activeFeatureIndex",void 0),e([h({readOnly:!0})],x.prototype,"activeForm",null),e([h()],x.prototype,"activeFormIsValid",null),e([h()],x.prototype,"disabled",void 0),e([h()],x.prototype,"editType",void 0),e([h()],x.prototype,"features",null),e([h()],x.prototype,"hiddenIndividualFormErrors",null),e([h()],x.prototype,"updating",null),e([h()],x.prototype,"valid",null),e([h()],x.prototype,"layers",null),e([h()],x.prototype,"mode",null),e([h()],x.prototype,"sharedForm",void 0),e([h()],x.prototype,"sharedFormTemplate",void 0),e([h()],x.prototype,"userHasChangedValues",void 0),e([h()],x.prototype,"_arcadeExecutorProvider",void 0),e([h()],x.prototype,"_prepareTask",void 0),e([h()],x.prototype,"_layerTemplateMap",void 0),e([h()],x.prototype,"_workingFeatures",void 0),x=e([f("esri.widgets.BatchAttributeForm.BatchAttributeFormViewModel")],x);const M=x;export{M as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const e="esri-batch-attribute-form",t=`${e}__group`,
|
|
5
|
+
const e="esri-batch-attribute-form",t=`${e}__group`,i=`${e}__input`,n={base:e,form:`${e}__form`,formHeader:`${e}__form-header`,label:`${e}__label`,labelTextContent:`${e}__label-text-content`,fieldInput:`${i}`,inputRadio:`${i}--radio`,inputRadioGroup:`${i}--radio-group`,inputRadioLabel:`${i}--radio-label`,inputDisabled:`${i}--disabled`,inputSwitch:`${i}--switch`,centeredButton:`${e}__centered-button`,description:`${e}__description-text`,dateInputContainer:`${`${e}__date`}-input-container`,block:`${e}__block`,group:t,groupSequential:`${t}--sequential`,individualElement:`${t}__individual-element`};export{n as css};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../core/Error.js";import
|
|
5
|
+
import e from"../../../../core/Error.js";import r from"../../../../core/Logger.js";import{isFieldElement as t,isGroupElement as o}from"../../../../form/support/formUtils.js";import{getLowerCaseEditTrackingFields as n,isFieldVisibleByDefault as s}from"../../../../layers/support/fieldUtils.js";import{makeExpressionInfosMap as i,makeExecutorSetForFormElement as a}from"../../expressions/expressionUtils.js";import l from"../BatchFormTemplate.js";import{FieldElementTemplate as c}from"../FieldElementTemplate.js";import{GroupElementTemplate as m}from"../GroupElementTemplate.js";const p=()=>r.getLogger("esri.widgets.BatchAttributeForm.templates.templateUtils");async function d(e,r){return null!=e.formTemplate?u(e,r):f(e,r)}async function f(e,{arcadeExecutorProvider:r}){const t=new Set(n(e)),o={arcadeExecutorProvider:r,editTrackingFields:t,layer:e},s=[];for(const n of e.fields)E(n,e,t)&&s.push(h(n,o));const i=await Promise.all(s);return new l({elements:i})}async function u(e,r){const t=e.formTemplate;if(!t)return f(e,r);const o=i(t.expressionInfos),n={description:t.description,elements:new Array,title:t.title},{elements:s}=t;if(!s)return new l(n);const{arcadeExecutorProvider:a}=r;for(const i of s)try{n.elements.push(await y(i,{arcadeExecutorProvider:a,expressionInfos:o,layer:e}))}catch(c){p().warn(c)}return new l(n)}async function y(r,n){if(t(r))return w(r,n);if(o(r))return x(r,n);throw new e("batch-attribute-form:unsupported-element-type",`Form elements of type ${r.type} are not supported`)}async function w(r,{arcadeExecutorProvider:t,expressionInfos:o,layer:n}){const{fieldsIndex:s}=n,{description:i,domain:l,fieldName:m,hint:p,input:d,label:f}=r;if(null==m||!s.has(m))throw new e("batch-attribute-form:invalid-form-element",`Field element with label '${f}' does not refer to a valid field`);const u={description:i,domain:l,field:s.get(m),hint:p,input:d,label:f},y=new c(u),w=await a({element:r,expressionInfos:o,provider:t});return y.addLayer(n,w),y}async function x(e,r){const{arcadeExecutorProvider:t,expressionInfos:o,layer:n}=r,{description:s,label:i}=e,l={description:s,elements:[],label:i};for(const a of e.elements)try{l.elements.push(await y(a,r))}catch{continue}const c=new m(l),p=await a({element:e,expressionInfos:o,provider:t}),d=c.elements.map((e=>e.getExpressionExecutorsForLayer(n)));return c.addLayer(n,p,d),c}async function h(e,{arcadeExecutorProvider:r,layer:t}){const o=new c({field:e,label:e.alias??e.name}),n={};return e.editable&&t.userHasUpdateItemPrivileges&&(n.editableExpression=await r.getArcadeExecutor("true")),o.addLayer(t,n),o}function E(e,r,t){return!t.has(e.name.toLowerCase())&&s(e,r)}export{u as convertFormTemplateToBatchFormTemplate,d as createBatchFormTemplate,f as createBatchFormTemplateFromFields};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import"../core/has.js";import{property as t}from"../core/accessorSupport/decorators/property.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";import
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import"../core/has.js";import{property as t}from"../core/accessorSupport/decorators/property.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";import n from"./Widget.js";import o from"./BatchAttributeForm/BatchAttributeFormViewModel.js";import{css as r}from"./BatchAttributeForm/css.js";import{VisibleElements as s}from"./BatchAttributeForm/VisibleElements.js";import{isGroupInput as a,isFieldInput as l}from"./BatchAttributeForm/inputs/support/inputUtils.js";import{loadCalciteComponents as d}from"./support/componentsUtils.js";import{isDateType as p,isNumberType as c,getLabelForDateFieldValue as u}from"./support/dateUtils.js";import{globalCss as m}from"./support/globalCss.js";import{Heading as b}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as h}from"./support/decorators/messageBundle.js";import{tsx as v}from"./support/jsxFactory.js";import{substitute as f}from"../intl/substitute.js";let y=class extends n{constructor(e,t){super(e,t),this.headingLevel=2,this.messagesCommon=null,this.messages=null,this.readOnly=!1,this.viewModel=new o,this.visibleElements=new s}loadDependencies(){return d({input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button.js"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js")})}get activeFeatureIndex(){return this.viewModel.activeFeatureIndex}set activeFeatureIndex(e){this.viewModel.activeFeatureIndex=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get icon(){return"edit-attributes"}set icon(e){this._overrideIfSome("icon",e)}render(){return v("div",{class:this.classes(r.base,m.widget,m.panel)},this._renderForm())}_renderForm(){return"single"!==this.viewModel.mode?v("div",null,v("form",null,this._renderHeader(),this._renderContent())):v("div",null)}_renderHeader(){const e="title",t="description",i=v(b,{key:"title",level:this.headingLevel},e),n=v("p",{key:"description"},t);return e||t?v("div",null,i,n):null}_renderContent(){const{inputs:e}=this.viewModel.activeForm;return e.items.filter((e=>e.visible)).map((e=>this._renderInput(e)))}_renderInput(e){return a(e)?this._renderGroupInput(e):l(e)?this._renderLabeledField(e):void 0}_renderGroupInput(e){const{inputs:t,template:i}=e,n=t.filter((e=>e.visible));return v("calcite-block",{class:this.classes(r.group,r.groupSequential,r.block),collapsible:!0,description:i.description??void 0,disabled:!1,heading:i.label??"",headingLevel:this.headingLevel,key:`{${i.elementId}-key}`,open:!0},n.map((e=>this._renderInput(e))))}_renderLabeledField(e){const{fieldName:t,description:i,label:n,field:o,elementId:s}=e.template,a=o.nullable,l=a?f(this.messages.requiredFieldLabel,{name:n}):n;return v("calcite-label",{"aria-label":l,class:r.label,key:`field--${s}`},v("div",{class:r.labelTextContent,key:"labelTextContainer"},n,i?v("span",{title:`${t}`},i):void 0,a?v("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),o.editable?this._renderFieldInput(e):this._renderReadOnlyComponent(e))}_renderFieldInput(e){const t=this.getCommonInputProps(e),{template:i}=e;if(i.input){const{type:n}=i.input;if(p(n))return this._renderDateComponents(e,t);if("coded-value"===i.field.domain?.type){const{domain:o}=i.field;return this._renderCodedInputs({input:e,domain:o,type:n,props:t})}return c(n)?this._renderNumberComponent(e,t):this._renderStringComponent(e,t)}return null}_renderCodedInputs({input:e,domain:t,type:i,props:n}){const o=this.viewModel.getCodedValueOptions(t);switch(i){case"combo-box":return this._renderComboBoxComponent({input:e,options:o,props:n});case"switch":return this._renderSwitchComponent(n);case"radio-buttons":return this._renderRadioButtonGroupComponent({input:e,options:o,props:n});default:return null}}_renderSwitchComponent(e){return v("calcite-switch",{...e,checked:!1,class:r.inputSwitch})}_renderComboBoxComponent({input:e,options:t,props:i}){const{label:n,field:o}=e.template,r=t.map((e=>this.renderComboboxItem({value:`${e.value}`,text:e.name,selected:o.defaultValue===e.value.toString()})));return v("calcite-combobox",{...i,label:n??"",selectionMode:"single"},r)}renderComboboxItem({text:e,value:t,selected:i}){return v("calcite-combobox-item",{key:t,selected:i,textLabel:e,value:t})}_renderRadioButtonGroupComponent({input:e,options:t,props:i}){const n=t.map((({name:t,value:i})=>this._renderRadioButtons({label:t,name:t,value:i,checked:i===e.template.field.defaultValue})));return v("calcite-radio-button-group",{...i,layout:"vertical",name:i.label??""},n)}_renderRadioButtons({name:e,value:t,checked:i,label:n}){return v("calcite-label",{class:r.inputRadioLabel,key:e,layout:"inline"},v("calcite-radio-button",{checked:i,name:e,value:`${t}`}),n)}_renderStringComponent(e,t){const{template:i}=e;return i.field.editable?i.input&&"text-area"===i.input.type?v("calcite-text-area",{...t,class:this.classes(r.group,r.groupSequential,r.individualElement),resize:"vertical"}):v("calcite-input",{...t,class:this.classes(r.group,r.groupSequential,r.individualElement),type:"text"}):this._renderReadOnlyComponent(e)}_renderNumberComponent(e,t){return v("calcite-input-number",{...t,type:"number",value:e.template.field.defaultValue?e.template.field.defaultValue.toString():void 0})}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return v("calcite-input",{class:this.classes(r.fieldInput,r.inputDisabled,r.individualElement),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderDateComponents(e,t){const{input:i}=e.template;switch(i?.type){case"datetime-picker":return this._renderDateFieldComponents(t);case"date-picker":return this._renderDateOnlyFieldComponent(t);case"time-picker":return this._renderTimeOnlyFieldComponent(t);case"datetimeoffset-picker":return this._renderTimestampOffsetFieldComponents(t);default:return this._renderReadOnlyComponent(e,u(e.field,t.value))}}_renderDateOnlyFieldComponent(e){const{class:t,key:i}=e;return v("calcite-input-date-picker",{class:t,"data-date-part":"date","data-field-name":"fieldNameAttribute",key:`${i}-date-input`,overlayPositioning:"fixed",value:void 0})}_renderTimeOnlyFieldComponent(e){const{class:t,key:i}=e;return v("calcite-input-time-picker",{class:t,"data-date-part":"time","data-field-name":"fieldNameAttribute",key:`${i}-time-input`,overlayPositioning:"fixed",value:void 0})}_renderTimestampOffsetFieldComponents(e){const{class:t,key:i}=e;return v("div",{class:r.dateInputContainer,key:`${i}-date-time-container`},v("calcite-input-date-picker",{class:t,"data-date-part":"date",key:`${i}-date-input`,value:void 0}),v("calcite-input-time-picker",{class:t,"data-date-part":"time",key:`${i}-time-input`,value:void 0}),null)}_renderDateFieldComponents(e){const{class:t,key:i}=e;return v("div",{class:r.dateInputContainer,key:`${i}-date-time-container`},v("calcite-input-date-picker",{class:t,"data-date-part":"date",key:`${i}-date-input`,value:void 0}),v("calcite-input-time-picker",{"data-date-part":"time",key:`${i}-time-input`,step:1,value:void 0}))}getCommonInputProps(e){const{disabled:t}=this,{template:i,field:n,valid:o}=e,{editable:s,name:a,nullable:l,defaultValue:d}=n,p=e.userHasChangedValue,c=!s||t;return{"aria-invalid":o?"false":"true",class:this.classes(r.fieldInput,c?r.inputDisabled:null),status:p&&!o?"invalid":"idle",key:i.elementId,label:a,placeholder:i.hint??void 0,readOnly:c,required:!l,value:null==d?"":`${d}`}}};e([t()],y.prototype,"activeFeatureIndex",null),e([t()],y.prototype,"disabled",null),e([t()],y.prototype,"features",null),e([t()],y.prototype,"headingLevel",void 0),e([t()],y.prototype,"icon",null),e([t(),h("esri/t9n/common")],y.prototype,"messagesCommon",void 0),e([t(),h("esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm")],y.prototype,"messages",void 0),e([t()],y.prototype,"readOnly",void 0),e([t()],y.prototype,"viewModel",void 0),e([t({type:s,nonNullable:!0})],y.prototype,"visibleElements",void 0),y=e([i("esri.widgets.BatchAttributeForm")],y);const g=y;export{g as default};
|