@arcgis/core 4.30.0-next.20240311 → 4.30.0-next.20240313
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/SceneViewer/layerUtils.d.ts +4 -0
- package/applications/SceneViewer/layerUtils.js +5 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{182f94904b6eb611b886.js → 052005514ce006ce0027.js} +1 -1
- package/assets/esri/core/workers/chunks/078397f7c17a9bbbf8c0.js +1 -0
- package/assets/esri/core/workers/chunks/{f0cd48d5f5f09ed01773.js → 08c9226e24b2261388e3.js} +1 -1
- package/assets/esri/core/workers/chunks/129ea550bf7ad7ad24f9.js +1 -0
- package/assets/esri/core/workers/chunks/196b5917e41da7b60cde.js +1 -0
- package/assets/esri/core/workers/chunks/{bfef87eb228c96004a4a.js → 1f385cd347b7735d505b.js} +1 -1
- package/assets/esri/core/workers/chunks/{49a715520999bbfab18d.js → 1f5b7880ccf47ef9229d.js} +5 -5
- package/assets/esri/core/workers/chunks/1f79a9bf849134b95bb6.js +1 -0
- package/assets/esri/core/workers/chunks/{523903a812624d0d6d06.js → 2427699e34e1895ed024.js} +1 -1
- package/assets/esri/core/workers/chunks/{83d39f990223ca97a320.js → 28ccc007bc898af2187c.js} +1 -1
- package/assets/esri/core/workers/chunks/2ceebeac397374a126ba.js +2 -0
- package/assets/esri/core/workers/chunks/300062b53d90ba3d8b09.js +1 -0
- package/assets/esri/core/workers/chunks/{c8634493442e8e1ce32b.js → 4b70d2db1cd9ddf4b453.js} +1 -1
- package/assets/esri/core/workers/chunks/{86fe8077986a991f0462.js → 500f39a5f74fa289df25.js} +1 -1
- package/assets/esri/core/workers/chunks/604dae6ff05ff4ac516b.js +1 -0
- package/assets/esri/core/workers/chunks/6204698fb1f20f1b41fe.js +1 -0
- package/assets/esri/core/workers/chunks/67ab6af927ea04c01a40.js +1 -0
- package/assets/esri/core/workers/chunks/67abe8171d41cf21624f.js +1 -0
- package/assets/esri/core/workers/chunks/7ae3b1a39ca4963ece12.js +1 -0
- package/assets/esri/core/workers/chunks/7ce30bf0770b2b8c6f82.js +1 -0
- package/assets/esri/core/workers/chunks/{16da21e329db54ccf49b.js → 893d96c21d929d38ab58.js} +1 -1
- package/assets/esri/core/workers/chunks/8a98d957bfcbfe69786d.js +1 -0
- package/assets/esri/core/workers/chunks/9656002ff528a7eda746.js +1 -0
- package/assets/esri/core/workers/chunks/99283ac67e6b73695df7.js +1 -0
- package/assets/esri/core/workers/chunks/9b70ef60e2e01b087d08.js +1 -0
- package/assets/esri/core/workers/chunks/a689f1ff4c6ae02b07ae.js +1 -0
- package/assets/esri/core/workers/chunks/ab3136c47c5fa8301980.js +1 -0
- package/assets/esri/core/workers/chunks/{9326343d8d4a66b96b01.js → b93e601da1592f153a3d.js} +1 -1
- package/assets/esri/core/workers/chunks/b9e8c2e2c5b4c9564319.js +1 -0
- package/assets/esri/core/workers/chunks/bb33e00cbd80fecc5606.js +1 -0
- package/assets/esri/core/workers/chunks/{6dbbfbaa37f4f6bf2120.js → c67b99d2a8376a15a71b.js} +1 -1
- package/assets/esri/core/workers/chunks/c76e155332aa0491de3d.js +1 -0
- package/assets/esri/core/workers/chunks/cccf63c65070c6a47b16.js +1 -0
- package/assets/esri/core/workers/chunks/cd425259ffa675ce7373.js +1 -0
- package/assets/esri/core/workers/chunks/{33821f2e70375d8dd01f.js → d2e4c01e33691801f9ef.js} +1 -1
- package/assets/esri/core/workers/chunks/d6becb4a089310101448.js +1 -0
- package/assets/esri/core/workers/chunks/da7189c3077f49858dc8.js +1 -0
- package/assets/esri/core/workers/chunks/dd5a078b7919f749ba3e.js +1 -0
- package/assets/esri/core/workers/chunks/f7cfdba77cb614fd3725.js +1 -0
- package/assets/esri/core/workers/chunks/f9427ac73435d1726d6c.js +1 -0
- package/assets/esri/core/workers/chunks/ff4151d794ec73064fac.js +1 -0
- package/chunks/Jpg.js +1 -1
- package/chunks/arcgis-knowledge-client-core-simd.js +1 -1
- package/chunks/arcgis-knowledge-client-core.js +1 -1
- package/chunks/geometryEngineBase.js +1 -1
- package/chunks/i3s.js +1 -1
- package/chunks/lclayout.js +1 -1
- package/chunks/lerc-wasm.js +1 -1
- package/chunks/libtess-asm.js +1 -1
- package/chunks/lyr3DMain.js +1 -1
- package/chunks/lyr3DWorker.js +1 -1
- package/chunks/pe-wasm.js +1 -1
- package/chunks/vxlLayer.js +1 -1
- package/core/image/apng.js +1 -1
- package/core/image/gif.js +1 -1
- package/core/mathUtils.js +1 -1
- package/core/pbf.js +1 -1
- package/core/sql/WhereGrammar.js +1 -1
- package/geohash/geohashUtils.js +1 -1
- package/interfaces.d.ts +24 -8
- package/layers/BingMapsLayer.js +1 -1
- package/layers/effects/parser.js +1 -1
- package/layers/graphics/data/QueryEngine.js +1 -1
- package/layers/mixins/SceneService.js +1 -1
- package/layers/support/ExportImageServiceParameters.js +1 -1
- package/layers/support/LayerContingentValuesCache.js +1 -1
- package/layers/support/LercWorker.js +1 -1
- package/layers/support/PixelBlock.js +1 -1
- package/layers/support/Tilemap.js +1 -1
- package/layers/support/rasterDatasets/BaseRaster.js +1 -1
- package/layers/support/rasterDatasets/CloudRaster.js +1 -1
- package/layers/support/rasterDatasets/FunctionRaster.js +1 -1
- package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
- package/layers/support/rasterDatasets/MRFRaster.js +1 -1
- package/layers/support/rasterDatasets/TIFFRaster.js +1 -1
- package/layers/support/rasterDatasets/WCSRaster.js +1 -1
- package/layers/support/rasterFormats/TiffDecoder.js +1 -1
- package/layers/support/rasterFunctions/ExtractBandFunction.js +1 -1
- package/layers/video/VideoController.js +1 -1
- package/package.json +3 -3
- package/request.js +1 -1
- package/rest/featureService/FeatureService.js +1 -1
- package/rest/symbolService.js +1 -1
- package/support/elevationInfoUtils.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/interactive/editingTools/ControlPointsTransformTool.js +1 -1
- package/views/2d/interactive/editingTools/TransformTool.js +1 -1
- package/views/2d/interactive/editingTools/manipulations/DragManipulation.js +1 -1
- package/views/2d/interactive/editingTools/manipulations/RotateManipulation.js +1 -1
- package/views/2d/interactive/editingTools/manipulations/ScaleManipulation.js +1 -1
- package/views/2d/layers/features/support/AttributeStore.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementPathHelper.js +1 -1
- package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
- package/views/3d/camera/constraintUtils/common.js +1 -1
- package/views/3d/interactive/editingTools/ManipulatedObjectGraphic3D.js +5 -0
- package/views/3d/interactive/editingTools/dragEventPipeline3D.js +1 -1
- package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
- package/views/3d/interactive/editingTools/{isSupportedGraphicUtils.js → isSupportedObjectUtils.js} +1 -1
- package/views/3d/interactive/editingTools/lineObjectVisualElementUtils.js +5 -0
- package/views/3d/interactive/editingTools/manipulatedObjectUtils.js +5 -0
- package/views/3d/interactive/editingTools/manipulations/MoveManipulation.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/MoveXYAxisManipulation.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/MoveXYDiscManipulation.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/MoveXYObjectManipulation.js +5 -0
- package/views/3d/interactive/editingTools/manipulations/MoveZManipulation.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/moveUtils.js +1 -1
- package/views/3d/interactive/editingTools/manipulatorUtils.js +1 -1
- package/views/3d/interactive/editingTools/meshFastUpdateUtils.js +1 -1
- package/views/3d/interactive/editingTools/move/MoveTool3D.js +5 -0
- package/views/3d/interactive/editingTools/move/isSupportedObject.js +5 -0
- package/views/3d/interactive/editingTools/originGeometryVisualElementUtils.js +5 -0
- package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +5 -0
- package/views/3d/interactive/editingTools/reshape/ReshapeTool3D.js +5 -0
- package/views/3d/interactive/editingTools/reshape/isSupportedObject.js +5 -0
- package/views/3d/interactive/editingTools/settings.js +1 -1
- package/views/3d/interactive/editingTools/transform/ExtentTransformTool.js +5 -0
- package/views/3d/interactive/editingTools/{transformGraphic → transform}/ScaleRotateMeshAdapter.js +1 -1
- package/views/3d/interactive/editingTools/{transformGraphic → transform}/ScaleRotateObjectSymbol3DAdapter.js +1 -1
- package/views/3d/interactive/editingTools/transform/ScaleRotateTransform.js +5 -0
- package/views/3d/interactive/editingTools/transform/TransformTool3D.js +5 -0
- package/views/3d/interactive/editingTools/transform/extentTransform/ExtentMove.js +5 -0
- package/views/3d/interactive/editingTools/transform/extentTransform/ExtentRotate.js +5 -0
- package/views/3d/interactive/editingTools/transform/extentTransform/ExtentScale.js +5 -0
- package/views/3d/interactive/editingTools/transform/extentTransform/PreserveAspectRatio.js +5 -0
- package/views/3d/interactive/editingTools/transform/extentTransform/extentUtils.js +5 -0
- package/views/3d/interactive/editingTools/transform/isSupportedGraphic.js +5 -0
- package/views/3d/interactive/editingTools/transform/undoRecords.js +5 -0
- package/views/3d/interactive/editingTools/visualElementUtils.js +1 -1
- package/views/3d/interactive/editingTools.js +1 -1
- package/views/3d/interactive/manipulatorUtils.js +1 -1
- package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
- package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/MediaLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DGraphic.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLodInstanceGraphicLayer.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
- package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
- package/views/3d/layers/i3s/PagedNodeIndex.js +1 -1
- package/views/3d/layers/i3s/PointCloudWorkerUtil.js +1 -1
- package/views/3d/state/ConstraintsManager.js +1 -1
- package/views/3d/state/ViewState.js +1 -1
- package/views/3d/support/LaserlinePathData.js +1 -1
- package/views/3d/support/orientedBoundingBox.js +1 -1
- package/views/3d/terrain/PatchRenderData.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/Tile.js +1 -1
- package/views/3d/terrain/TileRenderer.js +1 -1
- package/views/3d/terrain/TilingScheme.js +1 -1
- package/views/3d/terrain/tileUtils.js +1 -1
- package/views/3d/webgl-engine/collections/Component/DepthRange.js +1 -1
- package/views/3d/webgl-engine/lib/ComponentUtils.js +1 -1
- package/views/3d/webgl-engine/lib/DDSUtil.js +1 -1
- package/views/3d/webgl-engine/lib/MagnifierHelper.js +1 -1
- package/views/3d/webgl-engine/lib/Material.js +1 -1
- package/views/3d/webgl-engine/lib/Object3DStateSet.js +1 -1
- package/views/3d/webgl-engine/lib/Octree.js +1 -1
- package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/TextRenderParameters.js +1 -1
- package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeWorkerHandle.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/InstanceData.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
- package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
- package/views/draw/DrawAction.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/draw/SegmentDrawAction.js +1 -1
- package/views/draw/support/Box.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/input/InputManager.js +1 -1
- package/views/interactive/dragEventPipeline.js +1 -1
- package/views/interactive/editGeometry/EditGeometry.js +1 -1
- package/views/interactive/editGeometry/EditGeometryOperations.js +1 -1
- package/views/interactive/editGeometry/operations/MoveMesh.js +5 -0
- package/views/interactive/editGeometry/operations/SetAllVertexPositions.js +5 -0
- package/views/interactive/tooltip/TranslateTooltipInfos.js +1 -1
- package/views/interactive/tooltip/content/{TooltipContentTranslateGraphic.js → TooltipContentTranslate.js} +1 -1
- package/views/interactive/tooltip/content/{TooltipContentTranslateGraphicXY.js → TooltipContentTranslateXY.js} +1 -1
- package/views/interactive/tooltip/content/{TooltipContentTranslateGraphicZ.js → TooltipContentTranslateZ.js} +1 -1
- package/views/interactive/tooltip/content/tooltipContentFactory.js +1 -1
- package/widgets/AreaMeasurement2D/AreaMeasurement2DTool.js +1 -1
- package/widgets/DistanceMeasurement2D/DistanceMeasurement2DTool.js +1 -1
- package/widgets/ElevationProfile/support/InputRepresentation3D.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/UtilityNetworkTrace/support/ResultAreaHandler.js +1 -1
- package/assets/esri/core/workers/chunks/0008d178ba41307f7bb4.js +0 -1
- package/assets/esri/core/workers/chunks/0272af5adbbd4482f50d.js +0 -1
- package/assets/esri/core/workers/chunks/07f017d3af8051577cae.js +0 -1
- package/assets/esri/core/workers/chunks/13901677c9a53d6e814c.js +0 -1
- package/assets/esri/core/workers/chunks/16f1ede633a712a555a6.js +0 -1
- package/assets/esri/core/workers/chunks/2801fa3eeb6511324632.js +0 -1
- package/assets/esri/core/workers/chunks/40eb89485beba79167e0.js +0 -1
- package/assets/esri/core/workers/chunks/41b4d651db6376fb3609.js +0 -1
- package/assets/esri/core/workers/chunks/4e6091bf95d1042eecd2.js +0 -1
- package/assets/esri/core/workers/chunks/615edb84daad08678931.js +0 -1
- package/assets/esri/core/workers/chunks/618393798d39655debf5.js +0 -1
- package/assets/esri/core/workers/chunks/61d903fe9200dced54df.js +0 -1
- package/assets/esri/core/workers/chunks/771b95d28e1c9a14df64.js +0 -1
- package/assets/esri/core/workers/chunks/79f36c3a2026c2f35fb0.js +0 -1
- package/assets/esri/core/workers/chunks/8526061e12755d6ddfd1.js +0 -2
- package/assets/esri/core/workers/chunks/899b4539e516f44c51af.js +0 -1
- package/assets/esri/core/workers/chunks/9ecc225c87ba2637a298.js +0 -1
- package/assets/esri/core/workers/chunks/ab1b23decd5bae49155a.js +0 -1
- package/assets/esri/core/workers/chunks/ac95efd57f7c1472698a.js +0 -1
- package/assets/esri/core/workers/chunks/b20412f08361ba99f73e.js +0 -1
- package/assets/esri/core/workers/chunks/b226161c2ad448347689.js +0 -1
- package/assets/esri/core/workers/chunks/b70be572d509557428f4.js +0 -1
- package/assets/esri/core/workers/chunks/bbedc4ff3d0aadbde16a.js +0 -1
- package/assets/esri/core/workers/chunks/c16ed88e7733b1d31041.js +0 -1
- package/assets/esri/core/workers/chunks/cb9d1f24ebd4763412df.js +0 -1
- package/assets/esri/core/workers/chunks/d206f750dd2933c7e6b0.js +0 -1
- package/assets/esri/core/workers/chunks/d54500cf91321b705565.js +0 -1
- package/assets/esri/core/workers/chunks/e538d269ff6c79a8fd3b.js +0 -1
- package/assets/esri/core/workers/chunks/ea7e4f72a5b65ecb1c23.js +0 -1
- package/views/3d/interactive/editingTools/lineGraphicVisualElementUtils.js +0 -5
- package/views/3d/interactive/editingTools/manipulations/MoveXYGraphicManipulation.js +0 -5
- package/views/3d/interactive/editingTools/moveGraphic/GraphicMoveTool.js +0 -5
- package/views/3d/interactive/editingTools/moveGraphic/isSupportedGraphic.js +0 -5
- package/views/3d/interactive/editingTools/originGraphicVisualElementUtils.js +0 -5
- package/views/3d/interactive/editingTools/reshapeGraphic/GraphicReshapeTool.js +0 -5
- package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +0 -5
- package/views/3d/interactive/editingTools/reshapeGraphic/isSupportedGraphic.js +0 -5
- package/views/3d/interactive/editingTools/transformGraphic/ExtentMove.js +0 -5
- package/views/3d/interactive/editingTools/transformGraphic/ExtentRotate.js +0 -5
- package/views/3d/interactive/editingTools/transformGraphic/ExtentScale.js +0 -5
- package/views/3d/interactive/editingTools/transformGraphic/ExtentTransformTool.js +0 -5
- package/views/3d/interactive/editingTools/transformGraphic/GraphicScaleRotateTransform.js +0 -5
- package/views/3d/interactive/editingTools/transformGraphic/GraphicTransformTool.js +0 -5
- package/views/3d/interactive/editingTools/transformGraphic/PreserveAspectRatio.js +0 -5
- package/views/3d/interactive/editingTools/transformGraphic/extentUtils.js +0 -5
- package/views/3d/interactive/editingTools/transformGraphic/isSupportedGraphic.js +0 -5
- package/views/3d/interactive/editingTools/transformGraphic/undoRecords.js +0 -5
- /package/assets/esri/core/workers/chunks/{8526061e12755d6ddfd1.js.LICENSE.txt → 2ceebeac397374a126ba.js.LICENSE.txt} +0 -0
- /package/views/3d/interactive/editingTools/{reshapeGraphic → reshape}/edgeOffsetUtils.js +0 -0
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import o from"../../../../Color.js";import{isCachedFontFace as t,loadFont as e}from"../../../../core/fontUtils.js";import
|
|
5
|
+
import o from"../../../../Color.js";import{isCachedFontFace as t,loadFont as e}from"../../../../core/fontUtils.js";import i from"../../../../core/Logger.js";import{pt2px as r}from"../../../../core/screenUtils.js";import{ZEROS as n}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";class s{constructor(o){this.definition=o,this.key=JSON.stringify(o),this.haloSize=Math.round(o.halo.size),this.textStyle=a(o.color),this.haloStyle=l(o.halo.color),this.backgroundStyle=0!==o.background.color[3]?a(o.background.color):null}fontString(o){const t=this.definition.font,e="sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji";return`${t.style} ${t.weight} ${o}px ${t.family}, ${e}`}setFontProperties(o,t){o.font=this.fontString(t),o.textAlign="left",o.textBaseline="alphabetic"}static async fromSymbol(l,a){const f=l?.material?.color,m=o.toUnitRGBA(f)??n,g=null!=l.size?r(l.size):12,u=l.lineHeight,d=null!=l.background?o.toUnitRGBA(l.background.color):n,h={family:l.font?.family??"sans-serif",decoration:l.font?.decoration??"none",weight:l.font?.weight??"normal",style:l.font?.style??"normal"},y=l.halo,b=null!=y?.color&&y.size>0?{size:r(y.size),color:o.toUnitRGBA(y.color)}:{size:0,color:n},p=new s({color:m,size:g,background:{color:d,padding:null!=l.background?[.65*g,.5*g]:[0,0],borderRadius:null!=l.background?g*(6/16):0},lineSpacingFactor:u,font:h,halo:b,pixelRatio:a});if(l.font){let o=!1;const r=p.fontString(g);try{o=(await document.fonts.load(r)).some((o=>!t(o)))}catch(S){i.getLogger("esri.views.3d.webgl-engine.lib.TextRenderParameters").warnOnce(`Failed to preload font '${r}'. Some text symbology may be rendered using the default browser font.`)}if(!o&&!c.has(l.font.family))try{await e(l.font)}catch(S){}}return p}}function l(o){return`rgb(${o.slice(0,3).map((o=>Math.floor(255*o))).toString()})`}function a(o){return`rgba(${o.slice(0,3).map((o=>Math.floor(255*o))).toString()},${o[3]})`}const c=new Set(["Arial","Times New Roman","Courier New","serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]);export{s as TextRenderParameters};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{unpackFloatRGBA as e}from"../../../../core/floatRGBA.js";import t from"../../../../core/PooledArray.js";import{multiply as r,copy as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{e as s}from"../../../../chunks/vec32.js";import{l as a}from"../../../../chunks/vec42.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{intersectsSphere as h,create as f,copy as c}from"../../../../geometry/support/frustum.js";import{g as l,d as
|
|
5
|
+
import{unpackFloatRGBA as e}from"../../../../core/floatRGBA.js";import t from"../../../../core/PooledArray.js";import{multiply as r,copy as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{e as s}from"../../../../chunks/vec32.js";import{l as a}from"../../../../chunks/vec42.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{intersectsSphere as h,create as f,copy as c}from"../../../../geometry/support/frustum.js";import{g as l,d as u}from"../../../../chunks/sphere.js";import{maxScale as _}from"../../support/mathUtils.js";import{empty as d,union as m,set as g,DepthRange as p}from"./depthRange.js";import b from"./Octree.js";import{assert as w}from"./Util.js";const v=1e4,R=100,j=500,C=500,A=.1;function B(t,r,i){return e(r,t)*(i[1]-i[0])+i[0]}function M(e,t,r){let i=0;if(!t.some((e=>!!e.materialReference&&(i+=e.numGeometries,i>=v))))return Q.compute(e,t);const n=d();return r.forAll((t=>m(n,O(e,t)))),n}function O(e,t){if(!t.visible)return;const r=d(),i=t.getSpatialQueryAccelerator();return i?x(r,e,i):D(r,e,t.objects),r}function x(e,t,r){const i=t.eye,n=t.viewForward,s=t.frustum,a=e=>e.visible,o=r.objectCount;if(o<j)g(G,t.near,Math.min(e.near,t.far)),r.forEachInDepthRange(i,n,b.DepthOrder.FRONT_TO_BACK,G,((r,i)=>{T(e,t,r),G.far=e.near,i.setRange(G)}),s,a),g(G,Math.max(e.far,t.near),t.far),r.forEachInDepthRange(i,n,b.DepthOrder.BACK_TO_FRONT,G,((r,i)=>{T(e,t,r),G.near=e.far,i.setRange(G)}),s,a);else{const i=Math.max(Math.min(o,C),Math.ceil(o*A)),h=r.findClosest(n,b.DepthOrder.FRONT_TO_BACK,s,a,i),f=r.findClosest(n,b.DepthOrder.BACK_TO_FRONT,s,a,i);h&&f&&(I(e,t,h.boundingVolumeWorldSpace.bounds),I(e,t,f.boundingVolumeWorldSpace.bounds))}}function D(e,t,r){U.clear(),r.forAll((e=>{e.visible&&0!==e.geometries.length&&U.add(e)})),U.empty||(U.sort(t),g(G,t.near,Math.min(e.near,t.far)),U.forEachInDepthRange(G,b.DepthOrder.FRONT_TO_BACK,((r,i)=>{i<e.near&&T(e,t,r)})),g(G,Math.max(e.far,t.near),t.far),U.forEachInDepthRange(G,b.DepthOrder.BACK_TO_FRONT,((t,r,i)=>{e.far=Math.max(e.far,i)})))}function T(e,t,i){if(!i.visible)return;if(!h(t.frustum,i.boundingVolumeWorldSpace.bounds))return;const n=i.transformation,s=k;i.geometries.forEach((i=>{r(s,n,i.transformation);const a=_(s);F(e,t,i.boundingInfo,s,a)}))}function F(e,t,r,i,n){if(null==r)return;s(l(V),r.center,i);const{eye:a,viewForward:o}=t,f=o[0]*(V[0]-a[0])+o[1]*(V[1]-a[1])+o[2]*(V[2]-a[2]);if(V[3]=r.radius*n,!(f-V[3]>e.near&&f+V[3]<e.far)&&h(t.frustum,V))if(r.radius>R&&r.getChildren())for(const s of r.getChildren())F(e,t,s,i,n);else q.unionDepthRangeWithAABB(e,t.viewProjectionMatrix,i,r.bbMin,r.bbMax)}function I(e,t,r){const i=t.eye,n=t.viewForward,s=(r[0]-i[0])*n[0]+(r[1]-i[1])*n[1]+(r[2]-i[2])*n[2];e.near=Math.min(e.near,s-r[3]),e.far=Math.max(e.far,s+r[3])}class y{constructor(){this._items=new t({allocator:e=>e||{object:null,distance:0,near:0,far:0},deallocator:e=>(e.object=null,e.distance=0,e.near=0,e.far=0,e)})}get length(){return this._items.length}get empty(){return 0===this._items.length}clear(){this._items.clear()}add(e){this._items.pushNew().object=e}sort(e){const t=e.eye,r=e.viewForward;this._items.forAll((e=>{const i=e.object.boundingVolumeWorldSpace.bounds,n=(i[0]-t[0])*r[0]+(i[1]-t[1])*r[1]+(i[2]-t[2])*r[2];e.distance=n,e.near=n-i[3],e.far=n+i[3]})),this._items.sort(((e,t)=>e.distance-t.distance))}forEachInDepthRange(e,t,r){if(t===b.DepthOrder.FRONT_TO_BACK)for(let i=0;i<this._items.length;++i){const t=this._items.data[i];t.far<e.near||t.near>e.far||r(t.object,t.near,t.far)}else for(let i=this._items.length-1;i>=0;--i){const t=this._items.data[i];t.far<e.near||t.near>e.far||r(t.object,t.near,t.far)}}}class P{constructor(){this._view=n(),this._viewProj=n(),this._frustum=f(),this._geometries=new Array,this._near=[],this._far=[],this._nearCandidates=[],this._farCandidates=[],this._looseRange={near:0,far:0}}compute(e,t){this._reset(),i(this._view,e.viewMatrix),r(this._viewProj,e.projectionMatrix,this._view),c(this._frustum,e.frustum);const n=this._view,s=n[2],a=n[6],o=n[10],h=n[14];t.forAll((e=>{e.materialReference&&e.forEachGeometry&&e.forEachGeometry((e=>{if(!e.visible||!e.castShadow)return;const t=e.boundingSphere,r=s*t[0]+a*t[1]+o*t[2]+h,i=r-t[3],n=r+t[3];this._geometries.push(e),this._near.push(-n),this._far.push(-i)}))}));const f=new p;if(0===this._geometries.length)return f;for(let r=0;r<this._geometries.length;++r)this._near[r]>f.far&&(f.far=this._near[r]),this._near[r]>2&&this._far[r]<f.near&&(f.near=this._far[r]);const l=this._looseRange;l.near=Math.max(.5*f.near,2),l.far=2*f.far;let u=0,_=0;for(let r=0;r<this._geometries.length;++r)this._near[r]<f.near&&(this._near[r]>=l.near?f.near=this._near[r]:this._nearCandidates[u++]=r),this._far[r]>f.far&&(this._far[r]<=l.far?f.far=this._far[r]:this._farCandidates[_++]=r);if(0===this._nearCandidates.length&&0===this._farCandidates.length)return f;this._nearCandidates.sort(((e,t)=>this._near[e]<this._near[t]?-1:this._near[e]>this._near[t]?1:0)),this._farCandidates.sort(((e,t)=>this._far[e]<this._far[t]?1:this._far[e]>this._far[t]?-1:0));for(let r=0;r<this._nearCandidates.length;++r){const e=this._nearCandidates[r];if(this._near[e]<f.near){const t=this._geometries[e],r=t.boundingInfo;this._includeNearBoundingInfoRec(r,t.shaderTransformation,f)}}for(let r=0;r<this._farCandidates.length;++r){const e=this._farCandidates[r];if(this._far[e]>f.far){const t=this._geometries[e],r=t.boundingInfo;this._includeFarBoundingInfoRec(r,t.shaderTransformation,f)}}return this._reset(),f}_reset(){this._geometries.length=0,this._near.length=0,this._far.length=0,this._nearCandidates.length=0,this._farCandidates.length=0}_includeNearBoundingInfoRec(e,t,r){if(null==e)return;const i=e.center;s(l(V),i,t);const n=_(t),a=V[0],o=V[1],h=V[2],f=e.radius*n,c=this._frustum;if(c[0][0]*a+c[0][1]*o+c[0][2]*h+c[0][3]>f||c[1][0]*a+c[1][1]*o+c[1][2]*h+c[1][3]>f||c[2][0]*a+c[2][1]*o+c[2][2]*h+c[2][3]>f||c[3][0]*a+c[3][1]*o+c[3][2]*h+c[3][3]>f)return;const u=this._view[2]*a+this._view[6]*o+this._view[10]*h+this._view[14],d=u+f;if(!(-(u-f)<2||-d>=r.near))if(-d>this._looseRange.near)r.near=-d;else{if(f>R){const i=e.getChildren();if(void 0!==i){for(const e of i)this._includeNearBoundingInfoRec(e,t,r);return}}q.unionDepthRangeWithAABB(r,this._viewProj,t,e.bbMin,e.bbMax)}}_includeFarBoundingInfoRec(e,t,r){if(null==e)return;let i=e.radius;const n=e.center;s(l(V),n,t);const a=_(t),o=V[0],h=V[1],f=V[2];i*=a;const c=this._frustum;if(c[0][0]*o+c[0][1]*h+c[0][2]*f+c[0][3]>i||c[1][0]*o+c[1][1]*h+c[1][2]*f+c[1][3]>i||c[2][0]*o+c[2][1]*h+c[2][2]*f+c[2][3]>i||c[3][0]*o+c[3][1]*h+c[3][2]*f+c[3][3]>i)return;const u=this._view[2]*o+this._view[6]*h+this._view[10]*f+this._view[14]-i;if(!(-u<=r.far))if(-u<this._looseRange.far)r.far=-u;else{if(i>R){const i=e.getChildren();if(void 0!==i){for(const e of i)this._includeFarBoundingInfoRec(e,t,r);return}}q.unionDepthRangeWithAABB(r,this._viewProj,t,e.bbMin,e.bbMax)}}}class N{constructor(){this._modelViewProj=n(),this._clipPosition=[o(),o(),o(),o(),o(),o(),o(),o()]}unionDepthRangeWithAABB(e,t,i,n,s){const a=this._modelViewProj;r(a,t,i);let o=!1;for(let r=0;r<8;++r){const e=this._clipPosition[r],t=0===r||3===r||4===r||7===r?n[0]:s[0],i=0===r||1===r||4===r||5===r?n[1]:s[1],o=r<4?n[2]:s[2];e[0]=a[0]*t+a[4]*i+a[8]*o+a[12],e[1]=a[1]*t+a[5]*i+a[9]*o+a[13],e[2]=a[2]*t+a[6]*i+a[10]*o+a[14],e[3]=a[3]*t+a[7]*i+a[11]*o+a[15]}for(let r=0;r<12;++r){const t=E(this._clipPosition[S[r][0]],this._clipPosition[S[r][1]],this._clipPosition[S[r][2]]);let i=!0;for(let e=0;e<t.length;++e){if(t[e][3]>=2){i=!1;break}}if(!i){o=!0;for(let r=0;r<t.length;++r){const i=t[r][3];Number.isFinite(i)&&(e.near=Math.min(i,e.near),e.far=Math.max(i,e.far))}}}return o}}function E(e,t,r){let i=[e,t,r];for(let n=0;n<4;++n){const e=i;i=[];for(let t=0;t<e.length;++t){const r=e[t],s=e[(t+1)%e.length];W(s,n)?(W(r,n)||i.push(K(r,s,n)),i.push(s)):W(r,n)&&i.push(K(r,s,n))}}return i}function W(e,t){return 0===t?e[0]>=-e[3]:1===t?e[1]>=-e[3]:2===t?e[0]<=e[3]:3===t?e[1]<=e[3]:void w(!1)}function K(e,t,r){let i=0;return 0===r?i=(-e[3]-e[0])/(t[0]-e[0]+t[3]-e[3]):1===r?i=(-e[3]-e[1])/(t[1]-e[1]+t[3]-e[3]):2===r?i=(e[3]-e[0])/(t[0]-e[0]-t[3]+e[3]):3===r&&(i=(e[3]-e[1])/(t[1]-e[1]-t[3]+e[3])),a(o(),e,t,i)}const S=[[0,1,3],[2,3,1],[1,5,2],[6,2,5],[5,4,6],[7,6,4],[4,0,7],[3,7,0],[3,2,7],[6,7,2],[4,5,0],[1,0,5]],V=u(),k=n(),G=d(),U=new y,Q=new P,q=new N;export{P as DepthRangeFromRenderGeometries,O as depthRangeFromLayer,M as depthRangeFromScene,B as textureToDepth};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/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 n from"../../../../../core/Logger.js";import{clamp as o}from"../../../../../core/mathUtils.js";import{disposeMaybe as i,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"../../../../../core/has.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{s as _,c as b,z as y,k 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{g as R,a as v}from"../../../../../chunks/sphere.js";import{c as x}from"../../../../../chunks/vec33.js";import{ViewingMode as M}from"../../../../ViewingMode.js";import{encodeElevationOffset as T}from"../../collections/Component/Material/shader/ComponentData.glsl.js";import{TwoVectorPosition as C}from"../../core/util/TwoVectorPosition.js";import{Attribute as P}from"../Attribute.js";import{GridLocalOriginFactory as A}from"../GridLocalOriginFactory.js";import{applyToModelMatrix as D}from"../localOriginHelper.js";import{LocalOriginManager as S}from"../LocalOriginManager.js";import{Object3D as U}from"../Object3D.js";import{VertexArrayObject as L}from"../VertexArrayObject.js";import{VertexAttribute as B}from"../VertexAttribute.js";import{VertexLayout as k,EdgeInputBufferLayout as I,EdgeShaderAttributeLocations as H,glVertexLayout as V}from"./bufferLayouts.js";import{RegularEdgeBufferWriter as N,SilhouetteEdgeBufferWriter as G}from"./edgeBufferWriters.js";import{EdgeRenderer as W,lineWidthFractionFactor as q,extensionLengthOffset as z}from"./EdgeRenderer.js";import{EdgePassParameters as F}from"./EdgeShaderParameters.js";import{EdgeWorkerHandle as K}from"./EdgeWorkerHandle.js";import{Transparency as Q}from"./interfaces.js";import{generateStrokesTexture as J}from"./strokes.js";import{determineRendererType as X,determineEdgeTransparency as Y,determineObjectTransparency as Z,fillComponentBufferIndices as $}from"./util.js";import{BufferManager as ee}from"../TextureBackedBuffer/BufferManager.js";import{EdgeSilhouette as te}from"../../shaders/sources/edgeRenderer/EdgeUtil.glsl.js";import{BufferObject as re}from"../../../../webgl/BufferObject.js";import{Usage as se}from"../../../../webgl/enums.js";const ne=128;let oe=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 S(new A(e.renderSR));const t=k.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=re.createVertex(e.rctx,se.STATIC_DRAW,t.buffer)}initialize(){this._worker=new K(this.schedule),this._componentColorManager=new ee(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=i(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",je))}get updating(){return this._updatingHandles.updating}get usedMemory(){return this._gpuMemoryUsage}shouldRender(){return this._renderers.size>0}async addComponentObject(e,t,r,s,n,o){if(this.hasObject(e))return this._getObjectMemoryUsage(e);let i;const a=new ce(null,new Promise((e=>i=e)),e.obb.center,e.obb.radius);this._objectEntries.set(e,a);const c=await this._updatingHandles.addPromise(this._addComponentGeometry(e.transform,a,t,r,s,n,o));return this.setNeedsRender(),i(),c}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 o=this._objectEntries.get(e);o&&(this._pendingDeletions.has(e)?this._discardObjectEntry(o):this._pendingDeletions.set(e,o));const i=new AbortController;let a;const l=e.boundingVolumeWorldSpace.bounds,d=new ce(i,new Promise((e=>a=e)),R(l),v(l));this._objectEntries.set(e,d);const h=()=>{this._removePendingDeletion(e),this.setNeedsRender(),a()};try{const n=new Array;if(r.mergeGeometries&&e.geometries.length>1&&ae(e))n.push(this._addObjectMergedGeometries(e,d,t,r,s));else for(const o of e.geometries)o.material.supportsEdges&&n.push(this._addGeometry(e,d,o,t[0],r,s));await this._updatingHandles.addPromise(Promise.all(n))}catch(u){c(u)&&this._discardObjectEntry(d)}finally{h()}}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,o=n.transform;if(!(o instanceof he))return!1;const[i]=r;if(i.localOrigin!==o.origin.origin)return!1;const a=p(),c=this._computeModelTransformWithLocalOrigin(e,i,a);return n.transform=new he(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=t instanceof Array?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],o=n.index;n.material.opacity=t,e.components.buffer.textureBuffer.setDataElement(o,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 U,o=!!r.hasSlicePlane,i=X(t),a=W.getKey(i,o,n),c=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=c&&(c.renderables.forEach((e=>{if(a!==e.rendererKey){const t=this._renderers.get(e.rendererKey),r=this._acquireRenderer(i,o,n);t.removeRenderable(e),--t.refCount,e.rendererKey=a,r.addRenderable(e)}for(let r=0;r<t.length;r++)e.components.meta[r].material=t[r];s&&this._updateComponentBuffer(e.components),this._updateTransparency(e)})),this.setNeedsRender())}async updateAllVerticalOffsets(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&(r.renderables.forEach((e=>{const r=e.components.meta;for(let s=0;s<r.length;s++)e.components.meta[s].verticalOffset=t?.[s]??0;this._updateComponentBuffer(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 C;let o=0,i=0;if(this._renderers.forEach((r=>{if(0===r.refCount)return this._renderers.delete(r.key),void r.dispose();let s=!0,n=!0;r.forEachRenderable((t=>{t.visible&&(o+=t.statistics.averageEdgeLength,i++,s&&t.regular&&(r.updateTechnique(e,!1),s=!1),n&&t.silhouette&&(r.updateTechnique(e,!0),n=!1))}),t)})),this._componentColorManager.garbageCollect(),this._componentColorManager.updateTextures(),0===i)return;const a=new F(40*o/i,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(ye,a.transformViewFromCameraRelativeRS),g(a.transformNormalViewFromGlobal,ye),a.transformProjFromView=e.camera.projectionMatrix,this._updateObjectCameraDistances(e),this._renderers.forEach((t=>{this._renderRegularEdges(t,e,a),this._renderSilhouetteEdges(t,e,a)}))}_updateTransparency(e){const t=Y(e.components.meta),r=Z(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,D(s.origin.vec3,r),s}_updateComponentBuffer(e){const{meta:t,buffer:r}=e,s=new Uint8Array(4);for(let n=0;n<t.length;n++){const e=t[n].material,i=t[n].index,a=o(Math.round(e.size*q),0,255),c=o(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(i,0,h,u,m,g),r.textureBuffer.setData(i,1,a,c,e.type,l),T(t[n].verticalOffset,s),r.textureBuffer.setData(i,2,s[0],s[1],s[2],s[3])}}_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],o=r.acquireIndex();t.push({index:o,verticalOffset:0,material:s})}const s=new le(r,t);return this._updateComponentBuffer(s),s}_extractEdges(e,t,r,s,n,o,i=o.length){return i<ne&&(n=!0),this._worker.process({data:r,indices:o,indicesLength:i,writerSettings:t,skipDeduplicate:s},e,n)}_createRenderable(e,t,r,s,n){const o=t=>new de(new L(this.rctx,H,{vertices:V,instances:t===te.REGULAR?N.glLayout:G.glLayout},{vertices:this._verticesBufferObject,instances:re.createVertex(this.rctx,se.STATIC_DRAW,t===te.REGULAR?e.regular.instancesData.buffer:e.silhouette.instancesData.buffer)}),t===te.REGULAR?e.regular.lodInfo:e.silhouette.lodInfo),i=e.regular.lodInfo.lengths.length>0?o(te.REGULAR):null,a=e.silhouette.lodInfo.lengths.length>0?o(te.SILHOUETTE):null,c=(i?.vao.usedMemory??0)+(a?.vao.usedMemory??0);return new ue(i,a,{gpuMemoryUsage:c,externalMemoryUsage:n,averageEdgeLength:e.averageEdgeLength},r,Y(t.meta),Z(t.meta),t,s)}async _addGeometry(e,t,r,s,n,o){if(r.edgeIndicesLength<=0)return;const i=r.attributes.get(B.POSITION),a=p(),c=this._computeModelTransformWithLocalOrigin(e,r,a),l=new be(i,a,c);return this._addPositionData(t,l,r.edgeIndicesLength,s,n,o)}async _addPositionData(e,t,r,s,n,o=!1){if(null==e.loaded)return;const i=this._createComponentBuffers([s]);if(null==i)return;const a=this._acquireRenderer(s.type,!!n.hasSlicePlane,!0),{modelTransform:c,origin:l}=t,d=t.position.indices,h=t.position,u=h.data.length/h.size,m=I.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]);$(i.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,o,d,r));if(null==e.loaded)return;const f=this._createRenderable(g,i,new he(c,l),a.key,!1);e.renderables.push(f),a.addRenderable(f),this._gpuMemoryUsage+=f.statistics.gpuMemoryUsage}async _addComponentGeometry(e,t,r,s,n,o,i){if(null==t.loaded)return 0;const a=this._createComponentBuffers(o);if(null==a)return 0;const c=X(o),l=this._acquireRenderer(c,i.hasSlicePlane||!1,!1),d=I.createBuffer(r.length/3);x(d.position.typedBuffer,r,d.position.typedBufferStride,3),$(a.meta,n,d.componentIndex,s);const h=!0,u=l.writerSettings,m=await this._updatingHandles.addPromise(this._extractEdges(this._workerAbort.signal,u,d,h,!1,s));if(null==t.loaded)return 0;const g=this._createRenderable(m,a,e,l.key,!0);return t.renderables.push(g),l.addRenderable(g),g.statistics.gpuMemoryUsage}async _addObjectMergedGeometries(e,t,r,s,n){const o=new Map;let i=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(B.POSITION);return a+=t.data.length/t.size,i+=e.edgeIndicesLength,!0}));if(0===l.length)return;const d=a>=65536?Uint32Array:Uint16Array,h=i?new d(i):null,u=[];let m=0;l.forEach((e=>{const t=e.attributes.get(B.POSITION),r=t.indices;let s=o.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]);o.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 be(new P(u,h,3),f,_);await this._updatingHandles.addPromise(this._addPositionData(t,b,h.length,r[0],s,n))}_acquireRenderer(e,t,r){const s=W.getKey(e,t,r);let n=this._renderers.get(s);return null==this._strokesTexture&&(this._strokesTexture=J(this.rctx)),n||(n=new W(this.rctx,this.techniqueRepository,{type:e,hasSlicePlane:t,strokesTexture:this._strokesTexture,legacy:r,spherical:this.viewingMode===M.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),o=e.radius,i=n<-o?1/0:n<o?0:n-o;e.renderables.forEach((e=>e.distanceToCamera=i))};this._objectEntries.forEach(n),this._pendingDeletions.forEach(n)}_renderRegularEdges(e,t,r){const s=e.bindRegularEdges(r,t),n=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((n=>{if(!ge(n)||!n.visible)return;const i=_e(n.regular.lod.lengths,n.distanceToCamera,o);e.renderRegularEdges(s,n,r,t,i)}),n)}_renderSilhouetteEdges(e,t,r){const s=e.bindSilhouetteEdges(r,t),n=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((n=>{if(!pe(n)||!n.visible)return;const i=_e(n.silhouette.lod.lengths,n.distanceToCamera,o);e.renderSilhouetteEdges(s,n,r,t,i)}),n)}get test(){return{hasRenderedPrimitives:e=>{let t=!1;const r=e.perScreenPixelRatio,s=(e,s)=>e.forEachRenderable((e=>{e.visible&&!t&&(ge(e)&&(t=_e(e.regular.lod.lengths,e.distanceToCamera,r)>0),!t&&pe(e)&&(t=_e(e.silhouette.lod.lengths,e.distanceToCamera,r)>0))}),s);return this._renderers.forEach((e=>{t||(s(e,Q.OPAQUE),s(e,Q.TRANSPARENT))})),t},getObjectData:e=>this._objectEntries.get(e)}}};function ie(e){e?.vao&&(e.vao.vertexBuffers.instances.dispose(),e.vao.disposeVAOOnly(),e.vao=null)}function ae(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})],oe.prototype,"rctx",void 0),e([d({constructOnly:!0})],oe.prototype,"renderSR",void 0),e([d({constructOnly:!0})],oe.prototype,"viewingMode",void 0),e([d({constructOnly:!0})],oe.prototype,"techniqueRepository",void 0),e([d({constructOnly:!0})],oe.prototype,"setNeedsRender",void 0),e([d({constructOnly:!0})],oe.prototype,"schedule",void 0),e([d({readOnly:!0})],oe.prototype,"_updatingHandles",void 0),e([d({readOnly:!0})],oe.prototype,"updating",null),oe=e([h("esri.views.3d.webgl-engine.lib.edgeRendering.EdgeView")],oe);class ce{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 le{constructor(e,t){this.buffer=e,this.meta=t}}class de{constructor(e,t){this.vao=e,this.lod=t}}class he{constructor(e,t){this.modelMatrix=e,this.origin=t}}class ue{constructor(e,t,r,s,n,o,i,a){this.regular=e,this.silhouette=t,this.statistics=r,this.transform=s,this.edgeTransparency=n,this.objectTransparency=o,this.components=i,this.rendererKey=a,this.distanceToCamera=0,this.visible=!0}}class me extends ue{}function ge(e){return null!=e.regular}class fe extends ue{}function pe(e){return null!=e.silhouette}function _e(e,t,r){const n=t*r,o=s(e,n,!0);return-1===o?n<e[0]?e.length:0:e.length-o}class be{constructor(e,t,r){this.position=e,this.modelTransform=t,this.origin=r}}const ye=f(),je=()=>Promise.reject();export{oe as EdgeView,he as LegacyTransform,me as RegularRenderable,ue as Renderable,fe 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 n from"../../../../../core/Logger.js";import{clamp as o}from"../../../../../core/mathUtils.js";import{disposeMaybe as i,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"../../../../../core/has.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{s as _,c as b,z as y,k 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{g as v,a as R}from"../../../../../chunks/sphere.js";import{c as x}from"../../../../../chunks/vec33.js";import{ViewingMode as M}from"../../../../ViewingMode.js";import{encodeElevationOffset as T}from"../../collections/Component/Material/shader/ComponentData.glsl.js";import{TwoVectorPosition as C}from"../../core/util/TwoVectorPosition.js";import{Attribute as P}from"../Attribute.js";import{GridLocalOriginFactory as A}from"../GridLocalOriginFactory.js";import{applyToModelMatrix as D}from"../localOriginHelper.js";import{LocalOriginManager as S}from"../LocalOriginManager.js";import{Object3D as U}from"../Object3D.js";import{VertexArrayObject as L}from"../VertexArrayObject.js";import{VertexAttribute as k}from"../VertexAttribute.js";import{VertexLayout as I,EdgeInputBufferLayout as B,EdgeShaderAttributeLocations as H,glVertexLayout as V}from"./bufferLayouts.js";import{RegularEdgeBufferWriter as N,SilhouetteEdgeBufferWriter as G}from"./edgeBufferWriters.js";import{EdgeRenderer as W,lineWidthFractionFactor as q,extensionLengthOffset as z}from"./EdgeRenderer.js";import{EdgePassParameters as F}from"./EdgeShaderParameters.js";import{EdgeWorkerHandle as K}from"./EdgeWorkerHandle.js";import{Transparency as Q}from"./interfaces.js";import{generateStrokesTexture as J}from"./strokes.js";import{determineRendererType as X,determineEdgeTransparency as Y,determineObjectTransparency as Z,fillComponentBufferIndices as $}from"./util.js";import{BufferManager as ee}from"../TextureBackedBuffer/BufferManager.js";import{EdgeSilhouette as te}from"../../shaders/sources/edgeRenderer/EdgeUtil.glsl.js";import{BufferObject as re}from"../../../../webgl/BufferObject.js";import{Usage as se}from"../../../../webgl/enums.js";const ne=128;let oe=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 S(new A(e.renderSR));const t=I.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=re.createVertex(e.rctx,se.STATIC_DRAW,t.buffer)}initialize(){this._worker=new K(this.schedule),this._componentColorManager=new ee(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=i(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",Ee))}get updating(){return this._updatingHandles.updating}get usedMemory(){return this._gpuMemoryUsage}shouldRender(){return this._renderers.size>0}async addComponentObject(e,t,r,s,n,o){if(this.hasObject(e))return this._getObjectMemoryUsage(e);let i;const a=new ce(null,new Promise((e=>i=e)),e.obb.center,e.obb.radius);this._objectEntries.set(e,a);const c=await this._updatingHandles.addPromise(this._addComponentGeometry(e.transform,a,t,r,s,n,o));return this.setNeedsRender(),i(),c}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 o=this._objectEntries.get(e);o&&(this._pendingDeletions.has(e)?this._discardObjectEntry(o):this._pendingDeletions.set(e,o));const i=new AbortController;let a;const l=e.boundingVolumeWorldSpace.bounds,d=new ce(i,new Promise((e=>a=e)),v(l),R(l));this._objectEntries.set(e,d);const h=()=>{this._removePendingDeletion(e),this.setNeedsRender(),a()};try{const n=new Array;if(r.mergeGeometries&&e.geometries.length>1&&ae(e))n.push(this._addObjectMergedGeometries(e,d,t,r,s));else for(const o of e.geometries)o.material.supportsEdges&&n.push(this._addGeometry(e,d,o,t[0],r,s));await this._updatingHandles.addPromise(Promise.all(n))}catch(u){c(u)&&this._discardObjectEntry(d)}finally{h()}}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,o=n.transform;if(!(o instanceof he))return!1;const[i]=r;if(i.localOrigin!==o.origin.origin)return!1;const a=p(),c=this._computeModelTransformWithLocalOrigin(e,i,a);return n.transform=new he(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=t instanceof Array?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],o=n.index;n.material.opacity=t,e.components.buffer.textureBuffer.setDataElement(o,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 U,o=!!r.hasSlicePlane,i=X(t),a=W.getKey(i,o,n),c=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=c&&(c.renderables.forEach((e=>{if(a!==e.rendererKey){const t=this._renderers.get(e.rendererKey),r=this._acquireRenderer(i,o,n);t.removeRenderable(e),--t.refCount,e.rendererKey=a,r.addRenderable(e)}for(let r=0;r<t.length;r++)e.components.meta[r].material=t[r];s&&ge(e.components),this._updateTransparency(e)})),this.setNeedsRender())}async updateAllVerticalOffsets(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&(r.renderables.forEach((e=>{const r=e.components.meta;for(let s=0;s<r.length;s++)e.components.meta[s].verticalOffset=t?.[s]??0;ge(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 C;let o=0,i=0;if(this._renderers.forEach((r=>{if(0===r.refCount)return this._renderers.delete(r.key),void r.dispose();let s=!0,n=!0;r.forEachRenderable((t=>{t.visible&&(o+=t.statistics.averageEdgeLength,i++,s&&t.regular&&(r.updateTechnique(e,!1),s=!1),n&&t.silhouette&&(r.updateTechnique(e,!0),n=!1))}),t)})),this._componentColorManager.garbageCollect(),this._componentColorManager.updateTextures(),0===i)return;const a=new F(40*o/i,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(we,a.transformViewFromCameraRelativeRS),g(a.transformNormalViewFromGlobal,we),a.transformProjFromView=e.camera.projectionMatrix,this._updateObjectCameraDistances(e),this._renderers.forEach((t=>{fe(t,e,a),pe(t,e,a)}))}_updateTransparency(e){const t=Y(e.components.meta),r=Z(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,D(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],o=r.acquireIndex();t.push({index:o,verticalOffset:0,material:s})}const s=new le(r,t);return ge(s),s}_extractEdges(e,t,r,s,n,o,i=o.length){return i<ne&&(n=!0),this._worker.process({data:r,indices:o,indicesLength:i,writerSettings:t,skipDeduplicate:s},e,n)}_createRenderable(e,t,r,s,n){const o=t=>new de(new L(this.rctx,H,{vertices:V,instances:t===te.REGULAR?N.glLayout:G.glLayout},{vertices:this._verticesBufferObject,instances:re.createVertex(this.rctx,se.STATIC_DRAW,t===te.REGULAR?e.regular.instancesData.buffer:e.silhouette.instancesData.buffer)}),t===te.REGULAR?e.regular.lodInfo:e.silhouette.lodInfo),i=e.regular.lodInfo.lengths.length>0?o(te.REGULAR):null,a=e.silhouette.lodInfo.lengths.length>0?o(te.SILHOUETTE):null,c=(i?.vao.usedMemory??0)+(a?.vao.usedMemory??0);return new ue(i,a,{gpuMemoryUsage:c,externalMemoryUsage:n,averageEdgeLength:e.averageEdgeLength},r,Y(t.meta),Z(t.meta),t,s)}async _addGeometry(e,t,r,s,n,o){if(r.edgeIndicesLength<=0)return;const i=r.attributes.get(k.POSITION),a=p(),c=this._computeModelTransformWithLocalOrigin(e,r,a),l=new Oe(i,a,c);return this._addPositionData(t,l,r.edgeIndicesLength,s,n,o)}async _addPositionData(e,t,r,s,n,o=!1){if(null==e.loaded)return;const i=this._createComponentBuffers([s]);if(null==i)return;const a=this._acquireRenderer(s.type,!!n.hasSlicePlane,!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]);$(i.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,o,d,r));if(null==e.loaded)return;const f=this._createRenderable(g,i,new he(c,l),a.key,!1);e.renderables.push(f),a.addRenderable(f),this._gpuMemoryUsage+=f.statistics.gpuMemoryUsage}async _addComponentGeometry(e,t,r,s,n,o,i){if(null==t.loaded)return 0;const a=this._createComponentBuffers(o);if(null==a)return 0;const c=X(o),l=this._acquireRenderer(c,i.hasSlicePlane||!1,!1),d=B.createBuffer(r.length/3);x(d.position.typedBuffer,r,d.position.typedBufferStride,3),$(a.meta,n,d.componentIndex,s);const h=!0,u=l.writerSettings,m=await this._updatingHandles.addPromise(this._extractEdges(this._workerAbort.signal,u,d,h,!1,s));if(null==t.loaded)return 0;const g=this._createRenderable(m,a,e,l.key,!0);return t.renderables.push(g),l.addRenderable(g),g.statistics.gpuMemoryUsage}async _addObjectMergedGeometries(e,t,r,s,n){const o=new Map;let i=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(k.POSITION);return a+=t.data.length/t.size,i+=e.edgeIndicesLength,!0}));if(0===l.length)return;const d=a>=65536?Uint32Array:Uint16Array,h=i?new d(i):null,u=[];let m=0;l.forEach((e=>{const t=e.attributes.get(k.POSITION),r=t.indices;let s=o.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]);o.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 Oe(new P(u,h,3),f,_);await this._updatingHandles.addPromise(this._addPositionData(t,b,h.length,r[0],s,n))}_acquireRenderer(e,t,r){const s=W.getKey(e,t,r);let n=this._renderers.get(s);return null==this._strokesTexture&&(this._strokesTexture=J(this.rctx)),n||(n=new W(this.rctx,this.techniqueRepository,{type:e,hasSlicePlane:t,strokesTexture:this._strokesTexture,legacy:r,spherical:this.viewingMode===M.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),o=e.radius,i=n<-o?1/0:n<o?0:n-o;e.renderables.forEach((e=>e.distanceToCamera=i))};this._objectEntries.forEach(n),this._pendingDeletions.forEach(n)}get test(){return{hasRenderedPrimitives:e=>{let t=!1;const r=e.perScreenPixelRatio,s=(e,s)=>e.forEachRenderable((e=>{e.visible&&!t&&(_e(e)&&(t=je(e.regular.lod.lengths,e.distanceToCamera,r)>0),!t&&ye(e)&&(t=je(e.silhouette.lod.lengths,e.distanceToCamera,r)>0))}),s);return this._renderers.forEach((e=>{t||(s(e,Q.OPAQUE),s(e,Q.TRANSPARENT))})),t},getObjectData:e=>this._objectEntries.get(e)}}};function ie(e){e?.vao&&(e.vao.vertexBuffers.instances.dispose(),e.vao.disposeVAOOnly(),e.vao=null)}function ae(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})],oe.prototype,"rctx",void 0),e([d({constructOnly:!0})],oe.prototype,"renderSR",void 0),e([d({constructOnly:!0})],oe.prototype,"viewingMode",void 0),e([d({constructOnly:!0})],oe.prototype,"techniqueRepository",void 0),e([d({constructOnly:!0})],oe.prototype,"setNeedsRender",void 0),e([d({constructOnly:!0})],oe.prototype,"schedule",void 0),e([d({readOnly:!0})],oe.prototype,"_updatingHandles",void 0),e([d({readOnly:!0})],oe.prototype,"updating",null),oe=e([h("esri.views.3d.webgl-engine.lib.edgeRendering.EdgeView")],oe);class ce{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 le{constructor(e,t){this.buffer=e,this.meta=t}}class de{constructor(e,t){this.vao=e,this.lod=t}}class he{constructor(e,t){this.modelMatrix=e,this.origin=t}}class ue{constructor(e,t,r,s,n,o,i,a){this.regular=e,this.silhouette=t,this.statistics=r,this.transform=s,this.edgeTransparency=n,this.objectTransparency=o,this.components=i,this.rendererKey=a,this.distanceToCamera=0,this.visible=!0}}class me extends ue{}function ge(e){const{meta:t,buffer:r}=e,s=new Uint8Array(4);for(let n=0;n<t.length;n++){const e=t[n].material,i=t[n].index,a=o(Math.round(e.size*q),0,255),c=o(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(i,0,h,u,m,g),r.textureBuffer.setData(i,1,a,c,e.type,l),T(t[n].verticalOffset,s),r.textureBuffer.setData(i,2,s[0],s[1],s[2],s[3])}}function fe(e,t,r){const s=e.bindRegularEdges(r,t),n=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((n=>{if(!_e(n)||!n.visible)return;const i=je(n.regular.lod.lengths,n.distanceToCamera,o);e.renderRegularEdges(s,n,r,t,i)}),n)}function pe(e,t,r){const s=e.bindSilhouetteEdges(r,t),n=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((n=>{if(!ye(n)||!n.visible)return;const i=je(n.silhouette.lod.lengths,n.distanceToCamera,o);e.renderSilhouetteEdges(s,n,r,t,i)}),n)}function _e(e){return null!=e.regular}class be extends ue{}function ye(e){return null!=e.silhouette}function je(e,t,r){const n=t*r,o=s(e,n,!0);return-1===o?n<e[0]?e.length:0:e.length-o}class Oe{constructor(e,t,r){this.position=e,this.modelTransform=t,this.origin=r}}const we=f(),Ee=()=>Promise.reject();export{oe as EdgeView,he as LegacyTransform,me as RegularRenderable,ue as Renderable,be 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.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isArray as e,isUint32Array as t}from"../../../../../core/typedArrayUtil.js";import{WorkerHandle as r}from"../../../../../core/workers/WorkerHandle.js";import{unpackInterleavedBuffer as
|
|
5
|
+
import{isArray as e,isUint32Array as t}from"../../../../../core/typedArrayUtil.js";import{WorkerHandle as r}from"../../../../../core/workers/WorkerHandle.js";import{unpackInterleavedBuffer as n}from"../../../support/buffer/workerHelper.js";import{extract as s}from"./edgeProcessing.js";class a extends r{constructor(e){super("EdgeProcessingWorker","extract",{extract:e=>[e.dataBuffer],extractComponentsEdgeLocations:e=>[e.dataBuffer],extractEdgeLocations:e=>[e.dataBuffer]},e)}async process(e,t,r){if(r)return s(e);return i(await this.invoke(new o(e),t))}async extractEdgeLocations(e,t){const r=await this.invokeMethod("extractEdgeLocations",new o(e),t);return n(r)}async extractComponentsEdgeLocations(e,t){const r=await this.invokeMethod("extractComponentsEdgeLocations",new o(e),t);return n(r)}}function i(e){return{regular:{instancesData:n(e.regular.instancesData),lodInfo:{lengths:new Float32Array(e.regular.lodInfo.lengths)}},silhouette:{instancesData:n(e.silhouette.instancesData),lodInfo:{lengths:new Float32Array(e.silhouette.lodInfo.lengths)}},averageEdgeLength:e.averageEdgeLength}}class o{constructor(r){this.dataBuffer=r.data.buffer,this.writerSettings=r.writerSettings,this.skipDeduplicate=r.skipDeduplicate,this.indices=e(r.indices)?r.indices:r.indices.buffer,this.indicesType=e(r.indices)?"Array":t(r.indices)?"Uint32Array":"Uint16Array",this.indicesLength=r.indicesLength}}export{a as EdgeWorkerHandle,o as PackedInput};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../../../chunks/tslib.es6.js";import e from"../../../../../core/Accessor.js";import{reallocGrowthFactor as s}from"../../../../../core/arrayUtils.js";import i from"../../../../../core/Evented.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import{subclass as r}from"../../../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as o,invert as n,transpose as l}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as c}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as h}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as g}from"../../../../../chunks/vec32.js";import{create as f}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{BufferViewMat4f64 as d,BufferViewVec3f64 as T,BufferViewMat3f as _,BufferViewVec2f as u,BufferViewVec4f64 as L,BufferViewVec4f as A,BufferViewVec4u8 as E,BufferViewUint8 as p}from"../../../../../geometry/support/buffer/BufferView.js";import{scaleFromMatrix as O}from"../../../support/mathUtils.js";import{newLayout as v}from"../../../support/buffer/InterleavedLayout.js";import{assert as I}from"../Util.js";import{VertexAttribute as F}from"../VertexAttribute.js";import{initialCapacity as S}from"./RenderInstanceData.js";var M;function C(t){let e=v().mat4f64(F.LOCALTRANSFORM).mat4f64(F.GLOBALTRANSFORM).vec4f64(F.BOUNDINGSPHERE).vec3f64(F.MODELORIGIN).mat3f(F.INSTANCEMODEL).mat3f(F.INSTANCEMODELNORMAL).vec2f(F.MODELSCALEFACTORS);return t.includes(F.FEATUREATTRIBUTE)&&(e=e.vec4f(F.FEATUREATTRIBUTE)),t.includes(F.COLOR)&&(e=e.vec4u8(F.COLOR)),t.includes(F.OBJECTANDLAYERIDCOLOR)&&(e=e.vec4u8(F.OBJECTANDLAYERIDCOLOR)),e=e.u8(F.STATE).u8(F.LODLEVEL),e}!function(t){t[t.ALLOCATED=1]="ALLOCATED",t[t.DEFAULT_ACTIVE=2]="DEFAULT_ACTIVE",t[t.VISIBLE=4]="VISIBLE",t[t.HIGHLIGHT=8]="HIGHLIGHT",t[t.HIGHLIGHT_ACTIVE=16]="HIGHLIGHT_ACTIVE",t[t.REMOVE=32]="REMOVE",t[t.TRANSFORM_CHANGED=64]="TRANSFORM_CHANGED",t[t.ACTIVE=18]="ACTIVE"}(M||(M={}));class R{constructor(t){this.localTransform=t.getField(F.LOCALTRANSFORM,d),this.globalTransform=t.getField(F.GLOBALTRANSFORM,d),this.modelOrigin=t.getField(F.MODELORIGIN,T),this.model=t.getField(F.INSTANCEMODEL,_),this.modelNormal=t.getField(F.INSTANCEMODELNORMAL,_),this.modelScaleFactors=t.getField(F.MODELSCALEFACTORS,u),this.boundingSphere=t.getField(F.BOUNDINGSPHERE,L),this.featureAttribute=t.getField(F.FEATUREATTRIBUTE,A),this.color=t.getField(F.COLOR,E),this.objectAndLayerIdColor=t.getField(F.OBJECTANDLAYERIDCOLOR,E),this.state=t.getField(F.STATE,p),this.lodLevel=t.getField(F.LODLEVEL,p)}}let b=class extends e{constructor(t,e){super(t),this.events=new i,this._capacity=0,this._size=0,this._next=0,this._layout=C(e),this._capacity=S,this._buffer=this._layout.createBuffer(this._capacity),this._view=new R(this._buffer)}get capacity(){return this._capacity}get size(){return this._size}get view(){return this._view}addInstance(){this._size+1>this._capacity&&this._grow();const t=this._findSlot();return this._view.state.set(t,M.ALLOCATED),this._size++,this.events.emit("instances-changed"),t}removeInstance(t){const e=this._view.state;I(t>=0&&t<this._capacity
|
|
5
|
+
import{_ as t}from"../../../../../chunks/tslib.es6.js";import e from"../../../../../core/Accessor.js";import{reallocGrowthFactor as s}from"../../../../../core/arrayUtils.js";import i from"../../../../../core/Evented.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import{subclass as r}from"../../../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as o,invert as n,transpose as l}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as c}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as h}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as g}from"../../../../../chunks/vec32.js";import{create as f}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{BufferViewMat4f64 as d,BufferViewVec3f64 as T,BufferViewMat3f as _,BufferViewVec2f as u,BufferViewVec4f64 as L,BufferViewVec4f as A,BufferViewVec4u8 as E,BufferViewUint8 as p}from"../../../../../geometry/support/buffer/BufferView.js";import{scaleFromMatrix as O}from"../../../support/mathUtils.js";import{newLayout as v}from"../../../support/buffer/InterleavedLayout.js";import{assert as I}from"../Util.js";import{VertexAttribute as F}from"../VertexAttribute.js";import{initialCapacity as S}from"./RenderInstanceData.js";var M;function C(t){let e=v().mat4f64(F.LOCALTRANSFORM).mat4f64(F.GLOBALTRANSFORM).vec4f64(F.BOUNDINGSPHERE).vec3f64(F.MODELORIGIN).mat3f(F.INSTANCEMODEL).mat3f(F.INSTANCEMODELNORMAL).vec2f(F.MODELSCALEFACTORS);return t.includes(F.FEATUREATTRIBUTE)&&(e=e.vec4f(F.FEATUREATTRIBUTE)),t.includes(F.COLOR)&&(e=e.vec4u8(F.COLOR)),t.includes(F.OBJECTANDLAYERIDCOLOR)&&(e=e.vec4u8(F.OBJECTANDLAYERIDCOLOR)),e=e.u8(F.STATE).u8(F.LODLEVEL),e}!function(t){t[t.ALLOCATED=1]="ALLOCATED",t[t.DEFAULT_ACTIVE=2]="DEFAULT_ACTIVE",t[t.VISIBLE=4]="VISIBLE",t[t.HIGHLIGHT=8]="HIGHLIGHT",t[t.HIGHLIGHT_ACTIVE=16]="HIGHLIGHT_ACTIVE",t[t.REMOVE=32]="REMOVE",t[t.TRANSFORM_CHANGED=64]="TRANSFORM_CHANGED",t[t.ACTIVE=18]="ACTIVE"}(M||(M={}));class R{constructor(t){this.localTransform=t.getField(F.LOCALTRANSFORM,d),this.globalTransform=t.getField(F.GLOBALTRANSFORM,d),this.modelOrigin=t.getField(F.MODELORIGIN,T),this.model=t.getField(F.INSTANCEMODEL,_),this.modelNormal=t.getField(F.INSTANCEMODELNORMAL,_),this.modelScaleFactors=t.getField(F.MODELSCALEFACTORS,u),this.boundingSphere=t.getField(F.BOUNDINGSPHERE,L),this.featureAttribute=t.getField(F.FEATUREATTRIBUTE,A),this.color=t.getField(F.COLOR,E),this.objectAndLayerIdColor=t.getField(F.OBJECTANDLAYERIDCOLOR,E),this.state=t.getField(F.STATE,p),this.lodLevel=t.getField(F.LODLEVEL,p)}}let b=class extends e{constructor(t,e){super(t),this.events=new i,this._capacity=0,this._size=0,this._next=0,this._layout=C(e),this._capacity=S,this._buffer=this._layout.createBuffer(this._capacity),this._view=new R(this._buffer)}get capacity(){return this._capacity}get size(){return this._size}get view(){return this._view}addInstance(){this._size+1>this._capacity&&this._grow();const t=this._findSlot();return this._view.state.set(t,M.ALLOCATED),this._size++,this.events.emit("instances-changed"),t}removeInstance(t){const e=this._view.state;I(t>=0&&t<this._capacity&&!!(e.get(t)&M.ALLOCATED),"invalid instance handle"),this._getStateFlag(t,M.ACTIVE)?this._setStateFlags(t,M.REMOVE):this.freeInstance(t),this.events.emit("instances-changed")}freeInstance(t){const e=this._view.state;I(t>=0&&t<this._capacity&&!!(e.get(t)&M.ALLOCATED),"invalid instance handle"),e.set(t,0),this._size--}setLocalTransform(t,e,s=!0){this._view.localTransform.setMat(t,e),s&&this.updateModelTransform(t)}getLocalTransform(t,e){this._view.localTransform.getMat(t,e)}setGlobalTransform(t,e,s=!0){this._view.globalTransform.setMat(t,e),s&&this.updateModelTransform(t)}getGlobalTransform(t,e){this._view.globalTransform.getMat(t,e)}updateModelTransform(t){const e=this._view,s=y,i=D;e.localTransform.getMat(t,N),e.globalTransform.getMat(t,V);const a=h(V,V,N);g(s,a[12],a[13],a[14]),e.modelOrigin.setVec(t,s),o(i,a),e.model.setMat(t,i);const r=O(y,a);r.sort(),e.modelScaleFactors.set(t,0,r[1]),e.modelScaleFactors.set(t,1,r[2]),n(i,i),l(i,i),e.modelNormal.setMat(t,i),this._setStateFlags(t,M.TRANSFORM_CHANGED),this.events.emit("instance-transform-changed",{index:t})}getModelTransform(t,e){const s=this._view;s.model.getMat(t,D),s.modelOrigin.getVec(t,y),e[0]=D[0],e[1]=D[1],e[2]=D[2],e[3]=0,e[4]=D[3],e[5]=D[4],e[6]=D[5],e[7]=0,e[8]=D[6],e[9]=D[7],e[10]=D[8],e[11]=0,e[12]=y[0],e[13]=y[1],e[14]=y[2],e[15]=1}applyShaderTransformation(t,e){null!=this.shaderTransformation&&this.shaderTransformation.applyTransform(this,t,e)}getCombinedModelTransform(t,e){return this.getModelTransform(t,e),null!=this.shaderTransformation&&this.shaderTransformation.applyTransform(this,t,e),e}getCombinedLocalTransform(t,e){this._view.localTransform.getMat(t,e),null!=this.shaderTransformation&&this.shaderTransformation.applyTransform(this,t,e)}getCombinedMaxScaleFactor(t){let e=this._view.modelScaleFactors.get(t,1);return null!=this.shaderTransformation&&(this.shaderTransformation.scaleFactor(y,this,t),e*=Math.max(y[0],y[1],y[2])),e}getCombinedMedianScaleFactor(t){let e=this._view.modelScaleFactors.get(t,0);return null!=this.shaderTransformation&&(this.shaderTransformation.scaleFactor(y,this,t),e*=w(y[0],y[1],y[2])),e}getModel(t,e){this._view.model.getMat(t,e)}setFeatureAttribute(t,e){this._view.featureAttribute.setVec(t,e)}getFeatureAttribute(t,e){this._view.featureAttribute.getVec(t,e)}setColor(t,e){this._view.color.setVec(t,e)}setObjectAndLayerIdColor(t,e){this._view.objectAndLayerIdColor.setVec(t,e)}setVisible(t,e){e!==this.getVisible(t)&&(this._setStateFlag(t,M.VISIBLE,e),this.events.emit("instance-visibility-changed",{index:t}))}getVisible(t){return this._getStateFlag(t,M.VISIBLE)}setHighlight(t,e){e!==this.getHighlight(t)&&(this._setStateFlag(t,M.HIGHLIGHT,e),this.events.emit("instance-highlight-changed"))}getHighlight(t){return this._getStateFlag(t,M.HIGHLIGHT)}getState(t){return this._view.state.get(t)}getLodLevel(t){return this._view.lodLevel.get(t)}countFlags(t){let e=0;for(let s=0;s<this._capacity;++s){this.getState(s)&t&&++e}return e}_setStateFlags(t,e){const s=this._view.state;e=s.get(t)|e,s.set(t,e)}_clearStateFlags(t,e){const s=this._view.state;e=s.get(t)&~e,s.set(t,e)}_setStateFlag(t,e,s){s?this._setStateFlags(t,e):this._clearStateFlags(t,e)}_getStateFlag(t,e){return!!(this._view.state.get(t)&e)}_grow(){this._capacity=Math.max(S,Math.floor(this._capacity*s)),this._buffer=this._layout.createBuffer(this._capacity).copyFrom(this._buffer),this._view=new R(this._buffer)}_findSlot(){const t=this._view.state;let e=this._next;for(;t.get(e)&M.ALLOCATED;)e=e+1===this._capacity?0:e+1;return this._next=e+1===this._capacity?0:e+1,e}};function w(t,e,s){return Math.max(Math.min(t,e),Math.min(Math.max(t,e),s))}t([a({constructOnly:!0})],b.prototype,"shaderTransformation",void 0),t([a()],b.prototype,"_size",void 0),t([a({readOnly:!0})],b.prototype,"size",null),b=t([r("esri.views.3d.webgl-engine.lib.lodRendering.InstanceData")],b);const y=f(),D=c(),N=m(),V=m();export{b as InstanceData,R as InstanceDataView,M as StateFlags};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{isSome as t}from"../../../../../core/arrayUtils.js";import{destroyMaybe as r}from"../../../../../core/maybe.js";import{isAborted as a,throwIfAborted as s}from"../../../../../core/promiseUtils.js";import{property as n}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import{subclass as i}from"../../../../../core/accessorSupport/decorators/subclass.js";import{create as o}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{f as l,k as c,e as h}from"../../../../../chunks/vec32.js";import{create as d}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as u,fromValues as m}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{debugFlags as f}from"../../../support/debugFlags.js";import{glLayout as _}from"../../../support/buffer/glUtil.js";import{newLayout as p}from"../../../support/buffer/InterleavedLayout.js";import g from"../../../webgl/RenderCamera.js";import{ShaderOutput as I}from"../../core/shaderLibrary/ShaderOutput.js";import{ASyncPreparesRenderPlugin as C}from"../../effects/RenderPlugin.js";import{Default3D as y}from"../DefaultVertexAttributeLocations.js";import{IntersectorType as v}from"../IntersectorInterfaces.js";import E from"../Octree.js";import{RenderSlot as A}from"../RenderSlot.js";import{assert as b}from"../Util.js";import{VertexAttribute as D}from"../VertexAttribute.js";import{InstanceData as R,StateFlags as T}from"./InstanceData.js";import{InstanceOctree as L}from"./InstanceOctree.js";import{LevelSelector as S}from"./LevelSelector.js";import{LodLevel as O}from"./LodLevel.js";import{RenderInstanceData as j}from"./RenderInstanceData.js";import{colorMixModes as x}from"../../materials/internal/MaterialUtil.js";import{encodeDoubleVec3 as N}from"../../materials/renderers/utils.js";import{DefaultMaterialDrawParameters as M}from"../../shaders/DefaultMaterialTechnique.js";import{TaskPriority as U,noBudget as w}from"../../../../support/Scheduler.js";import{bindVertexBufferLayout as F,unbindVertexBufferLayout as H}from"../../../../webgl/Util.js";const V=e=>{const t=e.baseBoundingSphere.radius,r=e.levels.map((e=>e.minScreenSpaceRadius));return new S(t,r)};let B=class extends C{constructor(e,t){super(e),this.type=v.LOD,this.isGround=!1,this._levels=[],this._defaultRenderInstanceData=[new Array],this._highlightRenderInstanceData=[new Array],this._allRenderInstanceData=[this._defaultRenderInstanceData[0],this._highlightRenderInstanceData[0]],this._instanceIndex=0,this._cycleStartIndex=0,this._slicePlane=!1,this._camera=new g,this._updateCyclesWithStaticCamera=-1,this._needFullCycle=!1,this.produces=new Map([[A.OPAQUE_MATERIAL,e=>this._produces(e)],[A.TRANSPARENT_MATERIAL,e=>!!this._hasTransparentLevels()&&this._produces(e)]]),this._instanceData=new R({shaderTransformation:e.shaderTransformation},e.optionalFields),this.addHandles(t.registerTask(U.LOD_RENDERER,this))}initialize(){this._instanceBufferLayout=q(this.optionalFields),this._glInstanceBufferLayout=_(this._instanceBufferLayout,1),this.addHandles([this._instanceData.events.on("instances-changed",(()=>this._requestUpdateCycle())),this._instanceData.events.on("instance-transform-changed",(({index:e})=>{this._requestUpdateCycle(),this.metadata.notifyGraphicGeometryChanged(e)})),this._instanceData.events.on("instance-visibility-changed",(({index:e})=>{this._requestUpdateCycle(!0),this.metadata.notifyGraphicVisibilityChanged(e)})),this._instanceData.events.on("instance-highlight-changed",(()=>this._requestUpdateCycle(!0)))])}get _enableLevelSelection(){return this.symbol.levels.length>1}get levels(){return this._levels}get baseBoundingBox(){return this._levels[this._levels.length-1].boundingBox}get baseBoundingSphere(){return this._levels[this._levels.length-1].boundingSphere}get baseMaterial(){return this._levels[this._levels.length-1].components[0].material}get slicePlaneEnabled(){return this._slicePlane}set slicePlaneEnabled(e){this._slicePlane=e}get layerUid(){return this.metadata.layerUid}get instanceData(){return this._instanceData}get usedMemory(){return this._allRenderInstanceData.reduce(((e,t)=>t.reduce(((e,t)=>e+t.usedMemory),e)),0)}get renderStats(){const e=this._instanceData.size,t=[];return this._levels.forEach(((e,r)=>{const a=this._allRenderInstanceData[0][r].size+this._allRenderInstanceData[1][r].size,s=e.triangleCount;t.push({renderedInstances:a,renderedTriangles:a*s,trianglesPerInstance:s})})),{totalInstances:e,renderedInstances:t.reduce(((e,t)=>e+t.renderedInstances),0),renderedTriangles:t.reduce(((e,t)=>e+t.renderedTriangles),0),levels:t}}async initializeRenderContext(e,r){this._context=e;const n=e.renderContext.rctx,i=await Promise.allSettled(this.symbol.levels.map((t=>(this._defaultRenderInstanceData[0].push(new j(n,this._instanceBufferLayout)),this._highlightRenderInstanceData[0].push(new j(n,this._instanceBufferLayout)),O.create(e,t,r))))),o=i.map((e=>"fulfilled"===e.status?e.value:null)).filter(t);if(a(r)||o.length!==i.length){o.forEach((e=>e.destroy())),s(r);for(const e of i)if("rejected"===e.status)throw e.reason}this._levels=o,this._levelSelector=V(this)}uninitializeRenderContext(){this._invalidateOctree(),this._levels.forEach((e=>e.destroy())),this._defaultRenderInstanceData[0].forEach((e=>e.destroy())),this._highlightRenderInstanceData[0].forEach((e=>e.destroy()))}_hasTransparentLevels(){return this._levels.some((e=>e.components.some((e=>{const t=e.material.produces.get(A.TRANSPARENT_MATERIAL);return t&&t(I.Color)}))))}hasHighlights(){return this._highlightRenderInstanceData[0].some((e=>e.size>0))}_produces(e){return e!==I.Highlight&&e!==I.ShadowHighlight||this.hasHighlights()}prepareRender(e){if(!f.LOD_INSTANCE_RENDERER_DISABLE_UPDATES){if(this._enableLevelSelection){const t=e.bindParameters.contentCamera.equals(this._camera);this._camera.copyFrom(e.bindParameters.contentCamera),t||this._requestUpdateCycle()}this._needFullCycle&&(this.runTask(w),this._needFullCycle=!1)}}prepareTechniques(e){if(!this.baseMaterial.isVisible()||!this.baseMaterial.isVisibleForOutput(e.output))return null;const t=this._getInstanceDatas(e.output);if(!t)return null;const r=new Array;return t.forEach((t=>this.levels.forEach(((a,s)=>{a.components.forEach((a=>r.push(this._beginComponent(e,t[s],a))))})))),r}renderNode(e,t){const r=this._getInstanceDatas(e.output);if(!r||null==t)return;let a=0;e.rctx.bindVAO(),r.forEach((r=>this.levels.forEach(((s,n)=>{s.components.forEach((s=>this._renderComponent(e,t[a++],r[n],s,n)))}))))}_getInstanceDatas(e){const t=e!==I.Highlight&&e!==I.ShadowHighlight,r=e!==I.ShadowExcludeHighlight;return t&&r?this._allRenderInstanceData:t?this._defaultRenderInstanceData:r?this._highlightRenderInstanceData:null}intersect(e,t,r,a){if(!this.baseMaterial.isVisible()||null==this._octree)return;const s=d();l(s,a,r);const n=s=>{this._instanceData.getCombinedModelTransform(s,W),e.transform.set(W),h(K,r,e.transform.inverse),h(Y,a,e.transform.inverse);const n=this._instanceData.getState(s),i=this._instanceData.getLodLevel(s),o=this._levels.length;b(0!=(n&T.ACTIVE),"invalid instance state"),b(i>=0&&i<o,"invaid lod level"),this._levels[i].intersect(e,t,K,Y,s,this.metadata,o)};this.baseMaterial.parameters.verticalOffset?this._octree.forEach(n):this._octree.forEachAlongRay(r,s,n)}notifyShaderTransformationChanged(){this._invalidateOctree(),this._requestUpdateCycle()}get _octree(){if(null==this._octreeCached){const e=this._instanceData,t=e.view?.state;if(!t)return null;this._octreeCached=new L(e,this.baseBoundingSphere);for(let r=0;r<e.capacity;++r)t.get(r)&T.ACTIVE&&this._octreeCached.addInstance(r)}return this._octreeCached}_invalidateOctree(){this._octreeCached=r(this._octreeCached)}queryDepthRange(e){if(null==this._octree)return{near:1/0,far:-1/0};const t=e.viewForward,r=this._octree.findClosest(t,E.DepthOrder.FRONT_TO_BACK,e.frustum),a=this._octree.findClosest(t,E.DepthOrder.BACK_TO_FRONT,e.frustum);if(null==r||null==a)return{near:1/0,far:-1/0};const s=e.eye,n=this._instanceData.view;n.boundingSphere.getVec(r,k),l(k,k,s);const i=c(k,t)-k[3];n.boundingSphere.getVec(a,k),l(k,k,s);const o=c(k,t)+k[3];return{near:Math.max(e.near,i),far:Math.min(e.far,o)}}_requestUpdateCycle(e=!1){this._updateCyclesWithStaticCamera=-1,this._cycleStartIndex=this._instanceIndex,e&&(this._needFullCycle=!0,this._context.requestRender())}_startUpdateCycle(){this._updateCyclesWithStaticCamera++,this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.startUpdateCycle()))))}get running(){return this._instanceData.size>0&&this._updateCyclesWithStaticCamera<1}runTask(e){const{_enableLevelSelection:t,_camera:r,_levelSelector:a}=this;this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.beginUpdate()))));const s=this._instanceData,n=s.view;let i=s.size;const o=s.capacity;let l=this._instanceIndex;const c=Math.ceil(o/500);for(let h=0;h<i&&!e.done;++h){l===this._cycleStartIndex&&this._startUpdateCycle();const h=n.state.get(l);let d=0;if(!(h&T.ALLOCATED)){l=l+1===o?0:l+1,i++;continue}const u=n.lodLevel.get(l);if(h&T.DEFAULT_ACTIVE&&this._defaultRenderInstanceData[0][u].freeTail(),h&T.HIGHLIGHT_ACTIVE&&this._highlightRenderInstanceData[0][u].freeTail(),h&T.REMOVE)s.freeInstance(l);else if(h&T.VISIBLE){let e=0;t&&(n.modelOrigin.getVec(l,z),e=a.selectLevel(z,s.getCombinedMedianScaleFactor(l),r)),d=h&~(T.ACTIVE|T.TRANSFORM_CHANGED),e>=0&&(h&T.HIGHLIGHT?(P(this._highlightRenderInstanceData[0][e],n,l),d|=T.HIGHLIGHT_ACTIVE):(P(this._defaultRenderInstanceData[0][e],n,l),d|=T.DEFAULT_ACTIVE)),n.state.set(l,d),n.lodLevel.set(l,e)}else d=h&~(T.ACTIVE|T.TRANSFORM_CHANGED),n.state.set(l,d);if(null!=this._octreeCached){const e=!!(h&T.ACTIVE),t=!!(d&T.ACTIVE);!e&&t?this._octreeCached.addInstance(l):e&&!t?this._octreeCached.removeInstance(l):e&&t&&h&T.TRANSFORM_CHANGED&&(this._octreeCached.removeInstance(l),this._octreeCached.addInstance(l))}l=l+1===o?0:l+1,l%c==0&&e.madeProgress()}this._instanceIndex=l,this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.endUpdate())))),this._context.requestRender()}_beginComponent(e,t,r){if(0===t.size)return null;const a=r.glMaterials.load(e.rctx,e.bindParameters.slot,e.output);return null!=a?a.beginSlot(e.bindParameters):null}_renderComponent(e,t,r,a,s){if(!t)return;const{bindParameters:n,rctx:i}=e;i.runAppleAmdDriverHelper();const o=i.bindTechnique(t,n,a.material.parameters,Q);i.bindVAO(a.vao),t.ensureAttributeLocations(a.vao),f.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL&&e.output===I.Color&&(o.setUniform4fv("externalColor",J[Math.min(s,J.length-1)]),o.setUniform1i("colorMixMode",x.replace));const l=r.capacity,c=r.headIndex,h=r.tailIndex,d=r.firstIndex,u=this._glInstanceBufferLayout,m=(e,s)=>{F(i,y,r.buffer,u,e),i.drawArraysInstanced(t.primitiveType,0,a.vertexCount,s-e),H(i,y,r.buffer,u)};a.material.parameters.transparent&&null!=d?c>h?(b(d>=h&&d<=c,"invalid firstIndex"),m(d,c),m(h,d)):c<h&&(d<=c?(b(d>=0&&d<=c,"invalid firstIndex"),m(d,c),m(h,l),m(0,d)):(b(d>=h&&d<=l,"invalid firstIndex"),m(d,l),m(0,c),m(h,d))):c>h?m(h,c):c<h&&(m(0,c),m(h,l)),i.bindVAO(null)}};function P(e,t,r){const a=e.allocateHead();G(t,r,e.view,a)}function G(e,t,r,a){N(e.modelOrigin,t,r.modelOriginHi,r.modelOriginLo,a),r.model.copyFrom(a,e.model,t),r.modelNormal.copyFrom(a,e.modelNormal,t),e.color&&r.color&&r.color.copyFrom(a,e.color,t),e.objectAndLayerIdColor&&r.objectAndLayerIdColor&&r.objectAndLayerIdColor.copyFrom(a,e.objectAndLayerIdColor,t),e.featureAttribute&&r.featureAttribute&&r.featureAttribute.copyFrom(a,e.featureAttribute,t)}function q(e){let t=p().vec3f(D.INSTANCEMODELORIGINHI).vec3f(D.INSTANCEMODELORIGINLO).mat3f(D.INSTANCEMODEL).mat3f(D.INSTANCEMODELNORMAL);return null!=e&&e.includes("featureAttribute")&&(t=t.vec4f(D.INSTANCEFEATUREATTRIBUTE)),null!=e&&e.includes("color")&&(t=t.vec4u8(D.INSTANCECOLOR)),null!=e&&e.includes("objectAndLayerIdColor")&&(t=t.vec4u8(D.INSTANCEOBJECTANDLAYERIDCOLOR)),t}e([n({constructOnly:!0})],B.prototype,"symbol",void 0),e([n({constructOnly:!0})],B.prototype,"optionalFields",void 0),e([n({constructOnly:!0})],B.prototype,"metadata",void 0),e([n({constructOnly:!0})],B.prototype,"shaderTransformation",void 0),e([n()],B.prototype,"_instanceData",void 0),e([n()],B.prototype,"_cycleStartIndex",void 0),e([n({readOnly:!0})],B.prototype,"_enableLevelSelection",null),e([n()],B.prototype,"_updateCyclesWithStaticCamera",void 0),e([n({readOnly:!0})],B.prototype,"running",null),B=e([i("esri.views.3d.webgl-engine.lib.lodRendering.LodRenderer")],B);const z=d(),k=u(),W=o(),K=d(),Y=d(),J=[m(1,0,1,1),m(0,0,1,1),m(0,1,0,1),m(1,1,0,1),m(1,0,0,1)],Q=new M;export{B as LodRenderer};
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{isSome as t}from"../../../../../core/arrayUtils.js";import{destroyMaybe as r}from"../../../../../core/maybe.js";import{isAborted as a,throwIfAborted as s}from"../../../../../core/promiseUtils.js";import{property as n}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import{subclass as i}from"../../../../../core/accessorSupport/decorators/subclass.js";import{create as o}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{f as l,k as c,e as h}from"../../../../../chunks/vec32.js";import{create as d}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as u,fromValues as m}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{debugFlags as f}from"../../../support/debugFlags.js";import{glLayout as _}from"../../../support/buffer/glUtil.js";import{newLayout as p}from"../../../support/buffer/InterleavedLayout.js";import g from"../../../webgl/RenderCamera.js";import{ShaderOutput as I}from"../../core/shaderLibrary/ShaderOutput.js";import{ASyncPreparesRenderPlugin as C}from"../../effects/RenderPlugin.js";import{Default3D as y}from"../DefaultVertexAttributeLocations.js";import{IntersectorType as v}from"../IntersectorInterfaces.js";import E from"../Octree.js";import{RenderSlot as A}from"../RenderSlot.js";import{assert as b}from"../Util.js";import{VertexAttribute as D}from"../VertexAttribute.js";import{InstanceData as R,StateFlags as T}from"./InstanceData.js";import{InstanceOctree as L}from"./InstanceOctree.js";import{LevelSelector as S}from"./LevelSelector.js";import{LodLevel as O}from"./LodLevel.js";import{RenderInstanceData as j}from"./RenderInstanceData.js";import{colorMixModes as x}from"../../materials/internal/MaterialUtil.js";import{encodeDoubleVec3 as N}from"../../materials/renderers/utils.js";import{DefaultMaterialDrawParameters as M}from"../../shaders/DefaultMaterialTechnique.js";import{TaskPriority as U,noBudget as w}from"../../../../support/Scheduler.js";import{bindVertexBufferLayout as F,unbindVertexBufferLayout as H}from"../../../../webgl/Util.js";const V=e=>{const t=e.baseBoundingSphere.radius,r=e.levels.map((e=>e.minScreenSpaceRadius));return new S(t,r)};let B=class extends C{constructor(e,t){super(e),this.type=v.LOD,this.isGround=!1,this._levels=[],this._defaultRenderInstanceData=[new Array],this._highlightRenderInstanceData=[new Array],this._allRenderInstanceData=[this._defaultRenderInstanceData[0],this._highlightRenderInstanceData[0]],this._instanceIndex=0,this._cycleStartIndex=0,this._slicePlane=!1,this._camera=new g,this._updateCyclesWithStaticCamera=-1,this._needFullCycle=!1,this.produces=new Map([[A.OPAQUE_MATERIAL,e=>this._produces(e)],[A.TRANSPARENT_MATERIAL,e=>!!this._hasTransparentLevels()&&this._produces(e)]]),this._instanceData=new R({shaderTransformation:e.shaderTransformation},e.optionalFields),this.addHandles(t.registerTask(U.LOD_RENDERER,this))}initialize(){this._instanceBufferLayout=q(this.optionalFields),this._glInstanceBufferLayout=_(this._instanceBufferLayout,1),this.addHandles([this._instanceData.events.on("instances-changed",(()=>this._requestUpdateCycle())),this._instanceData.events.on("instance-transform-changed",(({index:e})=>{this._requestUpdateCycle(),this.metadata.notifyGraphicGeometryChanged(e)})),this._instanceData.events.on("instance-visibility-changed",(({index:e})=>{this._requestUpdateCycle(!0),this.metadata.notifyGraphicVisibilityChanged(e)})),this._instanceData.events.on("instance-highlight-changed",(()=>this._requestUpdateCycle(!0)))])}get _enableLevelSelection(){return this.symbol.levels.length>1}get levels(){return this._levels}get baseBoundingBox(){return this._levels[this._levels.length-1].boundingBox}get baseBoundingSphere(){return this._levels[this._levels.length-1].boundingSphere}get baseMaterial(){return this._levels[this._levels.length-1].components[0].material}get slicePlaneEnabled(){return this._slicePlane}set slicePlaneEnabled(e){this._slicePlane=e}get layerUid(){return this.metadata.layerUid}get instanceData(){return this._instanceData}get usedMemory(){return this._allRenderInstanceData.reduce(((e,t)=>t.reduce(((e,t)=>e+t.usedMemory),e)),0)}get renderStats(){const e=this._instanceData.size,t=[];return this._levels.forEach(((e,r)=>{const a=this._allRenderInstanceData[0][r].size+this._allRenderInstanceData[1][r].size,s=e.triangleCount;t.push({renderedInstances:a,renderedTriangles:a*s,trianglesPerInstance:s})})),{totalInstances:e,renderedInstances:t.reduce(((e,t)=>e+t.renderedInstances),0),renderedTriangles:t.reduce(((e,t)=>e+t.renderedTriangles),0),levels:t}}async initializeRenderContext(e,r){this._context=e;const n=e.renderContext.rctx,i=await Promise.allSettled(this.symbol.levels.map((t=>(this._defaultRenderInstanceData[0].push(new j(n,this._instanceBufferLayout)),this._highlightRenderInstanceData[0].push(new j(n,this._instanceBufferLayout)),O.create(e,t,r))))),o=i.map((e=>"fulfilled"===e.status?e.value:null)).filter(t);if(a(r)||o.length!==i.length){o.forEach((e=>e.destroy())),s(r);for(const e of i)if("rejected"===e.status)throw e.reason}this._levels=o,this._levelSelector=V(this)}uninitializeRenderContext(){this._invalidateOctree(),this._levels.forEach((e=>e.destroy())),this._defaultRenderInstanceData[0].forEach((e=>e.destroy())),this._highlightRenderInstanceData[0].forEach((e=>e.destroy()))}_hasTransparentLevels(){return this._levels.some((e=>e.components.some((e=>{const t=e.material.produces.get(A.TRANSPARENT_MATERIAL);return t&&t(I.Color)}))))}hasHighlights(){return this._highlightRenderInstanceData[0].some((e=>e.size>0))}_produces(e){return e!==I.Highlight&&e!==I.ShadowHighlight||this.hasHighlights()}prepareRender(e){if(!f.LOD_INSTANCE_RENDERER_DISABLE_UPDATES){if(this._enableLevelSelection){const t=e.bindParameters.contentCamera.equals(this._camera);this._camera.copyFrom(e.bindParameters.contentCamera),t||this._requestUpdateCycle()}this._needFullCycle&&(this.runTask(w),this._needFullCycle=!1)}}prepareTechniques(e){if(!this.baseMaterial.isVisible()||!this.baseMaterial.isVisibleForOutput(e.output))return null;const t=this._getInstanceDatas(e.output);if(!t)return null;const r=new Array;return t.forEach((t=>this.levels.forEach(((a,s)=>{a.components.forEach((a=>r.push(this._beginComponent(e,t[s],a))))})))),r}renderNode(e,t){const r=this._getInstanceDatas(e.output);if(!r||null==t)return;let a=0;e.rctx.bindVAO(),r.forEach((r=>this.levels.forEach(((s,n)=>{s.components.forEach((s=>this._renderComponent(e,t[a++],r[n],s,n)))}))))}_getInstanceDatas(e){const t=e!==I.Highlight&&e!==I.ShadowHighlight,r=e!==I.ShadowExcludeHighlight;return t&&r?this._allRenderInstanceData:t?this._defaultRenderInstanceData:r?this._highlightRenderInstanceData:null}intersect(e,t,r,a){if(!this.baseMaterial.isVisible()||null==this._octree)return;const s=d();l(s,a,r);const n=s=>{this._instanceData.getCombinedModelTransform(s,W),e.transform.set(W),h(K,r,e.transform.inverse),h(Y,a,e.transform.inverse);const n=this._instanceData.getState(s),i=this._instanceData.getLodLevel(s),o=this._levels.length;b(!!(n&T.ACTIVE),"invalid instance state"),b(i>=0&&i<o,"invaid lod level"),this._levels[i].intersect(e,t,K,Y,s,this.metadata,o)};this.baseMaterial.parameters.verticalOffset?this._octree.forEach(n):this._octree.forEachAlongRay(r,s,n)}notifyShaderTransformationChanged(){this._invalidateOctree(),this._requestUpdateCycle()}get _octree(){if(null==this._octreeCached){const e=this._instanceData,t=e.view?.state;if(!t)return null;this._octreeCached=new L(e,this.baseBoundingSphere);for(let r=0;r<e.capacity;++r)t.get(r)&T.ACTIVE&&this._octreeCached.addInstance(r)}return this._octreeCached}_invalidateOctree(){this._octreeCached=r(this._octreeCached)}queryDepthRange(e){if(null==this._octree)return{near:1/0,far:-1/0};const t=e.viewForward,r=this._octree.findClosest(t,E.DepthOrder.FRONT_TO_BACK,e.frustum),a=this._octree.findClosest(t,E.DepthOrder.BACK_TO_FRONT,e.frustum);if(null==r||null==a)return{near:1/0,far:-1/0};const s=e.eye,n=this._instanceData.view;n.boundingSphere.getVec(r,k),l(k,k,s);const i=c(k,t)-k[3];n.boundingSphere.getVec(a,k),l(k,k,s);const o=c(k,t)+k[3];return{near:Math.max(e.near,i),far:Math.min(e.far,o)}}_requestUpdateCycle(e=!1){this._updateCyclesWithStaticCamera=-1,this._cycleStartIndex=this._instanceIndex,e&&(this._needFullCycle=!0,this._context.requestRender())}_startUpdateCycle(){this._updateCyclesWithStaticCamera++,this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.startUpdateCycle()))))}get running(){return this._instanceData.size>0&&this._updateCyclesWithStaticCamera<1}runTask(e){const{_enableLevelSelection:t,_camera:r,_levelSelector:a}=this;this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.beginUpdate()))));const s=this._instanceData,n=s.view;let i=s.size;const o=s.capacity;let l=this._instanceIndex;const c=Math.ceil(o/500);for(let h=0;h<i&&!e.done;++h){l===this._cycleStartIndex&&this._startUpdateCycle();const h=n.state.get(l);let d=0;if(!(h&T.ALLOCATED)){l=l+1===o?0:l+1,i++;continue}const u=n.lodLevel.get(l);if(h&T.DEFAULT_ACTIVE&&this._defaultRenderInstanceData[0][u].freeTail(),h&T.HIGHLIGHT_ACTIVE&&this._highlightRenderInstanceData[0][u].freeTail(),h&T.REMOVE)s.freeInstance(l);else if(h&T.VISIBLE){let e=0;t&&(n.modelOrigin.getVec(l,z),e=a.selectLevel(z,s.getCombinedMedianScaleFactor(l),r)),d=h&~(T.ACTIVE|T.TRANSFORM_CHANGED),e>=0&&(h&T.HIGHLIGHT?(P(this._highlightRenderInstanceData[0][e],n,l),d|=T.HIGHLIGHT_ACTIVE):(P(this._defaultRenderInstanceData[0][e],n,l),d|=T.DEFAULT_ACTIVE)),n.state.set(l,d),n.lodLevel.set(l,e)}else d=h&~(T.ACTIVE|T.TRANSFORM_CHANGED),n.state.set(l,d);if(null!=this._octreeCached){const e=!!(h&T.ACTIVE),t=!!(d&T.ACTIVE);!e&&t?this._octreeCached.addInstance(l):e&&!t?this._octreeCached.removeInstance(l):e&&t&&h&T.TRANSFORM_CHANGED&&(this._octreeCached.removeInstance(l),this._octreeCached.addInstance(l))}l=l+1===o?0:l+1,l%c==0&&e.madeProgress()}this._instanceIndex=l,this._allRenderInstanceData.forEach((e=>e.forEach((e=>e.endUpdate())))),this._context.requestRender()}_beginComponent(e,t,r){if(0===t.size)return null;const a=r.glMaterials.load(e.rctx,e.bindParameters.slot,e.output);return null!=a?a.beginSlot(e.bindParameters):null}_renderComponent(e,t,r,a,s){if(!t)return;const{bindParameters:n,rctx:i}=e;i.runAppleAmdDriverHelper();const o=i.bindTechnique(t,n,a.material.parameters,Q);i.bindVAO(a.vao),t.ensureAttributeLocations(a.vao),f.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL&&e.output===I.Color&&(o.setUniform4fv("externalColor",J[Math.min(s,J.length-1)]),o.setUniform1i("colorMixMode",x.replace));const l=r.capacity,c=r.headIndex,h=r.tailIndex,d=r.firstIndex,u=this._glInstanceBufferLayout,m=(e,s)=>{F(i,y,r.buffer,u,e),i.drawArraysInstanced(t.primitiveType,0,a.vertexCount,s-e),H(i,y,r.buffer,u)};a.material.parameters.transparent&&null!=d?c>h?(b(d>=h&&d<=c,"invalid firstIndex"),m(d,c),m(h,d)):c<h&&(d<=c?(b(d>=0&&d<=c,"invalid firstIndex"),m(d,c),m(h,l),m(0,d)):(b(d>=h&&d<=l,"invalid firstIndex"),m(d,l),m(0,c),m(h,d))):c>h?m(h,c):c<h&&(m(0,c),m(h,l)),i.bindVAO(null)}};function P(e,t,r){const a=e.allocateHead();G(t,r,e.view,a)}function G(e,t,r,a){N(e.modelOrigin,t,r.modelOriginHi,r.modelOriginLo,a),r.model.copyFrom(a,e.model,t),r.modelNormal.copyFrom(a,e.modelNormal,t),e.color&&r.color&&r.color.copyFrom(a,e.color,t),e.objectAndLayerIdColor&&r.objectAndLayerIdColor&&r.objectAndLayerIdColor.copyFrom(a,e.objectAndLayerIdColor,t),e.featureAttribute&&r.featureAttribute&&r.featureAttribute.copyFrom(a,e.featureAttribute,t)}function q(e){let t=p().vec3f(D.INSTANCEMODELORIGINHI).vec3f(D.INSTANCEMODELORIGINLO).mat3f(D.INSTANCEMODEL).mat3f(D.INSTANCEMODELNORMAL);return null!=e&&e.includes("featureAttribute")&&(t=t.vec4f(D.INSTANCEFEATUREATTRIBUTE)),null!=e&&e.includes("color")&&(t=t.vec4u8(D.INSTANCECOLOR)),null!=e&&e.includes("objectAndLayerIdColor")&&(t=t.vec4u8(D.INSTANCEOBJECTANDLAYERIDCOLOR)),t}e([n({constructOnly:!0})],B.prototype,"symbol",void 0),e([n({constructOnly:!0})],B.prototype,"optionalFields",void 0),e([n({constructOnly:!0})],B.prototype,"metadata",void 0),e([n({constructOnly:!0})],B.prototype,"shaderTransformation",void 0),e([n()],B.prototype,"_instanceData",void 0),e([n()],B.prototype,"_cycleStartIndex",void 0),e([n({readOnly:!0})],B.prototype,"_enableLevelSelection",null),e([n()],B.prototype,"_updateCyclesWithStaticCamera",void 0),e([n({readOnly:!0})],B.prototype,"running",null),B=e([i("esri.views.3d.webgl-engine.lib.lodRendering.LodRenderer")],B);const z=d(),k=u(),W=o(),K=d(),Y=d(),J=[m(1,0,1,1),m(0,0,1,1),m(0,1,0,1),m(1,1,0,1),m(1,0,0,1)],Q=new M;export{B as LodRenderer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{normalFromMat4Legacy as t}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as r,transpose as e,copy as i,multiply as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as n,g as h,l as f,r as l,e as m}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{d as c,g as _}from"../../../../chunks/sphere.js";import{ViewingMode as u}from"../../../ViewingMode.js";import{Obb as g,computeOffsetObb as M}from"../../support/orientedBoundingBox.js";class v{constructor(){this._transform=a(),this._transformInverse=new b({value:this._transform},r,a),this._transformInverseTranspose=new b(this._transformInverse,e,a),this._transformTranspose=new b({value:this._transform},e,a),this._transformInverseRotation=new b({value:this._transform},t,s)}_invalidateLazyTransforms(){this._transformInverse.invalidate(),this._transformInverseTranspose.invalidate(),this._transformTranspose.invalidate(),this._transformInverseRotation.invalidate()}get transform(){return this._transform}get inverse(){return this._transformInverse.value}get inverseTranspose(){return this._transformInverseTranspose.value}get inverseRotation(){return this._transformInverseRotation.value}get transpose(){return this._transformTranspose.value}setTransformMatrix(t){i(this._transform,t)}multiplyTransform(t){o(this._transform,this._transform,t)}set(t){i(this._transform,t),this._invalidateLazyTransforms()}setAndInvalidateLazyTransforms(t,s){this.setTransformMatrix(t),this.multiplyTransform(s),this._invalidateLazyTransforms()}}class b{constructor(t,s,r){this._original=t,this._update=s,this._dirty=!0,this._transform=r()}invalidate(){this._dirty=!0}get value(){return this._dirty&&(this._update(this._transform,this._original.value),this._dirty=!1),this._transform}}class T{constructor(t=0){this.offset=t,this.tmpVertex=p()}applyToVertex(t,s,r){const e=n(q,t,s,r),i=h(z,e,this.localOrigin),o=this.offset/f(i);return l(this.tmpVertex,e,i,o),this.tmpVertex}applyToAabb(t){const s=A,r=R,e=B;for(let n=0;n<3;++n)s[n]=t[0+n]+this.localOrigin[n],r[n]=t[3+n]+this.localOrigin[n],e[n]=s[n];const i=this.applyToVertex(s[0],s[1],s[2]);for(let n=0;n<3;++n)t[n]=i[n],t[n+3]=i[n];const o=s=>{const r=this.applyToVertex(s[0],s[1],s[2]);for(let e=0;e<3;++e)t[e]=Math.min(t[e],r[e]),t[e+3]=Math.max(t[e+3],r[e])};for(let n=1;n<8;++n){for(let t=0;t<3;++t)e[t]=
|
|
5
|
+
import{normalFromMat4Legacy as t}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as r,transpose as e,copy as i,multiply as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as n,g as h,l as f,r as l,e as m}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{d as c,g as _}from"../../../../chunks/sphere.js";import{ViewingMode as u}from"../../../ViewingMode.js";import{Obb as g,computeOffsetObb as M}from"../../support/orientedBoundingBox.js";class v{constructor(){this._transform=a(),this._transformInverse=new b({value:this._transform},r,a),this._transformInverseTranspose=new b(this._transformInverse,e,a),this._transformTranspose=new b({value:this._transform},e,a),this._transformInverseRotation=new b({value:this._transform},t,s)}_invalidateLazyTransforms(){this._transformInverse.invalidate(),this._transformInverseTranspose.invalidate(),this._transformTranspose.invalidate(),this._transformInverseRotation.invalidate()}get transform(){return this._transform}get inverse(){return this._transformInverse.value}get inverseTranspose(){return this._transformInverseTranspose.value}get inverseRotation(){return this._transformInverseRotation.value}get transpose(){return this._transformTranspose.value}setTransformMatrix(t){i(this._transform,t)}multiplyTransform(t){o(this._transform,this._transform,t)}set(t){i(this._transform,t),this._invalidateLazyTransforms()}setAndInvalidateLazyTransforms(t,s){this.setTransformMatrix(t),this.multiplyTransform(s),this._invalidateLazyTransforms()}}class b{constructor(t,s,r){this._original=t,this._update=s,this._dirty=!0,this._transform=r()}invalidate(){this._dirty=!0}get value(){return this._dirty&&(this._update(this._transform,this._original.value),this._dirty=!1),this._transform}}class T{constructor(t=0){this.offset=t,this.tmpVertex=p()}applyToVertex(t,s,r){const e=n(q,t,s,r),i=h(z,e,this.localOrigin),o=this.offset/f(i);return l(this.tmpVertex,e,i,o),this.tmpVertex}applyToAabb(t){const s=A,r=R,e=B;for(let n=0;n<3;++n)s[n]=t[0+n]+this.localOrigin[n],r[n]=t[3+n]+this.localOrigin[n],e[n]=s[n];const i=this.applyToVertex(s[0],s[1],s[2]);for(let n=0;n<3;++n)t[n]=i[n],t[n+3]=i[n];const o=s=>{const r=this.applyToVertex(s[0],s[1],s[2]);for(let e=0;e<3;++e)t[e]=Math.min(t[e],r[e]),t[e+3]=Math.max(t[e+3],r[e])};for(let n=1;n<8;++n){for(let t=0;t<3;++t)e[t]=n&1<<t?r[t]:s[t];o(e)}let a=0;for(let n=0;n<3;++n){s[n]*r[n]<0&&(a|=1<<n)}if(0!==a&&7!==a)for(let n=0;n<8;++n)if(!(a&n)){for(let t=0;t<3;++t)e[t]=a&1<<t?0:n&1<<t?s[t]:r[t];o(e)}for(let n=0;n<3;++n)t[n]-=this.localOrigin[n],t[n+3]-=this.localOrigin[n];return t}}class x{constructor(t=0){this.componentLocalOriginLength=0,this._totalOffset=0,this._offset=0,this._tmpVertex=p(),this._tmpMbs=c(),this._tmpObb=new g,this._resetOffset(t)}_resetOffset(t){this._offset=t,this._totalOffset=t}set offset(t){this._resetOffset(t)}get offset(){return this._offset}set componentOffset(t){this._totalOffset=this._offset+t}set localOrigin(t){this.componentLocalOriginLength=f(t)}applyToVertex(t,s,r){const e=n(q,t,s,r),i=n(z,t,s,r+this.componentLocalOriginLength),o=this._totalOffset/f(i);return l(this._tmpVertex,e,i,o),this._tmpVertex}applyToAabb(t){const s=this.componentLocalOriginLength,r=t[0],e=t[1],i=t[2]+s,o=t[3],a=t[4],n=t[5]+s,h=Math.abs(r),f=Math.abs(e),l=Math.abs(i),m=Math.abs(o),p=Math.abs(a),c=Math.abs(n),_=.5*(1+Math.sign(r*o))*Math.min(h,m),u=.5*(1+Math.sign(e*a))*Math.min(f,p),g=.5*(1+Math.sign(i*n))*Math.min(l,c),M=Math.max(h,m),v=Math.max(f,p),b=Math.max(l,c),T=Math.sqrt(_*_+u*u+g*g),x=Math.sign(h+r),O=Math.sign(f+e),y=Math.sign(l+i),d=Math.sign(m+o),V=Math.sign(p+a),L=Math.sign(c+n),j=this._totalOffset;if(T<j)return t[0]-=(1-x)*j,t[1]-=(1-O)*j,t[2]-=(1-y)*j,t[3]+=d*j,t[4]+=V*j,t[5]+=L*j,t;const I=j/Math.sqrt(M*M+v*v+b*b),w=j/T,q=w-I,z=-q;return t[0]+=r*(x*z+w),t[1]+=e*(O*z+w),t[2]+=i*(y*z+w),t[3]+=o*(d*q+I),t[4]+=a*(V*q+I),t[5]+=n*(L*q+I),t}applyToMbs(t){const s=f(_(t)),r=this._totalOffset/s;return l(_(this._tmpMbs),_(t),_(t),r),this._tmpMbs[3]=t[3]+t[3]*this._totalOffset/s,this._tmpMbs}applyToObb(t){return M(t,this._totalOffset,this._totalOffset,u.Global,this._tmpObb),this._tmpObb}}class O{constructor(t=0){this.offset=t,this.sphere=c(),this.tmpVertex=p()}applyToVertex(t,s,r){const e=this.objectTransform.transform,i=n(q,t,s,r),o=m(i,i,e),a=this.offset/f(o);l(o,o,o,a);const h=this.objectTransform.inverse;return m(this.tmpVertex,o,h),this.tmpVertex}applyToMinMax(t,s){const r=this.offset/f(t);l(t,t,t,r);const e=this.offset/f(s);l(s,s,s,e)}applyToAabb(t){const s=this.offset/Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]+=t[0]*s,t[1]+=t[1]*s,t[2]+=t[2]*s;const r=this.offset/Math.sqrt(t[3]*t[3]+t[4]*t[4]+t[5]*t[5]);return t[3]+=t[3]*r,t[4]+=t[4]*r,t[5]+=t[5]*r,t}applyToBoundingSphere(t){const s=f(_(t)),r=this.offset/s;return l(_(this.sphere),_(t),_(t),r),this.sphere[3]=t[3]+t[3]*this.offset/s,this.sphere}}const y=new O;function d(t){return null!=t?(y.offset=t,y):null}const V=new x;function L(t){return null!=t?(V.offset=t,V):null}const j=new T;function I(t){return null!=t?(j.offset=t,j):null}const w="terrain",q=p(),z=p(),A=p(),R=p(),B=p();export{x as I3SVerticalOffsetGlobalViewingMode,v as IntersectorTransform,O as Object3DVerticalOffsetGlobalViewingMode,T as TerrainVerticalOffsetGlobalViewingMode,L as getVerticalOffsetI3S,d as getVerticalOffsetObject3D,I as getVerticalOffsetTerrain,w as terrainId};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"../../../../core/has.js";import{clamp as e}from"../../../../core/mathUtils.js";import{fromMat4 as t}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as s}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{s as n,e as o,n as l,f as c,h as f,c as p,l as u,q as m,t as h,k as d,g}from"../../../../chunks/vec32.js";import{create as S,fromValues as O}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromArray as b,create as A,fromValues as T}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMat4 as v}from"../../../../core/libs/gl-matrix-2/types/mat4.js";import{create as E}from"../../../../geometry/support/aaBoundingRect.js";import{BufferViewVec4u8 as I}from"../../../../geometry/support/buffer/BufferView.js";import{evaluateModelTransformScale as _}from"../../layers/support/FastSymbolUpdates.js";import{debugFlags as y}from"../../support/debugFlags.js";import{newLayout as R}from"../../support/buffer/InterleavedLayout.js";import{isColorAlphaHighlightOrOID as x,ShaderOutput as P}from"../core/shaderLibrary/ShaderOutput.js";import{HUDVerticalPixelOffset as C}from"../core/shaderLibrary/hud/HUD.glsl.js";import{GLTextureMaterial as D,GLTextureMaterialBindParameters as j}from"../lib/GLTextureMaterial.js";import{Material as L,RenderOccludedFlag as N}from"../lib/Material.js";import{RenderSlot as U}from"../lib/RenderSlot.js";import{applyScaleFactor as w,applyPrecomputedScaleFactor as F,precomputeScaleFactor as M}from"../lib/screenSizePerspectiveUtils.js";import{assert as z}from"../lib/Util.js";import{VertexAttribute as V}from"../lib/VertexAttribute.js";import{ScaleInfo as B}from"./ScaleInfo.js";import{writePosition as G,writeNormal as q,writeColor as W,writeBufferVec4 as H,writeBufferVec4Zeros as X,writeObjectAndLayerIdColor as Y}from"./internal/bufferWriterUtils.js";import{verticalOffsetAtDistance as Z}from"./internal/MaterialUtil.js";import{c as k}from"../../../../chunks/HUDMaterial.glsl.js";import{HUDMaterialTechnique as J}from"../shaders/HUDMaterialTechnique.js";import{HUDMaterialTechniqueConfiguration as K}from"../shaders/HUDMaterialTechniqueConfiguration.js";class Q extends L{constructor(e){super(e,new Ae),this._configuration=new K,this.produces=new Map([[U.HUD_MATERIAL,e=>x(e)&&!this.parameters.drawInSecondSlot],[U.LABEL_MATERIAL,e=>x(e)&&this.parameters.drawInSecondSlot],[U.OCCLUSION_PIXELS,()=>this.parameters.occlusionTest],[U.DRAPED_MATERIAL,e=>x(e)]])}getConfiguration(e,t){return this._configuration.output=e,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasVerticalOffset=!!this.parameters.verticalOffset,this._configuration.hasScreenSizePerspective=!!this.parameters.screenSizePerspective,this._configuration.screenCenterOffsetUnitsEnabled="screen"===this.parameters.centerOffsetUnits,this._configuration.hasPolygonOffset=this.parameters.polygonOffset,this._configuration.draped=this.parameters.draped,this._configuration.occlusionTestEnabled=this.parameters.occlusionTest,this._configuration.pixelSnappingEnabled=this.parameters.pixelSnappingEnabled,this._configuration.signedDistanceFieldEnabled=this.parameters.textureIsSignedDistanceField,this._configuration.sampleSignedDistanceFieldTexelCenter=this.parameters.sampleSignedDistanceFieldTexelCenter,this._configuration.vvSize=!!this.parameters.vvSize,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration.occlusionPass=t.slot===U.OCCLUSION_PIXELS&&this.parameters.occlusionTest,e===P.Color&&(this._configuration.debugDrawLabelBorder=!!y.LABELS_SHOW_BORDER),this._configuration.depthEnabled=this.parameters.depthEnabled,this._configuration.transparencyPassType=t.transparencyPassType,this._configuration.multipassEnabled=t.multipassEnabled,this._configuration.cullAboveGround=t.multipassTerrain.cullAboveGround,this._configuration}intersect(e,r,i,a,h,d){if(!(i.options.selectionMode&&i.options.hud&&e.visible&&i.point))return;const g=this.parameters,O=i.point,b=i.camera;let{scaleX:A,scaleY:T}=this._getScreenScale(e);A*=b.pixelRatio,T*=b.pixelRatio,t(ce,r),e.attributes.has(V.FEATUREATTRIBUTE)&&te(ce);const v=e.attributes.get(V.POSITION),E=e.attributes.get(V.SIZE),I=e.attributes.get(V.NORMAL),_=e.attributes.get(V.CENTEROFFSETANDDISTANCE);z(v.size>=3);const y=k(g),R="screen"===this.parameters.centerOffsetUnits;for(let t=0;t<v.data.length/v.size;t++){const e=t*v.size;n(ie,v.data[e],v.data[e+1],v.data[e+2]),o(ie,ie,r);const a=t*E.size;Oe[0]=E.data[a]*A,Oe[1]=E.data[a+1]*T,o(ie,ie,b.viewMatrix);const h=t*_.size;if(n(ue,_.data[h],_.data[h+1],_.data[h+2]),!R&&(ie[0]+=ue[0],ie[1]+=ue[1],0!==ue[2])){const e=ue[2];l(ue,ie),c(ie,ie,f(ue,ue,e))}const x=t*I.size;if(n(ae,I.data[x],I.data[x+1],I.data[x+2]),this._normalAndViewAngle(ae,ce,b,de),this._applyVerticalOffsetTransformationView(ie,de,b,se),b.applyProjection(ie,ne),ne[0]>-1){R&&(ue[0]||ue[1])&&(ne[0]+=ue[0]*b.pixelRatio,0!==ue[1]&&(ne[1]+=w(ue[1],se.factorAlignment)*b.pixelRatio),b.unapplyProjection(ne,ie)),ne[0]+=this.parameters.screenOffset[0]*b.pixelRatio,ne[1]+=this.parameters.screenOffset[1]*b.pixelRatio,ne[0]=Math.floor(ne[0]),ne[1]=Math.floor(ne[1]),F(Oe,se.factor,Oe);const e=ge*b.pixelRatio;let t=0;if(g.textureIsSignedDistanceField&&(t=g.outlineSize*b.pixelRatio/2),re(O,ne[0],ne[1],Oe,e,t,g,y)){const e=i.ray;if(o(le,ie,s(pe,b.viewMatrix)),ne[0]=O[0],ne[1]=O[1],b.unprojectFromRenderScreen(ne,ie)){const t=S();p(t,e.direction);const r=1/u(t);f(t,t,r);d(m(e.origin,ie)*r,t,-1,!0,1,le)}}}}}intersectDraped(e,t,r,s,i,a){const n=e.attributes.get(V.POSITION),o=e.attributes.get(V.SIZE),l=this.parameters,c=k(l);let{scaleX:f,scaleY:p}=this._getScreenScale(e);f*=e.screenToWorldRatio,p*=e.screenToWorldRatio;const u=Se*e.screenToWorldRatio;for(let m=0;m<n.data.length/n.size;m++){const t=m*n.size,r=n.data[t],h=n.data[t+1],d=m*o.size;Oe[0]=o.data[d]*f,Oe[1]=o.data[d+1]*p;let g=0;l.textureIsSignedDistanceField&&(g=l.outlineSize*e.screenToWorldRatio/2),re(s,r,h,Oe,u,g,l,c)&&i(a.dist,a.normal,-1,!1)}}createBufferWriter(){return new Ee(this)}_normalAndViewAngle(e,r,s,i){return v(r)&&(r=t(fe,r)),h(i.normal,e,r),o(i.normal,i.normal,s.viewInverseTransposeMatrix),i.cosAngle=d(oe,be),i}_updateScaleInfo(e,t,r){const s=this.parameters;null!=s.screenSizePerspective?M(r,t,s.screenSizePerspective,e.factor):(e.factor.scale=1,e.factor.factor=0,e.factor.minScaleFactor=0),null!=s.screenSizePerspectiveAlignment?M(r,t,s.screenSizePerspectiveAlignment,e.factorAlignment):(e.factorAlignment.factor=e.factor.factor,e.factorAlignment.scale=e.factor.scale,e.factorAlignment.minScaleFactor=e.factor.minScaleFactor)}applyShaderOffsetsView(e,t,r,s,i,a,n){const o=this._normalAndViewAngle(t,r,i,de);return this._applyVerticalGroundOffsetView(e,o,i,n),this._applyVerticalOffsetTransformationView(n,o,i,a),this._applyPolygonOffsetView(n,o,s[3],i,n),this._applyCenterOffsetView(n,s,n),n}applyShaderOffsetsNDC(e,t,r,s,i){return this._applyCenterOffsetNDC(e,t,r,s),null!=i&&p(i,s),this._applyPolygonOffsetNDC(s,t,r,s),s}_applyPolygonOffsetView(t,r,s,i,a){const n=i.aboveGround?1:-1;let o=Math.sign(s);0===o&&(o=n);const l=n*o;if(this.parameters.shaderPolygonOffset<=0)return p(a,t);const c=e(Math.abs(r.cosAngle),.01,1),u=1-Math.sqrt(1-c*c)/c/i.viewport[2];return f(a,t,l>0?u:1/u),a}_applyVerticalGroundOffsetView(e,t,r,s){const i=u(e),a=r.aboveGround?1:-1,n=r.computeRenderPixelSizeAtDist(i)*C,o=f(ie,t.normal,a*n);return g(s,e,o),s}_applyVerticalOffsetTransformationView(e,t,r,s){const i=this.parameters;if(!i.verticalOffset?.screenLength){if(i.screenSizePerspective||i.screenSizePerspectiveAlignment){const r=u(e);this._updateScaleInfo(s,r,t.cosAngle)}else s.factor.scale=1,s.factorAlignment.scale=1;return e}const a=u(e),n=i.screenSizePerspectiveAlignment??i.screenSizePerspective,o=Z(r,a,i.verticalOffset,t.cosAngle,n);return this._updateScaleInfo(s,a,t.cosAngle),f(t.normal,t.normal,o),g(e,e,t.normal)}_applyCenterOffsetView(e,t,r){const s="screen"!==this.parameters.centerOffsetUnits;return r!==e&&p(r,e),s&&(r[0]+=t[0],r[1]+=t[1],t[2]&&(l(ae,r),g(r,r,f(ae,ae,t[2])))),r}_applyCenterOffsetNDC(e,t,r,s){const i="screen"!==this.parameters.centerOffsetUnits;return s!==e&&p(s,e),i||(s[0]+=t[0]/r.fullWidth*2,s[1]+=t[1]/r.fullHeight*2),s}_applyPolygonOffsetNDC(e,t,r,s){const i=this.parameters.shaderPolygonOffset;if(e!==s&&p(s,e),i){const e=r.aboveGround?1:-1,a=e*Math.sign(t[3]);s[2]-=(a||e)*i}return s}createGLMaterial(e){return new $(e)}calculateRelativeScreenBounds(e,t,r=E()){return ee(this.parameters,e,t,r),r[2]=r[0]+e[0],r[3]=r[1]+e[1],r}_getScreenScale(e){const t=e.attributes.get(V.FEATUREATTRIBUTE);if(null==t)return{scaleX:1,scaleY:1};const r=b(t.data,he),[s,i]=_(me,this.parameters,r);return{scaleX:s,scaleY:i}}}class $ extends D{constructor(e){super({...e,...e.material.parameters})}selectProgram(e){return this.ensureTechnique(J,e)}beginSlot(e){return this.updateTexture(this._material.parameters.textureId),this._material.setParameters(this.textureBindParameters),this.selectProgram(e)}}function ee(e,t,r,s){s[0]=e.anchorPosition[0]*-t[0]+e.screenOffset[0]*r,s[1]=e.anchorPosition[1]*-t[1]+e.screenOffset[1]*r}function te(e){const t=e[0],r=e[1],s=e[2],i=e[3],a=e[4],n=e[5],o=e[6],l=e[7],c=e[8],f=1/Math.sqrt(t*t+r*r+s*s),p=1/Math.sqrt(i*i+a*a+n*n),u=1/Math.sqrt(o*o+l*l+c*c);return e[0]=t*f,e[1]=r*f,e[2]=s*f,e[3]=i*p,e[4]=a*p,e[5]=n*p,e[6]=o*u,e[7]=l*u,e[8]=c*u,e}function re(e,t,r,s,i,a,n,o){let l=t-i-(o[0]>0?s[0]*o[0]:0),c=l+s[0]+2*i,f=r-i-(o[1]>0?s[1]*o[1]:0),p=f+s[1]+2*i;const u=n.distanceFieldBoundingBox;return n.textureIsSignedDistanceField&&null!=u&&(l+=s[0]*u[0],f+=s[1]*u[1],c-=s[0]*(1-u[2]),p-=s[1]*(1-u[3]),l-=a,c+=a,f-=a,p+=a),e[0]>l&&e[0]<c&&e[1]>f&&e[1]<p}const se=new B,ie=S(),ae=S(),ne=A(),oe=S(),le=S(),ce=r(),fe=r(),pe=i(),ue=S(),me=S(),he=A(),de={normal:oe,cosAngle:0},ge=1,Se=2,Oe=[0,0],be=O(0,0,1);class Ae extends j{constructor(){super(...arguments),this.renderOccluded=N.Occlude,this.isDecoration=!1,this.color=T(1,1,1,1),this.texCoordScale=[1,1],this.polygonOffset=!1,this.anchorPosition=a(.5,.5),this.screenOffset=[0,0],this.shaderPolygonOffset=1e-5,this.textureIsSignedDistanceField=!1,this.sampleSignedDistanceFieldTexelCenter=!1,this.outlineColor=T(1,1,1,1),this.outlineSize=0,this.vvSizeEnabled=!1,this.vvSize=null,this.vvColor=null,this.vvOpacity=null,this.vvSymbolAnchor=null,this.vvSymbolRotationMatrix=null,this.hasSlicePlane=!1,this.pixelSnappingEnabled=!0,this.occlusionTest=!0,this.centerOffsetUnits="world",this.drawInSecondSlot=!1,this.depthEnabled=!0,this.draped=!1}}const Te=R().vec3f(V.POSITION).vec3f(V.NORMAL).vec2f(V.UV0).vec4u8(V.COLOR).vec2f(V.SIZE).vec4f(V.CENTEROFFSETANDDISTANCE).vec4f(V.FEATUREATTRIBUTE),ve=Te.clone().vec4u8(V.OBJECTANDLAYERIDCOLOR);class Ee{constructor(e){this._material=e,this.vertexBufferLayout=has("enable-feature:objectAndLayerId-rendering")?ve:Te}elementCount(e){return 6*e.attributes.get(V.POSITION).indices.length}write(e,t,r,s,i){G(r.attributes.get(V.POSITION),e,s.position,i,6),q(r.attributes.get(V.NORMAL),t,s.normal,i,6);const a=r.attributes.get(V.UV0).data;let n,o,l,c;if(null==a||a.length<4){const e=this._material.parameters;n=0,o=0,l=e.texCoordScale[0],c=e.texCoordScale[1]}else n=a[0],o=a[1],l=a[2],c=a[3];l=Math.min(1.99999,l+1),c=Math.min(1.99999,c+1);let f=r.attributes.get(V.POSITION).indices.length,p=i;const u=s.uv0;for(let g=0;g<f;++g)u.set(p,0,n),u.set(p,1,o),p++,u.set(p,0,l),u.set(p,1,o),p++,u.set(p,0,l),u.set(p,1,c),p++,u.set(p,0,l),u.set(p,1,c),p++,u.set(p,0,n),u.set(p,1,c),p++,u.set(p,0,n),u.set(p,1,o),p++;W(r.attributes.get(V.COLOR),4,s.color,i,6);const{data:m,indices:h}=r.attributes.get(V.SIZE);f=h.length;const d=s.size;p=i;for(let g=0;g<f;++g){const e=m[2*h[g]],t=m[2*h[g]+1];for(let r=0;r<6;++r)d.set(p,0,e),d.set(p,1,t),p++}if(r.attributes.get(V.CENTEROFFSETANDDISTANCE)?H(r.attributes.get(V.CENTEROFFSETANDDISTANCE),s.centerOffsetAndDistance,i,6):X(s.centerOffsetAndDistance,i,6*f),r.attributes.get(V.FEATUREATTRIBUTE)?H(r.attributes.get(V.FEATUREATTRIBUTE),s.featureAttribute,i,6):X(s.featureAttribute,i,6*f),null!=r.objectAndLayerIdColor){const e=r.attributes.get(V.POSITION)?.indices;if(e){const t=e.length,a=s.getField(V.OBJECTANDLAYERIDCOLOR,I);Y(r.objectAndLayerIdColor,a,t,i,6)}}}}export{Q as HUDMaterial,Ae as Parameters};
|
|
5
|
+
import has from"../../../../core/has.js";import{clamp as e}from"../../../../core/mathUtils.js";import{fromMat4 as t}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as s}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{s as n,e as o,n as c,f as l,h as f,c as p,l as u,q as m,g as h,t as d,k as g}from"../../../../chunks/vec32.js";import{create as S,fromValues as O}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromArray as b,create as T,fromValues as A}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMat4 as v}from"../../../../core/libs/gl-matrix-2/types/mat4.js";import{create as E}from"../../../../geometry/support/aaBoundingRect.js";import{BufferViewVec4u8 as I}from"../../../../geometry/support/buffer/BufferView.js";import{evaluateModelTransformScale as _}from"../../layers/support/FastSymbolUpdates.js";import{debugFlags as y}from"../../support/debugFlags.js";import{newLayout as R}from"../../support/buffer/InterleavedLayout.js";import{isColorAlphaHighlightOrOID as x,ShaderOutput as P}from"../core/shaderLibrary/ShaderOutput.js";import{HUDVerticalPixelOffset as C}from"../core/shaderLibrary/hud/HUD.glsl.js";import{GLTextureMaterial as D,GLTextureMaterialBindParameters as j}from"../lib/GLTextureMaterial.js";import{Material as L,RenderOccludedFlag as N}from"../lib/Material.js";import{RenderSlot as U}from"../lib/RenderSlot.js";import{applyScaleFactor as F,applyPrecomputedScaleFactor as M,precomputeScaleFactor as z}from"../lib/screenSizePerspectiveUtils.js";import{assert as w}from"../lib/Util.js";import{VertexAttribute as V}from"../lib/VertexAttribute.js";import{ScaleInfo as B}from"./ScaleInfo.js";import{writePosition as G,writeNormal as q,writeColor as W,writeBufferVec4 as H,writeBufferVec4Zeros as X,writeObjectAndLayerIdColor as Y}from"./internal/bufferWriterUtils.js";import{verticalOffsetAtDistance as Z}from"./internal/MaterialUtil.js";import{c as k}from"../../../../chunks/HUDMaterial.glsl.js";import{HUDMaterialTechnique as J}from"../shaders/HUDMaterialTechnique.js";import{HUDMaterialTechniqueConfiguration as K}from"../shaders/HUDMaterialTechniqueConfiguration.js";class Q extends L{constructor(e){super(e,new Ae),this._configuration=new K,this.produces=new Map([[U.HUD_MATERIAL,e=>x(e)&&!this.parameters.drawInSecondSlot],[U.LABEL_MATERIAL,e=>x(e)&&this.parameters.drawInSecondSlot],[U.OCCLUSION_PIXELS,()=>this.parameters.occlusionTest],[U.DRAPED_MATERIAL,e=>x(e)]])}getConfiguration(e,t){return this._configuration.output=e,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasVerticalOffset=!!this.parameters.verticalOffset,this._configuration.hasScreenSizePerspective=!!this.parameters.screenSizePerspective,this._configuration.screenCenterOffsetUnitsEnabled="screen"===this.parameters.centerOffsetUnits,this._configuration.hasPolygonOffset=this.parameters.polygonOffset,this._configuration.draped=this.parameters.draped,this._configuration.occlusionTestEnabled=this.parameters.occlusionTest,this._configuration.pixelSnappingEnabled=this.parameters.pixelSnappingEnabled,this._configuration.signedDistanceFieldEnabled=this.parameters.textureIsSignedDistanceField,this._configuration.sampleSignedDistanceFieldTexelCenter=this.parameters.sampleSignedDistanceFieldTexelCenter,this._configuration.vvSize=!!this.parameters.vvSize,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration.occlusionPass=t.slot===U.OCCLUSION_PIXELS&&this.parameters.occlusionTest,e===P.Color&&(this._configuration.debugDrawLabelBorder=!!y.LABELS_SHOW_BORDER),this._configuration.depthEnabled=this.parameters.depthEnabled,this._configuration.transparencyPassType=t.transparencyPassType,this._configuration.multipassEnabled=t.multipassEnabled,this._configuration.cullAboveGround=t.multipassTerrain.cullAboveGround,this._configuration}intersect(e,r,i,a,h,d){if(!(i.options.selectionMode&&i.options.hud&&e.visible&&i.point))return;const g=this.parameters,O=i.point,b=i.camera;let{scaleX:T,scaleY:A}=this._getScreenScale(e);T*=b.pixelRatio,A*=b.pixelRatio,t(fe,r),e.attributes.has(V.FEATUREATTRIBUTE)&&re(fe);const v=e.attributes.get(V.POSITION),E=e.attributes.get(V.SIZE),I=e.attributes.get(V.NORMAL),_=e.attributes.get(V.CENTEROFFSETANDDISTANCE);w(v.size>=3);const y=k(g),R="screen"===this.parameters.centerOffsetUnits;for(let t=0;t<v.data.length/v.size;t++){const e=t*v.size;n(ae,v.data[e],v.data[e+1],v.data[e+2]),o(ae,ae,r);const a=t*E.size;be[0]=E.data[a]*T,be[1]=E.data[a+1]*A,o(ae,ae,b.viewMatrix);const h=t*_.size;if(n(me,_.data[h],_.data[h+1],_.data[h+2]),!R&&(ae[0]+=me[0],ae[1]+=me[1],0!==me[2])){const e=me[2];c(me,ae),l(ae,ae,f(me,me,e))}const x=t*I.size;if(n(ne,I.data[x],I.data[x+1],I.data[x+2]),te(ne,fe,b,ge),this._applyVerticalOffsetTransformationView(ae,ge,b,ie),b.applyProjection(ae,oe),oe[0]>-1){R&&(me[0]||me[1])&&(oe[0]+=me[0]*b.pixelRatio,0!==me[1]&&(oe[1]+=F(me[1],ie.factorAlignment)*b.pixelRatio),b.unapplyProjection(oe,ae)),oe[0]+=this.parameters.screenOffset[0]*b.pixelRatio,oe[1]+=this.parameters.screenOffset[1]*b.pixelRatio,oe[0]=Math.floor(oe[0]),oe[1]=Math.floor(oe[1]),M(be,ie.factor,be);const e=Se*b.pixelRatio;let t=0;if(g.textureIsSignedDistanceField&&(t=g.outlineSize*b.pixelRatio/2),se(O,oe[0],oe[1],be,e,t,g,y)){const e=i.ray;if(o(le,ae,s(ue,b.viewMatrix)),oe[0]=O[0],oe[1]=O[1],b.unprojectFromRenderScreen(oe,ae)){const t=S();p(t,e.direction);const r=1/u(t);f(t,t,r);d(m(e.origin,ae)*r,t,-1,!0,1,le)}}}}}intersectDraped(e,t,r,s,i,a){const n=e.attributes.get(V.POSITION),o=e.attributes.get(V.SIZE),c=this.parameters,l=k(c);let{scaleX:f,scaleY:p}=this._getScreenScale(e);f*=e.screenToWorldRatio,p*=e.screenToWorldRatio;const u=Oe*e.screenToWorldRatio;for(let m=0;m<n.data.length/n.size;m++){const t=m*n.size,r=n.data[t],h=n.data[t+1],d=m*o.size;be[0]=o.data[d]*f,be[1]=o.data[d+1]*p;let g=0;c.textureIsSignedDistanceField&&(g=c.outlineSize*e.screenToWorldRatio/2),se(s,r,h,be,u,g,c,l)&&i(a.dist,a.normal,-1,!1)}}createBufferWriter(){return new Ie(this)}_updateScaleInfo(e,t,r){const s=this.parameters;null!=s.screenSizePerspective?z(r,t,s.screenSizePerspective,e.factor):(e.factor.scale=1,e.factor.factor=0,e.factor.minScaleFactor=0),null!=s.screenSizePerspectiveAlignment?z(r,t,s.screenSizePerspectiveAlignment,e.factorAlignment):(e.factorAlignment.factor=e.factor.factor,e.factorAlignment.scale=e.factor.scale,e.factorAlignment.minScaleFactor=e.factor.minScaleFactor)}applyShaderOffsetsView(e,t,r,s,i,a,n){const o=te(t,r,i,ge);return this._applyVerticalGroundOffsetView(e,o,i,n),this._applyVerticalOffsetTransformationView(n,o,i,a),this._applyPolygonOffsetView(n,o,s[3],i,n),this._applyCenterOffsetView(n,s,n),n}applyShaderOffsetsNDC(e,t,r,s,i){return this._applyCenterOffsetNDC(e,t,r,s),null!=i&&p(i,s),this._applyPolygonOffsetNDC(s,t,r,s),s}_applyPolygonOffsetView(t,r,s,i,a){const n=i.aboveGround?1:-1;let o=Math.sign(s);0===o&&(o=n);const c=n*o;if(this.parameters.shaderPolygonOffset<=0)return p(a,t);const l=e(Math.abs(r.cosAngle),.01,1),u=1-Math.sqrt(1-l*l)/l/i.viewport[2];return f(a,t,c>0?u:1/u),a}_applyVerticalGroundOffsetView(e,t,r,s){const i=u(e),a=r.aboveGround?1:-1,n=r.computeRenderPixelSizeAtDist(i)*C,o=f(ae,t.normal,a*n);return h(s,e,o),s}_applyVerticalOffsetTransformationView(e,t,r,s){const i=this.parameters;if(!i.verticalOffset?.screenLength){if(i.screenSizePerspective||i.screenSizePerspectiveAlignment){const r=u(e);this._updateScaleInfo(s,r,t.cosAngle)}else s.factor.scale=1,s.factorAlignment.scale=1;return e}const a=u(e),n=i.screenSizePerspectiveAlignment??i.screenSizePerspective,o=Z(r,a,i.verticalOffset,t.cosAngle,n);return this._updateScaleInfo(s,a,t.cosAngle),f(t.normal,t.normal,o),h(e,e,t.normal)}_applyCenterOffsetView(e,t,r){const s="screen"!==this.parameters.centerOffsetUnits;return r!==e&&p(r,e),s&&(r[0]+=t[0],r[1]+=t[1],t[2]&&(c(ne,r),h(r,r,f(ne,ne,t[2])))),r}_applyCenterOffsetNDC(e,t,r,s){const i="screen"!==this.parameters.centerOffsetUnits;return s!==e&&p(s,e),i||(s[0]+=t[0]/r.fullWidth*2,s[1]+=t[1]/r.fullHeight*2),s}_applyPolygonOffsetNDC(e,t,r,s){const i=this.parameters.shaderPolygonOffset;if(e!==s&&p(s,e),i){const e=r.aboveGround?1:-1,a=e*Math.sign(t[3]);s[2]-=(a||e)*i}return s}createGLMaterial(e){return new $(e)}calculateRelativeScreenBounds(e,t,r=E()){return ee(this.parameters,e,t,r),r[2]=r[0]+e[0],r[3]=r[1]+e[1],r}_getScreenScale(e){const t=e.attributes.get(V.FEATUREATTRIBUTE);if(null==t)return{scaleX:1,scaleY:1};const r=b(t.data,de),[s,i]=_(he,this.parameters,r);return{scaleX:s,scaleY:i}}}class $ extends D{constructor(e){super({...e,...e.material.parameters})}selectProgram(e){return this.ensureTechnique(J,e)}beginSlot(e){return this.updateTexture(this._material.parameters.textureId),this._material.setParameters(this.textureBindParameters),this.selectProgram(e)}}function ee(e,t,r,s){s[0]=e.anchorPosition[0]*-t[0]+e.screenOffset[0]*r,s[1]=e.anchorPosition[1]*-t[1]+e.screenOffset[1]*r}function te(e,r,s,i){return v(r)&&(r=t(pe,r)),d(i.normal,e,r),o(i.normal,i.normal,s.viewInverseTransposeMatrix),i.cosAngle=g(ce,Te),i}function re(e){const t=e[0],r=e[1],s=e[2],i=e[3],a=e[4],n=e[5],o=e[6],c=e[7],l=e[8],f=1/Math.sqrt(t*t+r*r+s*s),p=1/Math.sqrt(i*i+a*a+n*n),u=1/Math.sqrt(o*o+c*c+l*l);return e[0]=t*f,e[1]=r*f,e[2]=s*f,e[3]=i*p,e[4]=a*p,e[5]=n*p,e[6]=o*u,e[7]=c*u,e[8]=l*u,e}function se(e,t,r,s,i,a,n,o){let c=t-i-(o[0]>0?s[0]*o[0]:0),l=c+s[0]+2*i,f=r-i-(o[1]>0?s[1]*o[1]:0),p=f+s[1]+2*i;const u=n.distanceFieldBoundingBox;return n.textureIsSignedDistanceField&&null!=u&&(c+=s[0]*u[0],f+=s[1]*u[1],l-=s[0]*(1-u[2]),p-=s[1]*(1-u[3]),c-=a,l+=a,f-=a,p+=a),e[0]>c&&e[0]<l&&e[1]>f&&e[1]<p}const ie=new B,ae=S(),ne=S(),oe=T(),ce=S(),le=S(),fe=r(),pe=r(),ue=i(),me=S(),he=S(),de=T(),ge={normal:ce,cosAngle:0},Se=1,Oe=2,be=[0,0],Te=O(0,0,1);class Ae extends j{constructor(){super(...arguments),this.renderOccluded=N.Occlude,this.isDecoration=!1,this.color=A(1,1,1,1),this.texCoordScale=[1,1],this.polygonOffset=!1,this.anchorPosition=a(.5,.5),this.screenOffset=[0,0],this.shaderPolygonOffset=1e-5,this.textureIsSignedDistanceField=!1,this.sampleSignedDistanceFieldTexelCenter=!1,this.outlineColor=A(1,1,1,1),this.outlineSize=0,this.vvSizeEnabled=!1,this.vvSize=null,this.vvColor=null,this.vvOpacity=null,this.vvSymbolAnchor=null,this.vvSymbolRotationMatrix=null,this.hasSlicePlane=!1,this.pixelSnappingEnabled=!0,this.occlusionTest=!0,this.centerOffsetUnits="world",this.drawInSecondSlot=!1,this.depthEnabled=!0,this.draped=!1}}const ve=R().vec3f(V.POSITION).vec3f(V.NORMAL).vec2f(V.UV0).vec4u8(V.COLOR).vec2f(V.SIZE).vec4f(V.CENTEROFFSETANDDISTANCE).vec4f(V.FEATUREATTRIBUTE),Ee=ve.clone().vec4u8(V.OBJECTANDLAYERIDCOLOR);class Ie{constructor(e){this._material=e,this.vertexBufferLayout=has("enable-feature:objectAndLayerId-rendering")?Ee:ve}elementCount(e){return 6*e.attributes.get(V.POSITION).indices.length}write(e,t,r,s,i){G(r.attributes.get(V.POSITION),e,s.position,i,6),q(r.attributes.get(V.NORMAL),t,s.normal,i,6);const a=r.attributes.get(V.UV0).data;let n,o,c,l;if(null==a||a.length<4){const e=this._material.parameters;n=0,o=0,c=e.texCoordScale[0],l=e.texCoordScale[1]}else n=a[0],o=a[1],c=a[2],l=a[3];c=Math.min(1.99999,c+1),l=Math.min(1.99999,l+1);let f=r.attributes.get(V.POSITION).indices.length,p=i;const u=s.uv0;for(let g=0;g<f;++g)u.set(p,0,n),u.set(p,1,o),p++,u.set(p,0,c),u.set(p,1,o),p++,u.set(p,0,c),u.set(p,1,l),p++,u.set(p,0,c),u.set(p,1,l),p++,u.set(p,0,n),u.set(p,1,l),p++,u.set(p,0,n),u.set(p,1,o),p++;W(r.attributes.get(V.COLOR),4,s.color,i,6);const{data:m,indices:h}=r.attributes.get(V.SIZE);f=h.length;const d=s.size;p=i;for(let g=0;g<f;++g){const e=m[2*h[g]],t=m[2*h[g]+1];for(let r=0;r<6;++r)d.set(p,0,e),d.set(p,1,t),p++}if(r.attributes.get(V.CENTEROFFSETANDDISTANCE)?H(r.attributes.get(V.CENTEROFFSETANDDISTANCE),s.centerOffsetAndDistance,i,6):X(s.centerOffsetAndDistance,i,6*f),r.attributes.get(V.FEATUREATTRIBUTE)?H(r.attributes.get(V.FEATUREATTRIBUTE),s.featureAttribute,i,6):X(s.featureAttribute,i,6*f),null!=r.objectAndLayerIdColor){const e=r.attributes.get(V.POSITION)?.indices;if(e){const t=e.length,a=s.getField(V.OBJECTANDLAYERIDCOLOR,I);Y(r.objectAndLayerIdColor,a,t,i,6)}}}}export{Q as HUDMaterial,Ae as Parameters};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{clamp as e}from"../../../../core/mathUtils.js";import{fromValues as t}from"../../../../geometry/support/aaBoundingBox.js";import{newLayout as r}from"../../support/buffer/InterleavedLayout.js";import{isShadowRelatedOutput as i,is3DGeometryOutput as s,ShaderOutput as a}from"../core/shaderLibrary/ShaderOutput.js";import{NormalsDoubleSidedMode as o}from"../core/shaderLibrary/shading/Normals.glsl.js";import n from"../lib/GLMaterial.js";import{Material as h}from"../lib/Material.js";import{isPathGeometry as u}from"../lib/PathGeometry.js";import{intersectAabbInvDir as c}from"../lib/RayIntersections.js";import{RenderSlot as
|
|
5
|
+
import{clamp as e}from"../../../../core/mathUtils.js";import{fromValues as t}from"../../../../geometry/support/aaBoundingBox.js";import{newLayout as r}from"../../support/buffer/InterleavedLayout.js";import{isShadowRelatedOutput as i,is3DGeometryOutput as s,ShaderOutput as a}from"../core/shaderLibrary/ShaderOutput.js";import{NormalsDoubleSidedMode as o}from"../core/shaderLibrary/shading/Normals.glsl.js";import n from"../lib/GLMaterial.js";import{Material as h}from"../lib/Material.js";import{isPathGeometry as u}from"../lib/PathGeometry.js";import{intersectAabbInvDir as c}from"../lib/RayIntersections.js";import{RenderSlot as d}from"../lib/RenderSlot.js";import{VertexAttribute as l}from"../lib/VertexAttribute.js";import{DefaultBufferWriter as p}from"./DefaultBufferWriter.js";import{vertexAttributeLocations as m,PathTechniqueConfiguration as f,PathTechnique as b,PathPassParameters as S}from"./PathTechnique.js";class v extends h{constructor(e){super(e,new w),this.supportsEdges=!0,this.produces=new Map([[d.OPAQUE_MATERIAL,e=>(this.parameters.castShadows&&i(e)||s(e))&&!this.parameters.transparent],[d.TRANSPARENT_MATERIAL,e=>(this.parameters.castShadows&&i(e)||s(e))&&this.parameters.transparent]]),this._vertexAttributeLocations=m,this._configuration=new f,this._vertexBufferLayout=v.getVertexBufferLayout()}getConfiguration(e,t){return this._configuration.output=e,this._configuration.vvSize=!!this.parameters.vvSize,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration.vvOpacity=!!this.parameters.vvOpacity,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.transparent=this.parameters.transparent,this._configuration.hasOccludees=this.parameters.hasOccludees,e!==a.Color&&e!==a.Alpha||(this._configuration.doubleSidedMode=this.parameters.doubleSided&&"normal"===this.parameters.doubleSidedType?o.View:this.parameters.doubleSided&&"winding-order"===this.parameters.doubleSidedType?o.WindingOrder:o.None,this._configuration.receiveShadows=this.parameters.receiveShadows,this._configuration.receiveAmbientOcclusion=null!=t.ssao),this._configuration.transparencyPassType=t.transparencyPassType,this._configuration.multipassEnabled=t.multipassEnabled,this._configuration.cullAboveGround=t.multipassTerrain.cullAboveGround,this._configuration}isVisibleForOutput(e){return e!==a.Shadow&&e!==a.ShadowExcludeHighlight&&e!==a.ShadowHighlight||this.parameters.castShadows}isVisible(){return super.isVisible()&&this.parameters.opacity>0}intersect(r,i,s,a,o,n){const h=r;if(!u(h))return;const d=h.path,l=[this.parameters.size[0],this.parameters.size[1]];if(this.parameters.vvSize){const{offset:t,factor:r,minSize:i,maxSize:s}=this.parameters.vvSize,a=d.sizeAttributeValue;l[0]*=e(t[0]+a*r[0],i[0],s[0]),l[1]*=e(t[2]+a*r[2],i[2],s[2])}const p=Math.max(l[0],l[1]),m=r.boundingInfo;if(null==m)return void _(d,l,a,o,n);const f=t(m.bbMin[0]-p,m.bbMin[1]-p,m.bbMin[2]-p,m.bbMax[0]+p,m.bbMax[1]+p,m.bbMax[2]+p),b=[o[0]-a[0],o[1]-a[1],o[2]-a[2]],S=Math.sqrt(b[0]*b[0]+b[1]*b[1]+b[2]*b[2]),v=[S/b[0],S/b[1],S/b[2]];c(f,a,v,s.tolerance)&&_(d,l,a,o,n)}createBufferWriter(){return new p(this._vertexBufferLayout)}createGLMaterial(e){return new g(e)}static getVertexBufferLayout(){return r().vec3f(l.POSITION).vec4f(l.PROFILERIGHT).vec4f(l.PROFILEUP).vec4f(l.PROFILEVERTEXANDNORMAL).vec4f(l.FEATUREVALUE)}}class g extends n{_updateOccludeeState(e){e.hasOccludees!==this._material.parameters.hasOccludees&&this._material.setParameters({hasOccludees:e.hasOccludees})}_updateShadowState(e){null!=this.technique&&e.shadowMap.enabled===this.technique.configuration.receiveShadows||this._material.setParameters({receiveShadows:e.shadowMap.enabled})}beginSlot(e){return this._output!==a.Color&&this._output!==a.Alpha||(this._updateShadowState(e),this._updateOccludeeState(e)),this.ensureTechnique(b,e)}}function _(e,t,r,i,s){e.baked.size&&e.baked.size[0]===t[0]&&e.baked.size[1]===t[1]||e.baked.bake(t),e.baked.intersect(r,i,s)}class w extends S{constructor(){super(...arguments),this.doubleSided=!1,this.doubleSidedType="normal",this.receiveShadows=!1,this.castShadows=!0,this.hasSlicePlane=!1,this.transparent=!1,this.hasOccludees=!1}}export{v as PathMaterial,w as PathMaterialParameters};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"../../../../core/has.js";import{fromValues as e}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{BufferViewMat3f as t,BufferViewVec4f as r}from"../../../../geometry/support/buffer/BufferView.js";import{newLayout as s}from"../../support/buffer/InterleavedLayout.js";import{isOIDorHighlight as i,isColorOrAlpha as a,ShaderOutput as o}from"../core/shaderLibrary/ShaderOutput.js";import{CullFaceOptions as n}from"../lib/basicInterfaces.js";import c from"../lib/GLMaterial.js";import{OITPolygonOffsetLimit as l}from"../lib/OrderIndependentTransparency.js";import{RenderSlot as u}from"../lib/RenderSlot.js";import{assert as
|
|
5
|
+
import has from"../../../../core/has.js";import{fromValues as e}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{BufferViewMat3f as t,BufferViewVec4f as r}from"../../../../geometry/support/buffer/BufferView.js";import{newLayout as s}from"../../support/buffer/InterleavedLayout.js";import{isOIDorHighlight as i,isColorOrAlpha as a,ShaderOutput as o}from"../core/shaderLibrary/ShaderOutput.js";import{CullFaceOptions as n}from"../lib/basicInterfaces.js";import c from"../lib/GLMaterial.js";import{OITPolygonOffsetLimit as l}from"../lib/OrderIndependentTransparency.js";import{RenderSlot as u}from"../lib/RenderSlot.js";import{assert as p}from"../lib/Util.js";import{VertexAttribute as f}from"../lib/VertexAttribute.js";import{DefaultBufferWriter as h}from"./DefaultBufferWriter.js";import{Style as m}from"./PatternStyle.js";import{TriangleMaterial as d}from"./TriangleMaterial.js";import{VisualVariablePassParameters as g}from"./VisualVariablePassParameters.js";import{writeDefaultAttributes as _,writeBufferVec4 as b}from"./internal/bufferWriterUtils.js";import{vertexAttributeLocationsOID as A,vertexAttributeLocations as O,PatternTechniqueConfiguration as T,PatternTechnique as y}from"../shaders/PatternTechnique.js";class P extends d{constructor(e){super(e,new j),this.supportsEdges=!0,this.produces=new Map([[u.OPAQUE_MATERIAL,e=>i(e)],[u.TRANSPARENT_MATERIAL,e=>a(e)],[u.TRANSPARENT_NO_SSAO_DEPTH,e=>e===o.LinearDepth&&this.parameters.writeLinearDepth],[u.DRAPED_MATERIAL,e=>this.parameters.draped&&e===o.Color||i(e)]]),this._vertexAttributeLocations=has("enable-feature:objectAndLayerId-rendering")?A:O,this._configuration=new T}getConfiguration(e,t){return this._configuration.output=e,this._configuration.cullFace=this.parameters.cullFace,this._configuration.hasVertexColors=this.parameters.hasVertexColors&&!this.parameters.vvColor,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.polygonOffset=this.parameters.polygonOffset,this._configuration.style=this.parameters.style,this._configuration.patternSpacing=this.parameters.patternSpacing,this._configuration.lineWidth=this.parameters.lineWidth,this._configuration.draped=this.parameters.draped,this._configuration.transparencyPassType=t.transparencyPassType,this._configuration.enableOffset=t.camera.relativeElevation<l,this._configuration.multipassEnabled=t.multipassEnabled,this._configuration.cullAboveGround=t.multipassTerrain.cullAboveGround,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration}createGLMaterial(e){return new v(e)}createBufferWriter(){const e=s().vec3f(f.POSITION).vec4f(f.UVMAPSPACE);return this.parameters.draped||e.mat3f(f.BOUNDINGRECT),this.parameters.vvColor?e.f32(f.COLORFEATUREATTRIBUTE):e.vec4u8(f.COLOR),has("enable-feature:objectAndLayerId-rendering")&&e.vec4u8(f.OBJECTANDLAYERIDCOLOR),new E(e)}}class v extends c{_updateParameters(e){return this.ensureTechnique(y,e)}_updateOccludeeState(e){e.hasOccludees!==this._material.parameters.hasOccludees&&this._material.setParameters({hasOccludees:e.hasOccludees})}beginSlot(e){return this._output!==o.Color&&this._output!==o.Alpha||this._updateOccludeeState(e),this._updateParameters(e)}}class E extends h{write(e,s,i,a,o){_(i,this.vertexBufferLayout,e,s,a,o);for(const n of this.vertexBufferLayout.fields.keys()){const s=i.attributes.get(n),c=s?.indices;if(s&&c)switch(n){case f.UVMAPSPACE:{p(4===s.size);const e=a.getField(n,r);e&&b(s,e,o);break}case f.BOUNDINGRECT:{p(9===s.size);const r=a.getField(n,t);r&&S(s,e,r,o);break}}}}}function S(e,t,r,s){const{data:i,indices:a}=e,o=t,n=r.typedBuffer,c=r.typedBufferStride,l=a.length;s*=c;for(let u=0;u<l;++u){const e=9*a[u],t=i[e],r=i[e+1],l=i[e+2];n[s]=o[0]*t+o[4]*r+o[8]*l+o[12],n[s+1]=o[1]*t+o[5]*r+o[9]*l+o[13],n[s+2]=o[2]*t+o[6]*r+o[10]*l+o[14];for(let a=3;a<9;++a)n[s+a]=i[e+a];s+=c}}class j extends g{constructor(){super(...arguments),this.color=e(1,1,1,1),this.writeLinearDepth=!1,this.hasVertexColors=!1,this.polygonOffset=!1,this.hasSlicePlane=!1,this.cullFace=n.None,this.hasOccludees=!1,this.style=m.Cross,this.patternSpacing=10,this.lineWidth=1,this.draped=!0}}export{j as Parameters,P as PatternMaterial};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import r from"../../../../core/Evented.js";import has from"../../../../core/has.js";import s from"../../../../core/Logger.js";import{removeMaybe as i,destroyMaybe as n}from"../../../../core/maybe.js";import{watch as o,initial as a,syncAndInitial as h}from"../../../../core/reactiveUtils.js";import{addFrameTask as p}from"../../../../core/scheduling.js";import{Milliseconds as d}from"../../../../core/time.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/RandomLCG.js";import{subclass as l}from"../../../../core/accessorSupport/decorators/subclass.js";import{ComponentObjectCollection as m}from"../collections/Component/ComponentObjectCollection.js";import{ShaderTechniqueRepository as u}from"../core/shaderTechnique/ShaderTechniqueRepository.js";import{RenderRequestType as _}from"../lib/basicInterfaces.js";import f from"../lib/CompositingHelper.js";import{textureToDepth as g}from"../lib/depthRangeUtils.js";import{GLMaterialRepository as x}from"../lib/GLMaterialRepository.js";import{MagnifierHelper as b}from"../lib/MagnifierHelper.js";import{UpdateParameters as y}from"../lib/Material.js";import{ObjectAndLayerIdRenderHelper as R}from"../lib/ObjectAndLayerIdRenderHelper.js";import{Renderer as v}from"../lib/Renderer.js";import{RenderingContext as j}from"../lib/RenderingContext.js";import{TextureRepository as w}from"../lib/TextureRepository.js";import{createMarkerTextureRepository as T}from"../materials/markerTextureRepository.js";import{createStippleTextureRepository as A}from"../materials/stippleTextureRepository.js";import{WaterTextureRepository as C}from"../materials/internal/WaterTextureRepository.js";import{getContextCache as U}from"./contextCache.js";import{removeLoadedShaderModules as O}from"./requireUtils.js";import{ScreenshotManager as q,ScreenshotContext as L}from"./ScreenshotManager.js";import{contextCache as D}from"./testUtils.js";import{RenderState as H}from"../../../support/RenderState.js";import{createContext as S}from"../../../webgl/contextUtils.js";let k=class extends t{constructor(e){super({}),this.events=new r,this.waterTextures=new C,this._magnifierHelper=new b,this.objectAndLayerIdRenderHelper=has("enable-feature:objectAndLayerId-rendering")?new R:null,this._needsUpdate=!0,this._needsRender=!0,this._idleSuspend=!0,this._needsWaterReflectionUpdate=!1,this._lastAnimationUpdate=0,this._container=e.container,this._viewingMode=e.viewingMode;try{this._initializeContext(e)}catch(i){return void console.error("Failed to initialize context",i)}this.addHandles([o((()=>this.waterTextures?.updating),(()=>this.requestRender()),a),o((()=>e.view.qualityProfile),(e=>this.renderer?.updateRenderFeatures(e)),h),this._magnifierHelper.events.on("request-render",(()=>this.requestRender()))]);const{memoryController:t}=e.view.resourceController;this.stippleTextures=A(this._rctx,t),this.markerTextures=T(this._rctx,t),this._shaderTechniques=new u({rctx:this._rctx,viewingMode:e.viewingMode,stippleTextureRepository:this.stippleTextures,waterTextureRepository:this.waterTextures,markerTextureRepository:this.markerTextures}),this._textures=new w(e,this._shaderTechniques,this._rctx),this.addHandles(this._textures.events.on("changed",(e=>this.requestRender(e)))),this._materialRepository=new x(this._textures,this._shaderTechniques,(()=>this.requestRender()),(()=>this.requestRender())),this._compositingHelper=new f(this._rctx,this._shaderTechniques),this.renderer=new v(e,this._materialRepository,this._textures,this._shaderTechniques,this._rctx,this._compositingHelper,this._magnifierHelper,(e=>this.requestRender(e)));const s={renderScene:(e,t,r,s)=>this.renderer.render(e,t,r,s),requestRenderScene:e=>this.requestRender(e),prepareOverlay:()=>e.options.screenshot.prepareOverlay(),renderOverlay:(t,r,s)=>e.options.screenshot.renderOverlay(t,r,s)};this._screenshotManager=new q(this._rctx,s,(e=>this.events.emit("force-camera-for-screenshot",e))),this._registerFrameTask(e)}normalizeCtorArgs(){return{}}destroy(){this._container.contains(this._canvas)&&this._container.removeChild(this._canvas),this._frameTask=i(this._frameTask),this._shaderTechniques=n(this._shaderTechniques),this._componentObjects=n(this._componentObjects),this._screenshotManager=n(this._screenshotManager),n(this.renderer),this._textures=n(this._textures),n(this._magnifierHelper),n(this.waterTextures),n(this.markerTextures),n(this.stippleTextures),this._canvas=null,this._container=null,this._rctx=n(this._rctx)}requestRender(e=_.UPDATE){this._needsRender=!0,e===_.UPDATE&&(this._needsUpdate=!0)}get updating(){return this._needsUpdate||this._needsWaterReflectionUpdate||this.renderer.updating||this._textures.updating||this.waterTextures.updating||this._magnifierHelper.updating}get textureRepository(){return this._textures}get compositingHelper(){return this._compositingHelper}set magnifier(e){this._magnifierHelper.magnifier=e}setIdleSuspend(e){this._idleSuspend!==e&&(this._idleSuspend=e,this.requestRender())}get renderingContext(){return this._rctx}get capabilities(){return this._rctx.capabilities}get canvas(){return this._canvas}takeScreenshot(e){return this._screenshotManager.takeScreenshot(e).then((e=>e[0]))}takeScreenshotWithOID(e){return e.objectAndLayerIdColor=!0,this._screenshotManager.takeScreenshot(e)}getAlpha(){return!!this._rctx.contextAttributes.alpha}getMinimalDepthForArea(e,t,r,s,i,n=i){const o=s.constrainWindowSize(t,r,i*s.pixelRatio,n*s.pixelRatio),a=this._ensureDepthBuffer(o);this.renderer.readDepthPixels(s,o,a);let h=Number.MAX_VALUE;for(let p=0;p<o[2]*o[3];p++){const e=g(4*p,a,s.nearFar);h>e&&e!==s.nearFar[0]&&e!==s.nearFar[1]&&(h=e)}if(e){const i=e.pickDepth(t*s.pixelRatio,r*s.pixelRatio,s);null!=i&&h>i&&i!==s.nearFar[0]&&i!==s.nearFar[1]&&(h=i)}return h===Number.MAX_VALUE?void 0:h}_ensureDepthBuffer(e){const t=4*e[2]*e[3];return(null==this._tmpDepthBuffer||this._tmpDepthBuffer.byteLength<t)&&(this._tmpDepthBuffer=new Uint8Array(t)),this._tmpDepthBuffer}async reloadShaders(){O(),await this._shaderTechniques.reloadAll(),this.requestRender()}_registerFrameTask(e){const t=e.view.state;let r=!1,s=_.BACKGROUND,i=!1;const n={preRender:({time:i})=>{r=this.updating,s=this._needsUpdate?_.UPDATE:_.BACKGROUND,e.commitSyncLayers();const n=d(i-this._lastAnimationUpdate);if(n>this.renderer.animationTimestep||null!=t.forcedAnimationTime||r||this._needsRender){const e=d(n/this.renderer.animationTimeDilation),r=new y(t.camera,e,t.forcedAnimationTime);this.renderer.updateAnimation(r)&&this.requestRender(_.BACKGROUND),this._lastAnimationUpdate=i}},render:({time:e})=>{if((this._needsRender||!this._idleSuspend||!this.renderer.isCameraFinal||this._needsWaterReflectionUpdate)&&t.camera.fullWidth>0&&t.camera.fullHeight>0){const r=this._needsUpdate&&this._idleSuspend&&this.renderer.isCameraFinal;this._needsRender=!1,this._needsUpdate=!1,this._needsWaterReflectionUpdate=!1,this.renderer.render(t,e),i=!0,r&&this.renderer.hasReflections&&(this.requestRender(_.BACKGROUND),this._needsWaterReflectionUpdate=!0)}},update:({time:e})=>{const r=this.renderer.hasSlicePlane||this._magnifierHelper.enabled||this.renderer.hasDecorations||this.renderer.hasHighlights,s=new L(t,r,this.renderer.fboCache);this._textures.update(),this._screenshotManager.update(s,e)},finish:()=>{i&&(this.renderer.finish(t.mode===H.IDLE?s:_.UPDATE),i=!1)}};this._frameTask=p(n)}_initializeContext(e){const t=e.options;this._canvas=t.canvas,this._canvas||(this._canvas=document.createElement("canvas")),this._canvas.setAttribute("style","width: 100%; height:100%; display:block;");const r={alpha:t.alpha||!1,premultipliedAlpha:!0,antialias:!1,depth:!0,stencil:t.stencil??!0,powerPreference:"high-performance",preserveDrawingBuffer:t.preserveDrawingBuffer??!1},i=S(this._canvas,r);null!=i?(this._rctx=
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import r from"../../../../core/Evented.js";import has from"../../../../core/has.js";import s from"../../../../core/Logger.js";import{removeMaybe as i,destroyMaybe as n}from"../../../../core/maybe.js";import{watch as o,initial as a,syncAndInitial as h}from"../../../../core/reactiveUtils.js";import{addFrameTask as p}from"../../../../core/scheduling.js";import{Milliseconds as d}from"../../../../core/time.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/RandomLCG.js";import{subclass as l}from"../../../../core/accessorSupport/decorators/subclass.js";import{ComponentObjectCollection as m}from"../collections/Component/ComponentObjectCollection.js";import{ShaderTechniqueRepository as u}from"../core/shaderTechnique/ShaderTechniqueRepository.js";import{RenderRequestType as _}from"../lib/basicInterfaces.js";import f from"../lib/CompositingHelper.js";import{textureToDepth as g}from"../lib/depthRangeUtils.js";import{GLMaterialRepository as x}from"../lib/GLMaterialRepository.js";import{MagnifierHelper as b}from"../lib/MagnifierHelper.js";import{UpdateParameters as y}from"../lib/Material.js";import{ObjectAndLayerIdRenderHelper as R}from"../lib/ObjectAndLayerIdRenderHelper.js";import{Renderer as v}from"../lib/Renderer.js";import{RenderingContext as j}from"../lib/RenderingContext.js";import{TextureRepository as w}from"../lib/TextureRepository.js";import{createMarkerTextureRepository as T}from"../materials/markerTextureRepository.js";import{createStippleTextureRepository as A}from"../materials/stippleTextureRepository.js";import{WaterTextureRepository as C}from"../materials/internal/WaterTextureRepository.js";import{getContextCache as U}from"./contextCache.js";import{removeLoadedShaderModules as O}from"./requireUtils.js";import{ScreenshotManager as q,ScreenshotContext as L}from"./ScreenshotManager.js";import{contextCache as D}from"./testUtils.js";import{RenderState as H}from"../../../support/RenderState.js";import{createContext as S}from"../../../webgl/contextUtils.js";let k=class extends t{constructor(e){super({}),this.events=new r,this.waterTextures=new C,this._magnifierHelper=new b,this.objectAndLayerIdRenderHelper=has("enable-feature:objectAndLayerId-rendering")?new R:null,this._needsUpdate=!0,this._needsRender=!0,this._idleSuspend=!0,this._needsWaterReflectionUpdate=!1,this._lastAnimationUpdate=0,this._container=e.container,this._viewingMode=e.viewingMode;try{this._initializeContext(e)}catch(i){return void console.error("Failed to initialize context",i)}this.addHandles([o((()=>this.waterTextures?.updating),(()=>this.requestRender()),a),o((()=>e.view.qualityProfile),(e=>this.renderer?.updateRenderFeatures(e)),h),this._magnifierHelper.events.on("request-render",(()=>this.requestRender()))]);const{memoryController:t}=e.view.resourceController;this.stippleTextures=A(this._rctx,t),this.markerTextures=T(this._rctx,t),this._shaderTechniques=new u({rctx:this._rctx,viewingMode:e.viewingMode,stippleTextureRepository:this.stippleTextures,waterTextureRepository:this.waterTextures,markerTextureRepository:this.markerTextures}),this._textures=new w(e,this._shaderTechniques,this._rctx),this.addHandles(this._textures.events.on("changed",(e=>this.requestRender(e)))),this._materialRepository=new x(this._textures,this._shaderTechniques,(()=>this.requestRender()),(()=>this.requestRender())),this._compositingHelper=new f(this._rctx,this._shaderTechniques),this.renderer=new v(e,this._materialRepository,this._textures,this._shaderTechniques,this._rctx,this._compositingHelper,this._magnifierHelper,(e=>this.requestRender(e)));const s={renderScene:(e,t,r,s)=>this.renderer.render(e,t,r,s),requestRenderScene:e=>this.requestRender(e),prepareOverlay:()=>e.options.screenshot.prepareOverlay(),renderOverlay:(t,r,s)=>e.options.screenshot.renderOverlay(t,r,s)};this._screenshotManager=new q(this._rctx,s,(e=>this.events.emit("force-camera-for-screenshot",e))),this._registerFrameTask(e)}normalizeCtorArgs(){return{}}destroy(){this._container.contains(this._canvas)&&this._container.removeChild(this._canvas),this._frameTask=i(this._frameTask),this._shaderTechniques=n(this._shaderTechniques),this._componentObjects=n(this._componentObjects),this._screenshotManager=n(this._screenshotManager),n(this.renderer),this._textures=n(this._textures),n(this._magnifierHelper),n(this.waterTextures),n(this.markerTextures),n(this.stippleTextures),this._canvas=null,this._container=null,this._rctx=n(this._rctx)}requestRender(e=_.UPDATE){this._needsRender=!0,e===_.UPDATE&&(this._needsUpdate=!0)}get updating(){return this._needsUpdate||this._needsWaterReflectionUpdate||this.renderer.updating||this._textures.updating||this.waterTextures.updating||this._magnifierHelper.updating}get textureRepository(){return this._textures}get compositingHelper(){return this._compositingHelper}set magnifier(e){this._magnifierHelper.magnifier=e}setIdleSuspend(e){this._idleSuspend!==e&&(this._idleSuspend=e,this.requestRender())}get renderingContext(){return this._rctx}get capabilities(){return this._rctx.capabilities}get canvas(){return this._canvas}takeScreenshot(e){return this._screenshotManager.takeScreenshot(e).then((e=>e[0]))}takeScreenshotWithOID(e){return e.objectAndLayerIdColor=!0,this._screenshotManager.takeScreenshot(e)}getAlpha(){return!!this._rctx.contextAttributes.alpha}getMinimalDepthForArea(e,t,r,s,i,n=i){const o=s.constrainWindowSize(t,r,i*s.pixelRatio,n*s.pixelRatio),a=this._ensureDepthBuffer(o);this.renderer.readDepthPixels(s,o,a);let h=Number.MAX_VALUE;for(let p=0;p<o[2]*o[3];p++){const e=g(4*p,a,s.nearFar);h>e&&e!==s.nearFar[0]&&e!==s.nearFar[1]&&(h=e)}if(e){const i=e.pickDepth(t*s.pixelRatio,r*s.pixelRatio,s);null!=i&&h>i&&i!==s.nearFar[0]&&i!==s.nearFar[1]&&(h=i)}return h===Number.MAX_VALUE?void 0:h}_ensureDepthBuffer(e){const t=4*e[2]*e[3];return(null==this._tmpDepthBuffer||this._tmpDepthBuffer.byteLength<t)&&(this._tmpDepthBuffer=new Uint8Array(t)),this._tmpDepthBuffer}async reloadShaders(){O(),await this._shaderTechniques.reloadAll(),this.requestRender()}_registerFrameTask(e){const t=e.view.state;let r=!1,s=_.BACKGROUND,i=!1;const n={preRender:({time:i})=>{r=this.updating,s=this._needsUpdate?_.UPDATE:_.BACKGROUND,e.commitSyncLayers();const n=d(i-this._lastAnimationUpdate);if(n>this.renderer.animationTimestep||null!=t.forcedAnimationTime||r||this._needsRender){const e=d(n/this.renderer.animationTimeDilation),r=new y(t.camera,e,t.forcedAnimationTime);this.renderer.updateAnimation(r)&&this.requestRender(_.BACKGROUND),this._lastAnimationUpdate=i}},render:({time:e})=>{if((this._needsRender||!this._idleSuspend||!this.renderer.isCameraFinal||this._needsWaterReflectionUpdate)&&t.camera.fullWidth>0&&t.camera.fullHeight>0){const r=this._needsUpdate&&this._idleSuspend&&this.renderer.isCameraFinal;this._needsRender=!1,this._needsUpdate=!1,this._needsWaterReflectionUpdate=!1,this.renderer.render(t,e),i=!0,r&&this.renderer.hasReflections&&(this.requestRender(_.BACKGROUND),this._needsWaterReflectionUpdate=!0)}},update:({time:e})=>{const r=this.renderer.hasSlicePlane||this._magnifierHelper.enabled||this.renderer.hasDecorations||this.renderer.hasHighlights,s=new L(t,r,this.renderer.fboCache);this._textures.update(),this._screenshotManager.update(s,e)},finish:()=>{i&&(this.renderer.finish(t.mode===H.IDLE?s:_.UPDATE),i=!1)}};this._frameTask=p(n)}_initializeContext(e){const t=e.options;this._canvas=t.canvas,this._canvas||(this._canvas=document.createElement("canvas")),this._canvas.setAttribute("style","width: 100%; height:100%; display:block;");const r={alpha:t.alpha||!1,premultipliedAlpha:!0,antialias:!1,depth:!0,stencil:t.stencil??!0,powerPreference:"high-performance",preserveDrawingBuffer:t.preserveDrawingBuffer??!1},i=S(this._canvas,r);null!=i?(this._rctx=M(i,e),this._loadShaderOnlyExtensions(),!t.alpha&&this._rctx.contextAttributes.alpha&&s.getLogger(this).error("WebGL context has alpha channel even though no alpha channel was requested"),!this._rctx.contextAttributes.alpha&&has("safari")>=11&&(this._container.style.backgroundColor="black"),this._container.appendChild(this._canvas)):s.getLogger(this).error("A WebGL2 context could not be created.")}_loadShaderOnlyExtensions(){this._rctx.capabilities.enable("textureFloat")}getObjectAndLayerIdColor(e){return null!=this.objectAndLayerIdRenderHelper?this.objectAndLayerIdRenderHelper.getObjectAndLayerIdColor(e):null}get componentObjectCollection(){return null==this._componentObjects&&(this._componentObjects=new m(this.renderer.renderPassManager,this._viewingMode)),this._componentObjects}set componentObjectCollection(e){this._componentObjects=e}};function M(e,t){const r={disabledExtensions:t.options.deactivatedWebGLExtensions||{},debugWebGLExtensions:t.options.debugWebGLExtensions||{},maxAnisotropy:8},s=(e,r)=>t.view.resourceController.memoryController.newCache(e,r);if(D.enabled){let t=E.get(e);return t?(t.configure(r),t.newCache=s,t.ref(),t):(t=new j(e,r,s),E.set(e,t),t.ref(),t)}return new j(e,r,s)}e([c({type:Boolean,readOnly:!0})],k.prototype,"updating",null),e([c()],k.prototype,"_rctx",void 0),e([c()],k.prototype,"_container",void 0),e([c()],k.prototype,"_canvas",void 0),e([c()],k.prototype,"stippleTextures",void 0),e([c()],k.prototype,"markerTextures",void 0),e([c()],k.prototype,"waterTextures",void 0),e([c()],k.prototype,"_magnifierHelper",void 0),e([c({readOnly:!0})],k.prototype,"objectAndLayerIdRenderHelper",void 0),e([c()],k.prototype,"_textures",void 0),e([c({readOnly:!0})],k.prototype,"renderer",void 0),e([c()],k.prototype,"_screenshotManager",void 0),e([c()],k.prototype,"componentObjectCollection",null),e([c()],k.prototype,"_componentObjects",void 0),e([c()],k.prototype,"_needsUpdate",void 0),e([c()],k.prototype,"_needsWaterReflectionUpdate",void 0),k=e([l("esri.views.3d.webgl-engine.parts.RenderView")],k);const E=U();export{k as RenderView};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{fromArray as e,fromValues as t,create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as r}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ViewingMode as s}from"../../../ViewingMode.js";import{ShaderOutput as o}from"../core/shaderLibrary/ShaderOutput.js";import{NormalType as a}from"../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{TextureCoordinateAttributeType as l}from"../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{VertexNormalPassParameters as n,VertexNormalDrawParameters as c}from"../core/shaderLibrary/attributes/VertexNormal.glsl.js";import{defaultMaskAlphaCutoff as h}from"../core/shaderLibrary/util/AlphaCutoff.js";import{ReloadableShaderModule as u}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as m}from"../core/shaderTechnique/ShaderTechnique.js";import{CullFaceOptions as p,DepthTestFunction as d,AlphaDiscardMode as f}from"../lib/basicInterfaces.js";import{Default3D as b}from"../lib/DefaultVertexAttributeLocations.js";import{RenderOccludedFlag as g}from"../lib/Material.js";import{blendingDefault as
|
|
5
|
+
import{fromArray as e,fromValues as t,create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as r}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ViewingMode as s}from"../../../ViewingMode.js";import{ShaderOutput as o}from"../core/shaderLibrary/ShaderOutput.js";import{NormalType as a}from"../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{TextureCoordinateAttributeType as l}from"../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{VertexNormalPassParameters as n,VertexNormalDrawParameters as c}from"../core/shaderLibrary/attributes/VertexNormal.glsl.js";import{defaultMaskAlphaCutoff as h}from"../core/shaderLibrary/util/AlphaCutoff.js";import{ReloadableShaderModule as u}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as m}from"../core/shaderTechnique/ShaderTechnique.js";import{CullFaceOptions as p,DepthTestFunction as d,AlphaDiscardMode as f}from"../lib/basicInterfaces.js";import{Default3D as b}from"../lib/DefaultVertexAttributeLocations.js";import{RenderOccludedFlag as g}from"../lib/Material.js";import{blendingDefault as y,oitBlending as x,oitDepthTest as T,getOITPolygonOffset as j}from"../lib/OrderIndependentTransparency.js";import{Program as P}from"../lib/Program.js";import{stencilWriteMaskOn as S,stencilToolMaskBaseParams as v,stencilBaseAllZerosParams as O}from"../lib/StencilUtils.js";import{TransparencyPassType as A}from"../lib/TransparencyPassType.js";import{defaultAdvancedMRRFactors as C}from"../materials/pbrUtils.js";import{D as L}from"../../../../chunks/DefaultMaterial.glsl.js";import{CompareFunction as M}from"../../../webgl/enums.js";import{makePipelineState as w,cullingParams as D,defaultDepthWriteParams as F,defaultColorWriteParams as N}from"../../../webgl/renderState.js";class _ extends n{constructor(){super(...arguments),this.isSchematic=!1,this.usePBR=!1,this.mrrFactors=e(C),this.hasVertexColors=!1,this.hasSymbolColors=!1,this.doubleSided=!1,this.doubleSidedType="normal",this.cullFace=p.Back,this.isInstanced=!1,this.hasInstancedColor=!1,this.emissiveFactor=t(0,0,0),this.instancedDoublePrecision=!1,this.normalType=a.Attribute,this.receiveShadows=!0,this.receiveAmbientOcclusion=!0,this.castShadows=!0,this.shadowMappingEnabled=!1,this.ambient=t(.2,.2,.2),this.diffuse=t(.8,.8,.8),this.externalColor=r(1,1,1,1),this.colorMixMode="multiply",this.opacity=1,this.layerOpacity=1,this.origin=i(),this.hasSlicePlane=!1,this.hasSliceHighlight=!0,this.offsetTransparentBackfaces=!1,this.vvSize=null,this.vvColor=null,this.vvOpacity=null,this.vvSymbolAnchor=null,this.vvSymbolRotationMatrix=null,this.modelTransformation=null,this.transparent=!1,this.writeDepth=!0,this.customDepthTest=d.Less,this.textureAlphaMode=f.Blend,this.textureAlphaCutoff=h,this.textureAlphaPremultiplied=!1,this.hasOccludees=!1,this.renderOccluded=g.Occlude,this.isDecoration=!1}}class k extends c{constructor(){super(...arguments),this.origin=i(),this.slicePlaneLocalOrigin=this.origin}}class q extends m{initializeConfiguration(e,t){t.spherical=e.viewingMode===s.Global,t.doublePrecisionRequiresObfuscation=e.rctx.driverTest.doublePrecisionRequiresObfuscation.result,t.textureCoordinateType=t.hasColorTexture||t.hasMetallicRoughnessTexture||t.hasEmissionTexture||t.hasOcclusionTexture||t.hasNormalTexture?l.Default:l.None,t.objectAndLayerIdColorInstanced=t.instanced}initializeProgram(e){return this._initializeProgram(e,q.shader)}_initializeProgram(e,t){return new P(e.rctx,t.get().build(this.configuration),b)}_makePipeline(e,t){const i=this.configuration,r=e===A.NONE,s=e===A.FrontFace;return w({blending:i.output!==o.Color&&i.output!==o.Alpha||!i.transparent?null:r?y:x(e),culling:I(i)?D(i.cullFace):null,depthTest:{func:T(e,z(i.customDepthTest))},depthWrite:(r||s)&&i.writeDepth?F:null,colorWrite:N,stencilWrite:i.hasOccludees?S:null,stencilTest:i.hasOccludees?t?v:O:null,polygonOffset:r||s?null:j(i.enableOffset)})}initializePipeline(){return this._occludeePipelineState=this._makePipeline(this.configuration.transparencyPassType,!0),this._makePipeline(this.configuration.transparencyPassType,!1)}getPipeline(e){return e?this._occludeePipelineState:super.getPipeline()}}function z(e){return e===d.Lequal?M.LEQUAL:M.LESS}function I(e){return e.cullFace!==p.None||!e.hasSlicePlane&&(!e.transparent&&!e.doubleSidedMode)}q.shader=new u(L,(()=>import("./DefaultMaterial.glsl.js")));export{k as DefaultMaterialDrawParameters,_ as DefaultMaterialPassParameters,q as DefaultMaterialTechnique};
|