@arcgis/core 4.25.0-next.20220718 → 4.25.0-next.20220721
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/Camera.js +1 -1
- package/analysis/DimensioningAnalysis.js +1 -1
- package/analysis/LineOfSightAnalysis.js +1 -1
- package/analysis/SliceAnalysis.js +1 -1
- package/arcade/featureset/support/RecentlyUsedCache.js +1 -1
- package/arcade/functions/featuresetgeom.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/1751de504354d98ac3fd.js +1 -0
- package/assets/esri/core/workers/chunks/1f4f1896880bfa6801c5.js +1 -0
- package/assets/esri/core/workers/chunks/290cd411d0d18b1d0efd.js +1 -0
- package/assets/esri/core/workers/chunks/{ab3bd5fecdb97f2d690e.js → 3b5be512567d9c1c6fe6.js} +1 -1
- package/assets/esri/core/workers/chunks/{c3236a7058e64ea3b939.js → 3c9da9b88777700879aa.js} +1 -1
- package/assets/esri/core/workers/chunks/{f96e8724ae3458f5e262.js → 4a7aa1b9de61eb013647.js} +1 -1
- package/assets/esri/core/workers/chunks/4cb64ccb5fba126f9a66.js +1 -0
- package/assets/esri/core/workers/chunks/{68f19e58aae01791944e.js → 579ba109718bc2554008.js} +1 -1
- package/assets/esri/core/workers/chunks/59845b02b07a8ed7ce81.js +1 -0
- package/assets/esri/core/workers/chunks/{c705f907ce60a646d9aa.js → 652d36523efbe5c9ebb2.js} +1 -1
- package/assets/esri/core/workers/chunks/888d8e4471c9a2cd5009.js +1 -0
- package/assets/esri/core/workers/chunks/9493a8e5d6001b6bf275.js +1 -0
- package/assets/esri/core/workers/chunks/9d824cdfbcdf3cb3246f.js +1 -0
- package/assets/esri/core/workers/chunks/bf348f6f52701fa6016e.js +987 -0
- package/assets/esri/core/workers/chunks/d02881954c0cc0d39dfb.js +1 -0
- package/assets/esri/core/workers/chunks/{1ecbf642debc2207b762.js → da54483123f377e9b3e1.js} +1 -1
- package/assets/esri/core/workers/chunks/{61b71b8e028eda10ccab.js → e4ad2cf5d6bded02e392.js} +1 -1
- package/assets/esri/core/workers/chunks/{3bfab05ae07ac18a75fe.js → f298a70f3b6f27675d53.js} +1 -1
- package/assets/esri/core/workers/chunks/{d499cce61c1c5c367380.js → f40290cfad3fe6fb4ef9.js} +1 -1
- package/assets/esri/layers/support/rasterFormats/lerc-wasm.wasm +0 -0
- package/assets/esri/themes/base/widgets/_Tooltip.scss +1 -1
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/ComponentShader.glsl.js +39 -33
- package/chunks/Laserlines.glsl.js +4 -4
- package/chunks/Precipitation.glsl.js +2 -2
- package/chunks/RibbonLine.glsl.js +46 -44
- package/chunks/Stars.glsl.js +2 -2
- package/chunks/Terrain.glsl.js +25 -17
- package/chunks/boundedPlane.js +1 -1
- package/chunks/lerc-wasm.js +1 -1
- package/chunks/mat2d.js +1 -1
- package/chunks/quatf32.js +1 -1
- package/core/BidiEngine.js +1 -1
- package/core/accessorSupport/watch.js +1 -1
- package/core/libs/gl-matrix-2/factories/quatf32.js +1 -1
- package/core/libs/gl-matrix-2/math/mat2d.js +1 -1
- package/core/perspectiveUtils.js +1 -1
- package/core/promiseUtils.js +1 -1
- package/core/reactiveUtils.js +1 -1
- package/core/unitUtils.js +1 -1
- package/geometry/projection.js +1 -1
- package/geometry/projectionEllipsoid.js +1 -1
- package/geometry/support/MeshTexture.js +1 -1
- package/geometry/support/axisAngleDegrees.js +1 -1
- package/geometry/support/coordinateSystem.js +1 -1
- package/geometry/support/geodesicUtils.js +1 -1
- package/geometry/support/meshUtils/exporters/gltf/index.js +1 -1
- package/geometry/support/meshUtils/loadExternal.js +1 -1
- package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
- package/geometry/support/scaleUtils.js +1 -1
- package/geometry/support/spatialReferenceUtils.js +1 -1
- package/identity/IdentityManagerBase.js +1 -1
- package/identity/IdentityModal.js +1 -1
- package/interfaces.d.ts +3 -33
- package/layers/FeatureLayer.js +1 -1
- package/layers/effects/parser.js +1 -1
- package/layers/graphics/hydratedFeatures.js +1 -1
- package/layers/graphics/sources/support/sourceUtils.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/ogc/wfsUtils.js +1 -1
- package/layers/support/ContingentValue.js +1 -1
- package/layers/support/ElevationQuery.js +1 -1
- package/layers/support/PixelBlock.js +1 -1
- package/layers/support/kmlUtils.js +1 -1
- package/layers/support/rasterDatasets/CloudRaster.js +1 -1
- package/layers/support/rasterDatasets/EphemeralBlockCache.js +1 -1
- package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
- package/layers/support/rasterDatasets/multipartParser.js +1 -1
- package/layers/support/rasterFormats/ImageCanvasDecoder.js +1 -1
- package/layers/support/rasterFormats/JpgPlus.js +1 -1
- package/layers/support/rasterFormats/Lerc.js +1 -1
- package/layers/support/rasterFormats/RasterCodec.js +1 -1
- package/layers/support/rasterFormats/Raw.js +1 -1
- package/layers/support/rasterFormats/TiffTags.js +1 -1
- package/layers/support/rasterFunctions/vectorFieldUtils.js +1 -1
- package/layers/support/vectorTileLayerLoader.js +1 -1
- package/layers/support/wmtsUtils.js +1 -1
- package/package.json +1 -1
- package/renderers/RasterShadedReliefRenderer.js +1 -1
- package/renderers/RasterStretchRenderer.js +1 -1
- package/renderers/UniqueValueRenderer.js +1 -1
- package/renderers/support/AuthoringInfo.js +1 -1
- package/renderers/support/RasterSymbolizer.js +1 -1
- package/rest/query/operations/query.js +1 -1
- package/rest/query/operations/queryTopFeatures.js +1 -1
- package/rest/support/DirectionsFeatureSet.js +1 -1
- package/rest/support/ImageHistogramParameters.js +1 -1
- package/rest/support/ImageSampleParameters.js +1 -1
- package/smartMapping/labels/clusters.js +1 -1
- package/smartMapping/renderers/relationship.js +1 -1
- package/smartMapping/support/adapters/support/utils.js +1 -1
- package/support/basemapUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/LabelSymbol3D.js +1 -1
- package/symbols/PointSymbol3D.js +1 -1
- package/symbols/cim/CIMCursor.js +1 -1
- package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
- package/symbols/cim/CIMSymbolRasterizer.js +1 -1
- package/symbols/support/previewSymbol3D.js +1 -1
- package/symbols/support/webStyleSymbolUtils.js +1 -1
- package/views/2d/ViewState.js +1 -1
- package/views/2d/engine/vectorTiles/Feature.js +1 -1
- package/views/2d/engine/vectorTiles/style/StyleRepository.js +1 -1
- package/views/2d/engine/webgl/SDFConverter.js +1 -1
- package/views/2d/engine/webgl/TurboLine.js +1 -1
- package/views/2d/engine/webgl/brushes/BrushClip.js +1 -1
- package/views/2d/engine/webgl/brushes/BrushOverlay.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLGeometryBrushLabel.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLGeometryBrushLine.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLGeometryBrushText.js +1 -1
- package/views/2d/engine/webgl/collisions/MetricReader.js +1 -1
- package/views/2d/engine/webgl/cpuMapped/DisplayRecordReader.js +1 -1
- package/views/2d/engine/webgl/cpuMapped/FreeList.js +1 -1
- package/views/2d/engine/webgl/mesh/heuristics.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/WGLDynamicFillTemplate.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/WGLDynamicLineTemplate.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/WGLDynamicMarkerTemplate.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/WGLDynamicTextTemplate.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/WGLFillTemplate.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/WGLLineTemplate.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/WGLMarkerTemplate.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/input/MapViewInputManager.js +1 -1
- package/views/2d/layers/features/createSymbolSchema.js +1 -1
- package/views/2d/viewpointUtils.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightIntersectionResult.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightVisualization.js +1 -1
- package/views/3d/analysis/LineOfSightAnalysisView3D.js +1 -1
- package/views/3d/analysis/Slice/SliceTool.js +1 -1
- package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
- package/views/3d/camera/constraintUtils/distance.js +1 -1
- package/views/3d/environment/ChapmanAtmosphereTechniqueConfiguration.js +1 -1
- package/views/3d/environment/CloudsComposition.js +1 -1
- package/views/3d/environment/FogTechnique.js +1 -1
- package/views/3d/glTF/internal/Resource.js +1 -1
- package/views/3d/input/SceneInputManager.js +1 -1
- package/views/3d/interactive/editingTools/dragEventPipeline3D.js +1 -1
- package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
- package/views/3d/interactive/editingTools/reshapeGraphic/edgeOffsetUtils.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/GraphicScaleRotateTransform.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/GraphicTransformTool.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/ScaleRotateObjectSymbol3DAdapter.js +1 -1
- package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
- package/views/3d/layers/FeatureLayerViewBase3D.js +1 -1
- package/views/3d/layers/GraphicsLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/lineUtils.js +1 -1
- package/views/3d/layers/i3s/I3SGeometryUtil.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/IDBCache.js +1 -1
- package/views/3d/layers/i3s/IDBMockCache.js +1 -1
- package/views/3d/layers/i3s/PointRenderer.js +1 -1
- package/views/3d/layers/support/featureTileQuery3D.js +1 -1
- package/views/3d/state/ViewState.js +1 -1
- package/views/3d/support/cameraUtils.js +1 -1
- package/views/3d/support/orientedBoundingBox.js +1 -1
- package/views/3d/support/viewpointUtils.js +1 -1
- package/views/3d/terrain/Overlay.js +1 -1
- package/views/3d/terrain/OverlayRenderTarget.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/TilingSchemeLogic.js +1 -1
- package/views/3d/terrain/interfaces.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
- package/views/3d/webgl-engine/collections/Component/DepthRange.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentShader.glsl.js +1 -1
- package/views/3d/webgl-engine/collections/Component/RenderGeometry.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/AllRenderPasses.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/ObjectAndLayerIdColor.glsl.js +9 -0
- package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +18 -17
- package/views/3d/webgl-engine/lib/DefaultVertexAttributeLocations.js +1 -1
- package/views/3d/webgl-engine/lib/Geometry.js +1 -1
- package/views/3d/webgl-engine/lib/Intersector.js +1 -1
- package/views/3d/webgl-engine/lib/ObjectAndLayerIdRenderHelper.js +5 -0
- package/views/3d/webgl-engine/lib/Octree.js +1 -1
- package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
- package/views/3d/webgl-engine/lib/PathGeometry.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/TextureTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/lib/VertexAttribute.js +1 -1
- package/views/3d/webgl-engine/lib/geometryDataUtils.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/lodRendering/RenderInstanceData.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/internal/bufferWriterUtils.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterialTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/shaders/LaserlinePathTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLine.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/RibbonLineTechniqueConfiguration.js +1 -1
- package/views/DOMContainer.js +1 -1
- package/views/MapView.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/View.js +1 -1
- package/views/analysis/analysisViewUtils.js +1 -1
- package/views/animation/pointToPoint/apex/planning.js +1 -1
- package/views/draw/PolygonDrawAction.js +1 -1
- package/views/draw/PolylineDrawAction.js +1 -1
- package/views/draw/support/createUtils.js +1 -1
- package/views/draw/support/surfaceCoordinateSystems.js +1 -1
- package/views/input/InputManager.js +1 -1
- package/views/input/handlers/LatestPointer.js +1 -1
- package/views/input/handlers/MultiTouch.js +5 -0
- package/views/interactive/editGeometry/operations/OffsetEdgeVertex.js +1 -1
- package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTileCache.js +1 -1
- package/views/interactive/tooltip/Tooltip.js +1 -1
- package/views/interactive/tooltip/support/measurements.js +1 -1
- package/views/layers/GroupLayerView.js +1 -1
- package/views/navigation/FilteredFiniteDifference.js +1 -1
- package/views/navigation/MomentumEstimator.js +1 -1
- package/views/navigation/PanPlanarMomentumEstimator.js +1 -1
- package/views/navigation/PanSphericalMomentumEstimator.js +1 -1
- package/views/navigation/RotationMomentumEstimator.js +1 -1
- package/views/support/GroundViewElevationSampler.js +1 -1
- package/views/support/euclideanAreaMeasurementUtils.js +1 -1
- package/views/support/euclideanLengthMeasurementUtils.js +1 -1
- package/views/support/screenshotUtils.js +1 -1
- package/views/webgl/BufferObject.js +1 -1
- package/views/webgl/FramebufferObject.js +1 -1
- package/views/webgl/Texture.js +1 -1
- package/views/webgl/capabilities/Capabilities.js +1 -1
- package/views/webgl/capabilities.js +1 -1
- package/views/webgl/renderState.js +1 -1
- package/webscene/spec-certification/api.js +1 -1
- package/widgets/CoordinateConversion/support/formatUtils.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileController.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileLineInput.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileLineView.js +1 -1
- package/widgets/ElevationProfile/support/chartUtils.js +1 -1
- package/widgets/ElevationProfile/support/geometryUtils.js +1 -1
- package/widgets/Expand.js +1 -1
- package/widgets/Legend/support/sizeRampUtils.js +1 -1
- package/widgets/LineOfSight/LineOfSightViewModel.js +1 -1
- package/widgets/Popup/PopupViewModel.js +1 -1
- package/widgets/Popup/actionUtils.js +1 -1
- package/widgets/ScaleRangeSlider.js +1 -1
- package/widgets/Slider/SliderViewModel.js +1 -1
- package/widgets/Widget.js +1 -1
- package/assets/esri/core/workers/chunks/04ea469cb081e181ca82.js +0 -1
- package/assets/esri/core/workers/chunks/16c2626ca47132700519.js +0 -1
- package/assets/esri/core/workers/chunks/1e4e5d147263e98536bc.js +0 -1
- package/assets/esri/core/workers/chunks/35083def3c658d1ae9ff.js +0 -1
- package/assets/esri/core/workers/chunks/40032d2bf404a46b8f80.js +0 -1
- package/assets/esri/core/workers/chunks/613e82a3e13442685ac4.js +0 -1
- package/assets/esri/core/workers/chunks/64b4f1dbf61439cde801.js +0 -1
- package/assets/esri/core/workers/chunks/abd68b7ba3be4696611c.js +0 -1
- package/assets/esri/core/workers/chunks/b8a062c0c9c626acf61e.js +0 -982
- package/assets/esri/core/workers/chunks/e08686088be0aaca1a99.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import{isSome as t,get as s,none as r,isNone as a,unwrapOr as i}from"../../../../core/maybe.js";import{pt2px as o}from"../../../../core/screenUtils.js";import{c as n,i as c,l,h}from"../../../../chunks/mat4.js";import{c as d}from"../../../../chunks/mat4f64.js";import{l as p,o as m,c as u,E as y,a as f,s as _}from"../../../../chunks/vec3.js";import{d as b,O as g,Z as P,f as R,c as v}from"../../../../chunks/vec3f64.js";import{O as x,c as S}from"../../../../chunks/vec4f64.js";import{projectPointToVector as L,computeTranslationToOriginAndRotation as C}from"../../../../geometry/projection.js";import{create as w,size as E,containsPoint as U,center as j}from"../../../../geometry/support/aaBoundingBox.js";import{defaultPrimitive as B}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as T,objectSymbolLayerSizeWithResourceSize as G}from"../../../../symbols/support/symbolLayerUtils3D.js";import{perLodInstanceElevationAligner as O}from"./ElevationAligners.js";import{needsElevationUpdates3D as D,evaluateElevationInfoAtPoint as I,SampleElevationInfo as z}from"./elevationAlignmentUtils.js";import{ElevationContext as M}from"./ElevationContext.js";import A from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as F}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as V,mixinColorAndOpacity as k,computeObjectScale as W,computeObjectRotation as H}from"./graphicUtils.js";import{ApplyRendererDiffResult as q}from"./interfaces.js";import{LoadStatus as N}from"./Loadable.js";import{makeLodResources as $,fillEstimatedMinScreenSpaceRadius as Z}from"./lodResourceUtils.js";import{fetch as J}from"./objectResourceUtils.js";import{placePointOnGeometry as K,extendPointGraphicElevationContext as Q}from"./pointUtils.js";import{isValidPrimitive as X,primitiveLodResources as Y}from"./primitiveObjectSymbolUtils.js";import{defaultSymbolLayerMemoryComplexity as ee}from"./symbolComplexity.js";import{initFastSymbolUpdatesState as te,updateFastSymbolUpdatesState as se,evaluateModelTransform as re,evaluateModelTransformScale as ae}from"../support/FastSymbolUpdates.js";import{CullFaceOptions as ie}from"../../webgl-engine/lib/basicInterfaces.js";import{VertexAttribute as oe}from"../../webgl-engine/lib/VertexAttribute.js";import{LodRenderer as ne}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{materialsFromLodResources as ce,texturesFromLodResources as le,geometriesFromLodResources as he,geometriesFromLodLevelResources as de}from"../../webgl-engine/lib/lodRendering/LodResources.js";import{DefaultMaterial as pe}from"../../webgl-engine/materials/DefaultMaterial.js";class me extends F{constructor(e,t,s,r){super(e,t,s,r),this._resources=null,this._optionalFields=new Array,this._instanceIndexToGraphicUid=new Map,this._hasLoadedPBRTextures=!1,this._disposeResourceHandles=new Array,this.ensureDrapedStatus(!1),this._hasLoadedPBRTextures=s.physicalBasedRenderingEnabled}getCachedSize(){const[e,s,r]=t(this._resources)?this._resources.symbolSize:[1,1,1];return{width:e,depth:s,height:r}}async doLoad(e){if(!this._drivenProperties.size){if(V(this.symbolLayer))throw new Error}const t=this.symbolLayer;if(this._isPrimitive){const s=t.resource?t.resource.primitive:B;this._resources=await this._createResourcesForPrimitive(s,e)}else this._resources=await this._createResourcesForUrl(t.resource.href,e);this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicalBasedRenderingChanged(),this.complexity=this.computeComplexity()}get extentPadding(){return t(this._resources)?this._resources.extentPadding:0}get _isPrimitive(){return!(this.symbolLayer.resource&&this.symbolLayer.resource.href)}get lodRenderer(){return s(this._resources,"lodRenderer")}_setMaterialTransparencyParams(e,t=s(this.symbolLayer,"material","color")){const r=this._getCombinedOpacity(t),a=r<1||this.needsDrivenTransparentPass;return e.transparent=a,e.opacity=r,e.cullFace=a?ie.None:ie.Back,e}async _createResourcesForPrimitive(s,a){if(!X(s))throw new Error(`Unknown object symbol primitive: ${s}`);const i=this.symbolLayer,n=w(T(s)),c=b(E(n)),l=b(G(c,i)),h=p(l),d=!1,m=!1,u={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,ambient:g,diffuse:g,hasSlicePlane:this._context.slicePlaneEnabled,hasSliceHighlight:!1,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!this.symbolLayer.isPrimitive},y=u.usePBR;this._setMaterialTransparencyParams(u);const f=this.symbol;if("point-3d"===f.type&&f.verticalOffset){const{screenLength:e,minWorldLength:s,maxWorldLength:r}=f.verticalOffset;u.verticalOffset={screenLength:o(e),minWorldLength:s||0,maxWorldLength:t(r)?r:1/0},u.castShadows=!1}if(this._context.screenSizePerspectiveEnabled&&(u.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),this._drivenProperties.color)u.externalColor=x;else{const s=t(i.material)&&i.material.color,r=t(s)?e.toUnitRGBA(s):x;u.externalColor=r}this._fastUpdates=te(this._context.renderer,this._fastVisualVariableConvertOptions(n,l,c,r)),u.instanced=["transformation"],this._fastUpdates.enabled?(Object.assign(u,this._fastUpdates.materialParameters),u.instanced.push("featureAttribute"),this._optionalFields.push("featureAttribute")):this._hasPerInstanceColor()&&(u.instanced.push("color"),this._optionalFields.push("color"));const _=new pe(u),P=Y(s,_);if(!P)throw new Error(`Unknown object symbol primitive: ${s}`);const R=ce(P).map((e=>({opacity:1,transparent:e.parameters.transparent}))),v=await this._createStageResources(P,y);return{lodResources:P,lodRenderer:await this._createLodRenderer(P,a),stageResources:v,symbolSize:l,extentPadding:h,isEsriSymbolResource:d,isWosr:m,originalMaterialParameters:R,physicalBasedRenderingEnabled:y,resourceBoundingBox:n,resourceSize:c,pivotOffset:r}}async _createResourcesForUrl(e,a){const i=["transformation"],n={materialParamsMixin:{instanced:i,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},streamDataRequester:this._context.streamDataRequester,cache:this._context.sharedResources.objectResourceCache};this._fastUpdates=te(this._context.renderer,this._fastVisualVariableConvertOptions(r,r,r,r)),this._fastUpdates.enabled?(Object.assign(n.materialParamsMixin,this._fastUpdates.materialParameters),i.push("featureAttribute"),this._optionalFields.push("featureAttribute")):this._hasPerInstanceColor()&&(i.push("color"),this._optionalFields.push("color"));const c=this.symbol;if("point-3d"===c.type&&c.verticalOffset){const{screenLength:e,minWorldLength:s,maxWorldLength:r}=c.verticalOffset;n.materialParamsMixin.verticalOffset={screenLength:o(e),minWorldLength:s||0,maxWorldLength:t(r)?r:1/0},n.materialParamsMixin.castShadows=!1}n.signal=a,n.usePBR=this._context.physicalBasedRenderingEnabled;const l=n.usePBR,h=await J(e,n),d=h.isEsriSymbolResource,m=h.isWosr;this._addDisposeResource((()=>h.remove()));const u=$(h.lods);Z(u),u.levels.sort(((e,t)=>e.minScreenSpaceRadius-t.minScreenSpaceRadius)),u.levels[0].minScreenSpaceRadius=Math.min(2,u.levels[0].minScreenSpaceRadius);const y=this._context,f=this.symbolLayer.material,_=this._getExternalColorParameters(f),g=s(this.symbolLayer,"material","color"),P=this._getCombinedOpacity(g,{hasIntrinsicColor:!0}),R=this.needsDrivenTransparentPass,v=ce(u),x=ce(u).map((e=>({opacity:e.parameters.opacity||1,transparent:e.parameters.transparent})));v.forEach((e=>{const t=e.parameters;e.setParameters(_);const s=t.opacity*P,r=s<1||R||t.transparent;e.setParameters({opacity:s,transparent:r}),y.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:y.sharedResources.screenSizePerspectiveSettings})}));const S=h.referenceBoundingBox,L=b(E(S)),C=b(u.levels[0].pivotOffset),w=b(G(L,this.symbolLayer)),U=p(w);se(this._fastUpdates,this._context.renderer,this._fastVisualVariableConvertOptions(S,w,L,C))&&v.forEach((e=>e.setParameters(this._fastUpdates.materialParameters)));const j=await this._createStageResources(u,l);return{lodResources:u,lodRenderer:await this._createLodRenderer(u,a),stageResources:j,symbolSize:w,extentPadding:U,isEsriSymbolResource:d,isWosr:m,originalMaterialParameters:x,physicalBasedRenderingEnabled:l,resourceBoundingBox:S,resourceSize:L,pivotOffset:C}}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(e,t){const s=this._context.stage,r=ce(e);t!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged(),s.addMany(r),this._addDisposeResource((()=>s.removeMany(r)));const a=le(e);s.addMany(a),this._addDisposeResource((()=>s.removeMany(a))),await s.load(a);const i=he(e);return s.addMany(i),this._addDisposeResource((()=>s.removeMany(i))),{materials:r,textures:a,geometries:i}}async _createLodRenderer(e,t){const s=this._context.stage,r={layerUid:this._context.layer.uid,graphicUid:e=>this._instanceIndexToGraphicUid.get(e),notifyGraphicGeometryChanged:e=>this._context.notifyGraphicGeometryChanged(this._instanceIndexToGraphicUid.get(e)),notifyGraphicVisibilityChanged:e=>this._context.notifyGraphicVisibilityChanged(this._instanceIndexToGraphicUid.get(e))},a=this._fastUpdates.enabled?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,_e),n(s,re(this._fastUpdates.materialParameters,_e,s))},scaleFactor:(e,t,s)=>(t.getFeatureAttribute(s,_e),ae(e,this._fastUpdates.materialParameters,_e))}:null,i=new ne(e,this._optionalFields,r,a);return i.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource((()=>{s.removeRenderPlugin(i)})),await s.addRenderPlugin(i.slots,i,t),i}_getExternalColorParameters(s){const r={};return this._drivenProperties.color?r.externalColor=x:t(s)&&t(s.color)?r.externalColor=e.toUnitRGBA(s.color):(r.externalColor=x,r.colorMixMode="ignore"),r}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach((e=>e())),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const s=K(t.geometry);if(a(s))return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const r=this.setGraphicElevationContext(t,new M),i=e.renderingInfo;return this._createAs3DShape(t,s,i,r,t.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(a(this._resources))return!0;const e=this._drivenProperties.opacity,t=!this._isPrimitive,r=this._resources.stageResources.materials,i=this._resources.originalMaterialParameters;for(let a=0;a<r.length;a++){const o=r[a],n=s(this.symbolLayer,"material","color"),c=i[a],l=this._getCombinedOpacity(n,{hasIntrinsicColor:t})*c.opacity,h=l<1||e||c.transparent;o.setParameters({opacity:l,transparent:h}),this._isPrimitive&&o.setParameters({cullFace:h?ie.None:ie.Back})}return!0}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,D)}slicePlaneEnabledChanged(){if(a(this._resources))return!0;this._resources.lodRenderer.slicePlaneEnabled=this._context.slicePlaneEnabled;for(const e of this._resources.stageResources.materials)e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled});return!0}physicalBasedRenderingChanged(){if(a(this._resources))return!0;const{stageResources:e,isWosr:t}=this._resources;for(const s of e.materials)this._isPrimitive?s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}):t||s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!1});return!1!==this._hasLoadedPBRTextures||!0!==this._context.physicalBasedRenderingEnabled||(this._hasLoadedPBRTextures=!0,!1)}pixelRatioChanged(){return!0}applyRendererDiff(e,t){if(a(this._resources))return q.Recreate_Symbol;const{stageResources:{materials:s},lodRenderer:r,resourceBoundingBox:i,symbolSize:o,resourceSize:n,pivotOffset:c}=this._resources;for(const a in e.diff){if("visualVariables"!==a)return q.Recreate_Symbol;if(!se(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,o,n,c)))return q.Recreate_Symbol;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return q.Fast_Update}computeComplexity(){if(a(this._resources))return super.computeComplexity();return{primitivesPerFeature:de(this._resources.lodResources.levels[0]).reduce(((e,t)=>e+t.indices.get(oe.POSITION).length),0)/3,primitivesPerCoordinate:0,drawCallsPerFeature:0,estimated:!1,memory:ee(this.symbol,this.symbolLayer)}}_hasLodRenderer(){return t(this._resources)}_createAs3DShape(e,s,r,i,o){if(!this._hasLodRenderer()||a(this._resources))return null;const n=this.getFastUpdateAttrValues(e),c=!this._fastUpdates.enabled&&this._hasPerInstanceColor()?k(r.color,r.opacity):null,l=this._context.clippingExtent;if(L(s,ue,this._context.elevationProvider.spatialReference),t(l)&&!U(l,ue))return null;const h=this._requiresTerrainElevation(i),d=this._computeGlobalTransform(s,i,fe,be),p=this._computeLocalTransform(this._resources,this.symbolLayer,r,ye),m=this._resources.lodRenderer.instanceData,u=m.addInstance();this._instanceIndexToGraphicUid.set(u,o),m.setLocalTransform(u,p,!1),m.setGlobalTransform(u,d),n&&m.setFeatureAttribute(u,n),c&&m.setColor(u,c);const y=new A(this,u,O,i);return h&&(y.alignedSampledElevation=be.sampledElevation),y.needsElevationUpdates=D(i.mode),Q(y,s,this._context.elevationProvider),y}_computeGlobalTransform(e,t,s,r){return I(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),ue[0]=e.x,ue[1]=e.y,ue[2]=r.z,C(e.spatialReference,ue,s,this._context.renderCoordsHelper.spatialReference),s}_computeLocalTransform(e,t,s,r){return c(r),this._applyObjectRotation(s,!1,r),this._applyObjectRotation(t,!0,r),this._applyObjectScale(e,s,r),this._applyAnchor(e,t,r),r}_applyObjectScale(e,t,s){if(this._fastUpdates.enabled&&this._fastUpdates.requiresShaderTransformation)return;const r=this._drivenProperties.size&&t.size?t.size:e.symbolSize,a=W(r,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);1===a[0]&&1===a[1]&&1===a[2]||l(s,s,a)}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchTransform(e,t),this._preparePatchColor(e,t)}updateGeometry(e,t){if(a(this._resources))return!0;const s=t&&K(t);if(a(s))return!1;const r=this.getGeometryElevationMode(t);return e.elevationContext.mode===r&&(this._computeGlobalTransform(s,e.elevationContext,fe,be),this._requiresTerrainElevation(e.elevationContext)&&(e.alignedSampledElevation=be.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(e.instanceIndex,fe,!0),Q(e,s,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!(t.heading||t.tilt||t.roll||t.width||t.height||t.depth||t.anchor||t.anchorPosition))return;if(a(this._resources))return;const s=(e,t,s)=>i(null!=e&&"complete"===e.type?e.newValue:t,s),r=s(t.heading,this.symbolLayer.heading,0),o=s(t.tilt,this.symbolLayer.tilt,0),n=s(t.roll,this.symbolLayer.roll,0),c=s(t.width,this.symbolLayer.width,void 0),l=s(t.height,this.symbolLayer.height,void 0),h=s(t.depth,this.symbolLayer.depth,void 0),d=s(t.anchor,this.symbolLayer.anchor,void 0),p=s(t.anchorPosition,this.symbolLayer.anchorPosition,void 0);delete t.heading,delete t.tilt,delete t.roll,delete t.width,delete t.height,delete t.depth,delete t.anchor,delete t.anchorPosition;const m={heading:r,tilt:o,roll:n,anchor:d,anchorPosition:p},u=this._resources;this.loadStatus===N.LOADED&&e.symbolLayerStatePatches.push((()=>{u.symbolSize=b(G(u.resourceSize,{width:c,height:l,depth:h,isPrimitive:this.symbolLayer.isPrimitive}))})),e.graphics3DGraphicPatches.push(((e,t)=>{const s=this._computeLocalTransform(u,m,t,ye),r=e.instanceIndex;u.lodRenderer.instanceData.setLocalTransform(r,s,!0)}))}_preparePatchColor(s,r){if(!r.material||"partial"!==r.material.type)return;const i=r.material.diff;if(!i.color||"complete"!==i.color.type||null==i.color.newValue||null==i.color.oldValue)return;const o=i.color.newValue,n=t(o)?e.toUnitRGBA(o):x;delete i.color;const c=this._resources;a(c)||s.graphics3DGraphicPatches.push((e=>{let t;this._hasPerInstanceColor()?(c.lodRenderer.instanceData.setColor(e.instanceIndex,n),t=this._setMaterialTransparencyParams({},o)):t=this._setMaterialTransparencyParams({externalColor:n},o);for(const s of c.stageResources.materials)s.setParameters(t)}))}_requiresTerrainElevation(e){return"absolute-height"!==e.mode}_applyObjectRotation(e,t,s){if(!(this._fastUpdates.enabled&&this._fastUpdates.requiresShaderTransformation&&t))return H(e.heading,e.tilt,e.roll,s)}_computeAnchor(e,s,r){const a=v();switch(r.anchor){case"center":u(a,j(e)),m(a,a);break;case"top":{const t=j(e);_(a,-t[0],-t[1],-e[5]);break}case"bottom":{const t=j(e);_(a,-t[0],-t[1],-e[2]);break}case"relative":{const t=j(e),s=E(e),i=r.anchorPosition,o=i?R(i.x,i.y,i.z):P;y(a,s,o),f(a,a,t),m(a,a);break}default:t(s)?m(a,s):u(a,P)}return a}_applyAnchor(e,t,s){if(this._fastUpdates.enabled&&this._fastUpdates.requiresShaderTransformation)return;const r=this._computeAnchor(e.resourceBoundingBox,e.pivotOffset,t);r&&h(s,s,r)}_hasPerInstanceColor(){return this._drivenProperties.color||this._drivenProperties.opacity}_fastVisualVariableConvertOptions(e,s,r,a){const i=t(e)?b(E(e)):g,o=t(e)?this._computeAnchor(e,a,this.symbolLayer):P,n=this._context.renderCoordsHelper.unitInMeters,c=W(t(s)?s:void 0,s,r,n),l=R(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return{modelSize:i,symbolSize:t(s)?s:g,unitInMeters:n,transformation:{anchor:o,scale:c,rotation:l}}}}const ue=v(),ye=d(),fe=d(),_e=S(),be=new z;export{me as Graphics3DObjectSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import has from"../../../../core/has.js";import{isSome as t,get as s,none as r,isNone as a,unwrapOr as i}from"../../../../core/maybe.js";import{pt2px as o}from"../../../../core/screenUtils.js";import{c as n,i as c,l,h}from"../../../../chunks/mat4.js";import{c as d}from"../../../../chunks/mat4f64.js";import{l as p,o as m,c as u,E as y,a as f,s as _}from"../../../../chunks/vec3.js";import{d as b,O as g,Z as P,f as R,c as v}from"../../../../chunks/vec3f64.js";import{O as x,c as L}from"../../../../chunks/vec4f64.js";import{projectPointToVector as S,computeTranslationToOriginAndRotation as C}from"../../../../geometry/projection.js";import{create as j,size as w,containsPoint as U,center as E}from"../../../../geometry/support/aaBoundingBox.js";import{defaultPrimitive as B}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as I,objectSymbolLayerSizeWithResourceSize as T}from"../../../../symbols/support/symbolLayerUtils3D.js";import{perLodInstanceElevationAligner as O}from"./ElevationAligners.js";import{needsElevationUpdates3D as G,evaluateElevationInfoAtPoint as A,SampleElevationInfo as D}from"./elevationAlignmentUtils.js";import{ElevationContext as z}from"./ElevationContext.js";import M from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as F}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as V,mixinColorAndOpacity as k,computeObjectScale as W,computeObjectRotation as H}from"./graphicUtils.js";import{ApplyRendererDiffResult as q}from"./interfaces.js";import{LoadStatus as N}from"./Loadable.js";import{makeLodResources as $,fillEstimatedMinScreenSpaceRadius as Z}from"./lodResourceUtils.js";import{fetch as J}from"./objectResourceUtils.js";import{placePointOnGeometry as K,extendPointGraphicElevationContext as Q}from"./pointUtils.js";import{isValidPrimitive as X,primitiveLodResources as Y}from"./primitiveObjectSymbolUtils.js";import{defaultSymbolLayerMemoryComplexity as ee}from"./symbolComplexity.js";import{initFastSymbolUpdatesState as te,updateFastSymbolUpdatesState as se,evaluateModelTransform as re,evaluateModelTransformScale as ae}from"../support/FastSymbolUpdates.js";import{CullFaceOptions as ie}from"../../webgl-engine/lib/basicInterfaces.js";import{VertexAttribute as oe}from"../../webgl-engine/lib/VertexAttribute.js";import{LodRenderer as ne}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{materialsFromLodResources as ce,texturesFromLodResources as le,geometriesFromLodResources as he,geometriesFromLodLevelResources as de}from"../../webgl-engine/lib/lodRendering/LodResources.js";import{DefaultMaterial as pe}from"../../webgl-engine/materials/DefaultMaterial.js";class me extends F{constructor(e,t,s,r){super(e,t,s,r),this._resources=null,this._optionalFields=new Array,this._instanceIndexToGraphicUid=new Map,this._hasLoadedPBRTextures=!1,this._disposeResourceHandles=new Array,this.ensureDrapedStatus(!1),this._hasLoadedPBRTextures=s.physicalBasedRenderingEnabled}getCachedSize(){const[e,s,r]=t(this._resources)?this._resources.symbolSize:[1,1,1];return{width:e,depth:s,height:r}}async doLoad(e){if(!this._drivenProperties.size){if(V(this.symbolLayer))throw new Error}const t=this.symbolLayer;if(this._isPrimitive){const s=t.resource?t.resource.primitive:B;this._resources=await this._createResourcesForPrimitive(s,e)}else this._resources=await this._createResourcesForUrl(t.resource.href,e);this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicalBasedRenderingChanged(),this.complexity=this.computeComplexity()}get extentPadding(){return t(this._resources)?this._resources.extentPadding:0}get _isPrimitive(){return!(this.symbolLayer.resource&&this.symbolLayer.resource.href)}get lodRenderer(){return s(this._resources,"lodRenderer")}_setMaterialTransparencyParams(e,t=s(this.symbolLayer,"material","color")){const r=this._getCombinedOpacity(t),a=r<1||this.needsDrivenTransparentPass;return e.transparent=a,e.opacity=r,e.cullFace=a?ie.None:ie.Back,e}async _createResourcesForPrimitive(s,a){if(!X(s))throw new Error(`Unknown object symbol primitive: ${s}`);const i=this.symbolLayer,n=j(I(s)),c=b(w(n)),l=b(T(c,i)),h=p(l),d=!1,m=!1,u={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,ambient:g,diffuse:g,hasSlicePlane:this._context.slicePlaneEnabled,hasSliceHighlight:!1,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!this.symbolLayer.isPrimitive},y=u.usePBR;this._setMaterialTransparencyParams(u);const f=this.symbol;if("point-3d"===f.type&&f.verticalOffset){const{screenLength:e,minWorldLength:s,maxWorldLength:r}=f.verticalOffset;u.verticalOffset={screenLength:o(e),minWorldLength:s||0,maxWorldLength:t(r)?r:1/0},u.castShadows=!1}if(this._context.screenSizePerspectiveEnabled&&(u.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),this._drivenProperties.color)u.externalColor=x;else{const s=t(i.material)&&i.material.color,r=t(s)?e.toUnitRGBA(s):x;u.externalColor=r}this._fastUpdates=te(this._context.renderer,this._fastVisualVariableConvertOptions(n,l,c,r)),u.instanced=["transformation"],this._fastUpdates.enabled?(Object.assign(u,this._fastUpdates.materialParameters),u.instanced.push("featureAttribute"),this._optionalFields.push("featureAttribute")):this._hasPerInstanceColor()&&(u.instanced.push("color"),this._optionalFields.push("color")),has("enable-feature:objectAndLayerId-rendering")&&(u.instanced.push("objectAndLayerIdColor"),this._optionalFields.push("objectAndLayerIdColor"));const _=new pe(u),P=Y(s,_);if(!P)throw new Error(`Unknown object symbol primitive: ${s}`);const R=ce(P).map((e=>({opacity:1,transparent:e.parameters.transparent}))),v=await this._createStageResources(P,y);return{lodResources:P,lodRenderer:await this._createLodRenderer(P,a),stageResources:v,symbolSize:l,extentPadding:h,isEsriSymbolResource:d,isWosr:m,originalMaterialParameters:R,physicalBasedRenderingEnabled:y,resourceBoundingBox:n,resourceSize:c,pivotOffset:r}}async _createResourcesForUrl(e,a){const i=["transformation"],n={materialParamsMixin:{instanced:i,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},streamDataRequester:this._context.streamDataRequester,cache:this._context.sharedResources.objectResourceCache};this._fastUpdates=te(this._context.renderer,this._fastVisualVariableConvertOptions(r,r,r,r)),this._fastUpdates.enabled?(Object.assign(n.materialParamsMixin,this._fastUpdates.materialParameters),i.push("featureAttribute"),this._optionalFields.push("featureAttribute")):this._hasPerInstanceColor()&&(i.push("color"),this._optionalFields.push("color")),has("enable-feature:objectAndLayerId-rendering")&&(i.push("objectAndLayerIdColor"),this._optionalFields.push("objectAndLayerIdColor"));const c=this.symbol;if("point-3d"===c.type&&c.verticalOffset){const{screenLength:e,minWorldLength:s,maxWorldLength:r}=c.verticalOffset;n.materialParamsMixin.verticalOffset={screenLength:o(e),minWorldLength:s||0,maxWorldLength:t(r)?r:1/0},n.materialParamsMixin.castShadows=!1}n.signal=a,n.usePBR=this._context.physicalBasedRenderingEnabled;const l=n.usePBR,h=await J(e,n),d=h.isEsriSymbolResource,m=h.isWosr;this._addDisposeResource((()=>h.remove()));const u=$(h.lods);Z(u),u.levels.sort(((e,t)=>e.minScreenSpaceRadius-t.minScreenSpaceRadius)),u.levels[0].minScreenSpaceRadius=Math.min(2,u.levels[0].minScreenSpaceRadius);const y=this._context,f=this.symbolLayer.material,_=this._getExternalColorParameters(f),g=s(this.symbolLayer,"material","color"),P=this._getCombinedOpacity(g,{hasIntrinsicColor:!0}),R=this.needsDrivenTransparentPass,v=ce(u),x=ce(u).map((e=>({opacity:e.parameters.opacity||1,transparent:e.parameters.transparent})));v.forEach((e=>{const t=e.parameters;e.setParameters(_);const s=t.opacity*P,r=s<1||R||t.transparent;e.setParameters({opacity:s,transparent:r}),y.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:y.sharedResources.screenSizePerspectiveSettings})}));const L=h.referenceBoundingBox,S=b(w(L)),C=b(u.levels[0].pivotOffset),j=b(T(S,this.symbolLayer)),U=p(j);se(this._fastUpdates,this._context.renderer,this._fastVisualVariableConvertOptions(L,j,S,C))&&v.forEach((e=>e.setParameters(this._fastUpdates.materialParameters)));const E=await this._createStageResources(u,l);return{lodResources:u,lodRenderer:await this._createLodRenderer(u,a),stageResources:E,symbolSize:j,extentPadding:U,isEsriSymbolResource:d,isWosr:m,originalMaterialParameters:x,physicalBasedRenderingEnabled:l,resourceBoundingBox:L,resourceSize:S,pivotOffset:C}}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(e,t){const s=this._context.stage,r=ce(e);t!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged(),s.addMany(r),this._addDisposeResource((()=>s.removeMany(r)));const a=le(e);s.addMany(a),this._addDisposeResource((()=>s.removeMany(a))),await s.load(a);const i=he(e);return s.addMany(i),this._addDisposeResource((()=>s.removeMany(i))),{materials:r,textures:a,geometries:i}}async _createLodRenderer(e,t){const s=this._context.stage,r={layerUid:this._context.layer.uid,graphicUid:e=>this._instanceIndexToGraphicUid.get(e),notifyGraphicGeometryChanged:e=>this._context.notifyGraphicGeometryChanged(this._instanceIndexToGraphicUid.get(e)),notifyGraphicVisibilityChanged:e=>this._context.notifyGraphicVisibilityChanged(this._instanceIndexToGraphicUid.get(e))},a=this._fastUpdates.enabled?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,_e),n(s,re(this._fastUpdates.materialParameters,_e,s))},scaleFactor:(e,t,s)=>(t.getFeatureAttribute(s,_e),ae(e,this._fastUpdates.materialParameters,_e))}:null,i=new ne(e,this._optionalFields,r,a);return i.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource((()=>{s.removeRenderPlugin(i)})),await s.addRenderPlugin(i.slots,i,t),i}_getExternalColorParameters(s){const r={};return this._drivenProperties.color?r.externalColor=x:t(s)&&t(s.color)?r.externalColor=e.toUnitRGBA(s.color):(r.externalColor=x,r.colorMixMode="ignore"),r}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach((e=>e())),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const s=K(t.geometry);if(a(s))return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const r=this.setGraphicElevationContext(t,new z),i=e.renderingInfo;return this._createAs3DShape(t,s,i,r,t.uid,e.layer.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(a(this._resources))return!0;const e=this._drivenProperties.opacity,t=!this._isPrimitive,r=this._resources.stageResources.materials,i=this._resources.originalMaterialParameters;for(let a=0;a<r.length;a++){const o=r[a],n=s(this.symbolLayer,"material","color"),c=i[a],l=this._getCombinedOpacity(n,{hasIntrinsicColor:t})*c.opacity,h=l<1||e||c.transparent;o.setParameters({opacity:l,transparent:h}),this._isPrimitive&&o.setParameters({cullFace:h?ie.None:ie.Back})}return!0}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,G)}slicePlaneEnabledChanged(){if(a(this._resources))return!0;this._resources.lodRenderer.slicePlaneEnabled=this._context.slicePlaneEnabled;for(const e of this._resources.stageResources.materials)e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled});return!0}physicalBasedRenderingChanged(){if(a(this._resources))return!0;const{stageResources:e,isWosr:t}=this._resources;for(const s of e.materials)this._isPrimitive?s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}):t||s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!1});return!1!==this._hasLoadedPBRTextures||!0!==this._context.physicalBasedRenderingEnabled||(this._hasLoadedPBRTextures=!0,!1)}pixelRatioChanged(){return!0}applyRendererDiff(e,t){if(a(this._resources))return q.Recreate_Symbol;const{stageResources:{materials:s},lodRenderer:r,resourceBoundingBox:i,symbolSize:o,resourceSize:n,pivotOffset:c}=this._resources;for(const a in e.diff){if("visualVariables"!==a)return q.Recreate_Symbol;if(!se(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,o,n,c)))return q.Recreate_Symbol;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return q.Fast_Update}computeComplexity(){if(a(this._resources))return super.computeComplexity();return{primitivesPerFeature:de(this._resources.lodResources.levels[0]).reduce(((e,t)=>e+t.indices.get(oe.POSITION).length),0)/3,primitivesPerCoordinate:0,drawCallsPerFeature:0,estimated:!1,memory:ee(this.symbol,this.symbolLayer)}}_hasLodRenderer(){return t(this._resources)}_createAs3DShape(e,s,r,i,o,n){if(!this._hasLodRenderer()||a(this._resources))return null;const c=this.getFastUpdateAttrValues(e),l=!this._fastUpdates.enabled&&this._hasPerInstanceColor()?k(r.color,r.opacity):null,h=this._context.clippingExtent;if(S(s,ue,this._context.elevationProvider.spatialReference),t(h)&&!U(h,ue))return null;const d=this._requiresTerrainElevation(i),p=this._computeGlobalTransform(s,i,fe,be),m=this._computeLocalTransform(this._resources,this.symbolLayer,r,ye),u=this._resources.lodRenderer.instanceData,y=u.addInstance();this._instanceIndexToGraphicUid.set(y,o),u.setLocalTransform(y,m,!1),u.setGlobalTransform(y,p),c&&u.setFeatureAttribute(y,c),l&&u.setColor(y,l),has("enable-feature:objectAndLayerId-rendering")&&u.setObjectAndLayerIdColor(y,this._context.stage.renderView._objectAndLayerIdRenderHelper.getObjectAndLayerIdColor({graphicUid:o,layerUid:n}));const f=new M(this,y,O,i);return d&&(f.alignedSampledElevation=be.sampledElevation),f.needsElevationUpdates=G(i.mode),Q(f,s,this._context.elevationProvider),f}_computeGlobalTransform(e,t,s,r){return A(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),ue[0]=e.x,ue[1]=e.y,ue[2]=r.z,C(e.spatialReference,ue,s,this._context.renderCoordsHelper.spatialReference),s}_computeLocalTransform(e,t,s,r){return c(r),this._applyObjectRotation(s,!1,r),this._applyObjectRotation(t,!0,r),this._applyObjectScale(e,s,r),this._applyAnchor(e,t,r),r}_applyObjectScale(e,t,s){if(this._fastUpdates.enabled&&this._fastUpdates.requiresShaderTransformation)return;const r=this._drivenProperties.size&&t.size?t.size:e.symbolSize,a=W(r,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);1===a[0]&&1===a[1]&&1===a[2]||l(s,s,a)}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchTransform(e,t),this._preparePatchColor(e,t)}updateGeometry(e,t){if(a(this._resources))return!0;const s=t&&K(t);if(a(s))return!1;const r=this.getGeometryElevationMode(t);return e.elevationContext.mode===r&&(this._computeGlobalTransform(s,e.elevationContext,fe,be),this._requiresTerrainElevation(e.elevationContext)&&(e.alignedSampledElevation=be.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(e.instanceIndex,fe,!0),Q(e,s,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!(t.heading||t.tilt||t.roll||t.width||t.height||t.depth||t.anchor||t.anchorPosition))return;if(a(this._resources))return;const s=(e,t,s)=>i(null!=e&&"complete"===e.type?e.newValue:t,s),r=s(t.heading,this.symbolLayer.heading,0),o=s(t.tilt,this.symbolLayer.tilt,0),n=s(t.roll,this.symbolLayer.roll,0),c=s(t.width,this.symbolLayer.width,void 0),l=s(t.height,this.symbolLayer.height,void 0),h=s(t.depth,this.symbolLayer.depth,void 0),d=s(t.anchor,this.symbolLayer.anchor,void 0),p=s(t.anchorPosition,this.symbolLayer.anchorPosition,void 0);delete t.heading,delete t.tilt,delete t.roll,delete t.width,delete t.height,delete t.depth,delete t.anchor,delete t.anchorPosition;const m={heading:r,tilt:o,roll:n,anchor:d,anchorPosition:p},u=this._resources;this.loadStatus===N.LOADED&&e.symbolLayerStatePatches.push((()=>{u.symbolSize=b(T(u.resourceSize,{width:c,height:l,depth:h,isPrimitive:this.symbolLayer.isPrimitive}))})),e.graphics3DGraphicPatches.push(((e,t)=>{const s=this._computeLocalTransform(u,m,t,ye),r=e.instanceIndex;u.lodRenderer.instanceData.setLocalTransform(r,s,!0)}))}_preparePatchColor(s,r){if(!r.material||"partial"!==r.material.type)return;const i=r.material.diff;if(!i.color||"complete"!==i.color.type||null==i.color.newValue||null==i.color.oldValue)return;const o=i.color.newValue,n=t(o)?e.toUnitRGBA(o):x;delete i.color;const c=this._resources;a(c)||s.graphics3DGraphicPatches.push((e=>{let t;this._hasPerInstanceColor()?(c.lodRenderer.instanceData.setColor(e.instanceIndex,n),t=this._setMaterialTransparencyParams({},o)):t=this._setMaterialTransparencyParams({externalColor:n},o);for(const s of c.stageResources.materials)s.setParameters(t)}))}_requiresTerrainElevation(e){return"absolute-height"!==e.mode}_applyObjectRotation(e,t,s){if(!(this._fastUpdates.enabled&&this._fastUpdates.requiresShaderTransformation&&t))return H(e.heading,e.tilt,e.roll,s)}_computeAnchor(e,s,r){const a=v();switch(r.anchor){case"center":u(a,E(e)),m(a,a);break;case"top":{const t=E(e);_(a,-t[0],-t[1],-e[5]);break}case"bottom":{const t=E(e);_(a,-t[0],-t[1],-e[2]);break}case"relative":{const t=E(e),s=w(e),i=r.anchorPosition,o=i?R(i.x,i.y,i.z):P;y(a,s,o),f(a,a,t),m(a,a);break}default:t(s)?m(a,s):u(a,P)}return a}_applyAnchor(e,t,s){if(this._fastUpdates.enabled&&this._fastUpdates.requiresShaderTransformation)return;const r=this._computeAnchor(e.resourceBoundingBox,e.pivotOffset,t);r&&h(s,s,r)}_hasPerInstanceColor(){return this._drivenProperties.color||this._drivenProperties.opacity}_fastVisualVariableConvertOptions(e,s,r,a){const i=t(e)?b(w(e)):g,o=t(e)?this._computeAnchor(e,a,this.symbolLayer):P,n=this._context.renderCoordsHelper.unitInMeters,c=W(t(s)?s:void 0,s,r,n),l=R(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return{modelSize:i,symbolSize:t(s)?s:g,unitInMeters:n,transformation:{anchor:o,scale:c,rotation:l}}}}const ue=v(),ye=d(),fe=d(),_e=L(),be=new D;export{me as Graphics3DObjectSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../core/Error.js";import{acosClamped as t,reciprocalClamped as r}from"../../../../core/mathUtils.js";import{isSome as i,get as s}from"../../../../core/maybe.js";import{s as a}from"../../../../chunks/mat2.js";import{s as o,b as n}from"../../../../chunks/vec2.js";import{f as l,b as h}from"../../../../chunks/vec2f64.js";import{s as c,a as p,e as m,f,g as d,n as u,o as g,b as y}from"../../../../chunks/vec3.js";import{c as _}from"../../../../chunks/vec3f32.js";import{d as b,c as v}from"../../../../chunks/vec3f64.js";import{projectBuffer as x}from"../../../../geometry/projection.js";import{create as w,empty as S,expandWithBuffer as R,intersectsClippingArea as D}from"../../../../geometry/support/aaBoundingBox.js";import{makeDehydratedPoint as P}from"../../../../layers/graphics/dehydratedFeatures.js";import{needsElevationUpdates3D as j,evaluateElevationAlignmentAtPoint as C,SampleElevationInfo as A,evaluateElevationInfoAtPoint as V}from"./elevationAlignmentUtils.js";import{ElevationContext as L}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as z}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as E,getAttributeValue as U}from"./Graphics3DSymbolLayer.js";import{isValidSize as k}from"./graphicUtils.js";import{ApplyRendererDiffResult as F}from"./interfaces.js";import{initFastSymbolUpdatesState as G,updateFastSymbolUpdatesState as I}from"../support/FastSymbolUpdates.js";import{CullFaceOptions as M}from"../../webgl-engine/lib/basicInterfaces.js";import{Object3D as B}from"../../webgl-engine/lib/Object3D.js";import{PathGeometry as O,isPathGeometry as q}from"../../webgl-engine/lib/PathGeometry.js";import{Profile as H,SimpleExtruder as T,MiterExtruder as N,RoundCapBuilder as W,TriangulationCapBuilder as Z,NoCapBuilder as J,PathVertex as K,Path as Q,Builder as X,FastUpdatePathGeometry as Y,StaticPathGeometry as $,computeMinimumRotationTangentFrame as ee,vertexSpaceToProfileSpace as te}from"../../webgl-engine/lib/pathGeometryUtils.js";import{DefaultMaterial as re}from"../../webgl-engine/materials/DefaultMaterial.js";import{PathMaterial as ie}from"../../webgl-engine/materials/PathMaterial.js";const se=["polyline"];class ae extends E{constructor(e,t,r,i){super(e,t,r,i),this._intrinsicSize=l(1,1),this._upVectorAlignment="path",this._stencilWidth=.1,this.ensureDrapedStatus(!1)}async doLoad(){const t=i(this.symbolLayer.width)?this.symbolLayer.width:this.symbolLayer.height,r=i(this.symbolLayer.height)?this.symbolLayer.height:t;this._vvConvertOptions={modelSize:[1,1,1],symbolSize:[t,1,r],unitInMeters:this._context.renderCoordsHelper.unitInMeters,transformation:{anchor:[0,0,0],scale:[1,1,1],rotation:[0,0,0]},supportedTypes:{size:!0,color:!0,opacity:!0,rotation:!1}},this._context.renderer&&this._context.renderer.visualVariables&&this._context.renderer.visualVariables.length>0?this._fastUpdates=G(this._context.renderer,this._vvConvertOptions):this._fastUpdates={enabled:!1};const a=this.symbolLayer.anchor||"center";this._upVectorAlignment="path","heading"===this.symbolLayer.profileRotation&&(this._upVectorAlignment="world");const l=this.symbolLayer.profile||"circle";switch(l){case"circle":default:this._profile=H.circle(_e);break;case"quad":this._profile=H.rect()}let c=[0,0];"center"!==a&&(c={left:[.5,0],right:[-.5,0],top:[0,-.5],bottom:[0,.5]}[a],this._profile.translate(c[0],c[1]));switch(this.symbolLayer.join||"simple"){case"round":this._extruder=new N(0,ge);break;case"bevel":this._extruder=new N(0,1);break;case"miter":this._extruder=new N(.8*Math.PI,1);break;default:this._extruder=new T}const p=this.symbolLayer.cap||"butt";switch(p){case"none":this._startCap=new J,this._endCap=new J;break;case"butt":default:this._startCap=new Z(this._profile,0),this._endCap=new Z(this._profile,0,!0);break;case"square":this._startCap=new Z(this._profile,-.5),this._endCap=new Z(this._profile,.5,!0);break;case"round":{const e="quad"===l;this._startCap=new W({profile:this._profile,flip:!1,breakNormals:e,subdivisions:ye}),this._endCap=new W({profile:this._profile,flip:!0,breakNormals:e,subdivisions:ye});break}}const m=s(this.symbolLayer,"material","color"),f=this._getCombinedOpacityAndColor(m),d=b(f),u=f[3],g=u<1||this.needsDrivenTransparentPass,y={diffuse:d,ambient:d,opacity:u,transparent:g,hasVertexColors:!1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,cullFace:g||"none"===p?M.None:M.Back,offsetTransparentBackfaces:!0};if(!this._drivenProperties.size&&(o(this._intrinsicSize,t,r),!k(this._intrinsicSize[0])||!k(this._intrinsicSize[1])))throw new e("graphics3dpathsymbollayer:invalid-size","Symbol sizes may not be negative values");if(this._fastUpdates.enabled&&this._fastUpdates.visualVariables.size||n(this._intrinsicSize,this._intrinsicSize,1/this._context.renderCoordsHelper.unitInMeters),this._fastUpdates.enabled){const e={...y,...this._fastUpdates.materialParameters,size:h(this._intrinsicSize)};this._material=new ie(e)}else y.hasVertexColors=this._drivenProperties.color||this._drivenProperties.opacity,this._material=new re(y);this._material.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),this._context.stage.add(this._material)}destroy(){super.destroy(),this._context.stage.remove(this._material),this._material=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,se,this.symbolLayer.type))return null;const r=this.setGraphicElevationContext(t,new L),i=e.renderingInfo;return this._createAs3DShape(t,i,r,t.uid)}layerOpacityChanged(){const e=s(this.symbolLayer,"material","color"),t=this._getCombinedOpacity(e),r=t<1||this.needsDrivenTransparentPass;return this._material.setParameters({opacity:t,transparent:r}),!0}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,j)}slicePlaneEnabledChanged(){return this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return this._material.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),!0}pixelRatioChanged(){return!0}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return F.Recreate_Symbol;if(!I(this._fastUpdates,t,this._vvConvertOptions))return F.Recreate_Symbol;this._material.setParameters(this._fastUpdates.materialParameters)}return F.Fast_Update}getVertexData(e){let t=0;const r=e.paths,s=[],a=e.spatialReference,o=this._context.elevationProvider.spatialReference,n=this._context.renderCoordsHelper.spatialReference;for(const i of r)t+=i.length;const l=new Float64Array(3*t),h=new Float64Array(3*t),c=new Float64Array(3*t);let p=0;for(const i of r){s.push({index:p,numVertices:i.length});for(const t of i)l[p++]=t[0],l[p++]=t[1],l[p++]=e.hasZ?t[2]:0}let m=!0;return i(o)&&!a.equals(o)?m=x(l,a,0,h,o,0,t):this._copyVertices(l,0,h,0,t),i(o)&&!o.equals(n)?x(h,o,0,c,n,0,t):this._copyVertices(h,0,c,0,t),{pathVertexDataInfos:s,vertexDataGS:l,vertexDataES:h,vertexDataRS:c,projectionSuccess:m,terrainElevation:0}}_copyVertices(e,t,r,i,s){t*=3,i*=3;for(let a=0;a<s;++a)r[i++]=e[t++],r[i++]=e[t++],r[i++]=e[t++]}_createAs3DShape(e,t,r,s){const a=e.geometry,o=new Array,n=new Array,l=new Array,h=a.spatialReference,p=w(),m=this._context.renderCoordsHelper;pe.spatialReference=h;const f=this.getVertexData(a);if(!f.projectionSuccess)return this.logger.warn("PathSymbol3DLayer geometry failed to be created (failed to project geometry to view spatial reference)"),null;if(f.pathVertexDataInfos.length>0){for(let s=0;s<f.pathVertexDataInfos.length;++s){const a=f.pathVertexDataInfos[s],d=a.index,u=a.numVertices;if(u<2)continue;if(i(this._context.clippingExtent)&&(S(p),R(p,f.vertexDataES,3*d,u),!D(p,this._context.clippingExtent)))continue;const g=[];for(let e=d;e<d+3*u;){const t=e++,i=e++,s=e++,a=new K;c(a.posGS,f.vertexDataGS[t],f.vertexDataGS[i],f.vertexDataGS[s]),c(a.posES,f.vertexDataES[t],f.vertexDataES[i],f.vertexDataES[s]);const o=C(a.posES,this._context.elevationProvider,r,m);c(me,f.vertexDataRS[t],f.vertexDataRS[i],f.vertexDataRS[s]),m.setAltitude(me,o),c(a.pos,me[0],me[1],me[2]),g.push(a)}const y=new Q(g);oe(y,this._upVectorAlignment,this._context.renderCoordsHelper);const _=new X(y,this._profile,this._extruder,this._startCap,this._endCap);let b=null;if(this._fastUpdates.enabled){const t=this._fastUpdates.visualVariables,r=t.size?U(t.size.field,e):0,i=t.color?U(t.color.field,e):0,s=t.opacity?U(t.opacity.field,e):0;b=new Y(_,r,i,s)}else{const e=[this._intrinsicSize[0],this._intrinsicSize[1]];this._drivenProperties.size&&(e[0]*=ne(t.size[0],"symbol-value"===t.size[2]?this.symbolLayer.height||0:t.size[2],this.symbolLayer.width||0),e[1]*=ne(t.size[2],"symbol-value"===t.size[0]?this.symbolLayer.width||0:t.size[0],this.symbolLayer.height||0));let r=null;this._drivenProperties.color&&(r=t.color),this._drivenProperties.opacity&&null!=t.opacity&&(r=r?[r[0],r[1],r[2],t.opacity]:[1,1,1,t.opacity]);const i=new $(_);i.bake(e),r&&i.bakeVertexColors(r),b=i}const{vertexAttributes:v,indices:x}=b.createGeometryData(),w=new O(v,x,b,h,this._upVectorAlignment,this._stencilWidth);o.push(w),n.push(this._material),l.push(b.xform)}if(o.length>0){const e={layerUid:this._context.layer.uid,graphicUid:s},t=new B({geometries:o,materials:n,transformations:l,metadata:e}),i=new z(this,t,o,null,null,he,r);return i.alignedSampledElevation=f.terrainElevation,i.needsElevationUpdates=j(r.mode),i}}else 0!==a.paths.length&&a.paths.some((e=>e.length>0))||this.logger.warn("PathSymbol3DLayer geometry failed to be created (no paths were defined)");return null}}function oe(e,i,s){switch(i){case"world":for(const t of e.vertices)p(fe,t.pos,e.offset),s.worldUpAtPosition(fe,me),t.setFrameFromUpVector(me),t.computeRotationAxisAndAngleFromUpVector();break;case"path":p(fe,e.vertices[0].pos,e.offset),s.worldUpAtPosition(fe,me),ee(e,me);for(const i of e.vertices){const e=Math.sign(m(i.frame.right,i.vRight));f(i.rotationFrame.up,i.vRight,i.vLeft),d(i.rotationFrame.up,i.rotationFrame.up,e),u(i.rotationFrame.up,i.rotationFrame.up);const s=m(i.rotationFrame.up,i.frame.up),o=m(i.rotationFrame.up,i.frame.right);if(d(fe,i.frame.up,-o),d(de,i.frame.right,s),p(fe,fe,de),u(i.rotationFrame.right,fe),te(i.rotationRight,i.frame,i.rotationFrame.right),g(fe,i.vLeft),i.rotationAngle=-e*(Math.PI-t(m(fe,i.vRight))),Math.abs(i.rotationAngle)>0){const e=r(Math.cos(.5*i.rotationAngle));a(i.miterStretch,1+(e-1)*i.rotationRight[0]*i.rotationRight[0],(e-1)*i.rotationRight[0]*i.rotationRight[1],(e-1)*i.rotationRight[0]*i.rotationRight[1],1+(e-1)*i.rotationRight[1]*i.rotationRight[1])}const n=Math.PI-i.rotationAngle;i.maxStretchDistance=Math.abs(Math.min(i.vLeftLength,i.vRightLength)*r(Math.cos(.5*n)))}}}function ne(e,t,r){switch(e){case"symbol-value":return r;case"proportional":return t;default:return e}}function le(e,t,r,i){let s=0;for(const a of e.vertices)V(a.posES,r,t,i,ue),s+=ue.sampledElevation,p(me,a.pos,e.offset),i.setAltitude(me,ue.z),y(a.pos,me,e.offset);return e.updatePathVertexInformation(),s/e.vertices.length}function he(e,t,r,i){const s=e.stageObject,a=s.geometryRecords;let o=0;ce.spatialReference=i.spatialReference;for(const n of a){const e=n.geometry;if(!q(e))continue;const a=e.path,l=a.builder.path,h=e.geometrySR;pe.spatialReference=h,o+=le(l,t,r,i),"world"!==e.upVectorAlignment&&oe(l,e.upVectorAlignment,i),a.onPathChanged(),e.invalidateBoundingInfo(),s.geometryVertexAttrsUpdated(n)}return o/a.length}const ce=P(0,0,0,null),pe=P(0,0,0,null),me=v(),fe=_(),de=_(),ue=new A,ge=3,ye=3,_e=10;export{ae as Graphics3DPathSymbolLayer,_e as NUM_CIRCLE_PROFILE_SUBDIVISIONS,ye as NUM_ROUND_CAP_EXTRUSION_SUBDIVISIONS,ge as NUM_ROUND_JOIN_SUBDIVISIONS};
|
|
5
|
+
import e from"../../../../core/Error.js";import{acosClamped as t,reciprocalClamped as r}from"../../../../core/mathUtils.js";import{isSome as i,get as s}from"../../../../core/maybe.js";import{s as a}from"../../../../chunks/mat2.js";import{s as o,b as n}from"../../../../chunks/vec2.js";import{f as l,b as h}from"../../../../chunks/vec2f64.js";import{s as c,a as p,e as m,f as d,g as f,n as u,o as g,b as y}from"../../../../chunks/vec3.js";import{c as _}from"../../../../chunks/vec3f32.js";import{d as b,c as v}from"../../../../chunks/vec3f64.js";import{projectBuffer as x}from"../../../../geometry/projection.js";import{create as w,empty as S,expandWithBuffer as R,intersectsClippingArea as D}from"../../../../geometry/support/aaBoundingBox.js";import{makeDehydratedPoint as P}from"../../../../layers/graphics/dehydratedFeatures.js";import{needsElevationUpdates3D as j,evaluateElevationAlignmentAtPoint as C,SampleElevationInfo as A,evaluateElevationInfoAtPoint as V}from"./elevationAlignmentUtils.js";import{ElevationContext as L}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as z}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as U,getAttributeValue as E}from"./Graphics3DSymbolLayer.js";import{isValidSize as k}from"./graphicUtils.js";import{ApplyRendererDiffResult as F}from"./interfaces.js";import{initFastSymbolUpdatesState as G,updateFastSymbolUpdatesState as I}from"../support/FastSymbolUpdates.js";import{CullFaceOptions as M}from"../../webgl-engine/lib/basicInterfaces.js";import{Object3D as B}from"../../webgl-engine/lib/Object3D.js";import{PathGeometry as O,isPathGeometry as q}from"../../webgl-engine/lib/PathGeometry.js";import{Profile as H,SimpleExtruder as T,MiterExtruder as N,RoundCapBuilder as W,TriangulationCapBuilder as Z,NoCapBuilder as J,PathVertex as K,Path as Q,Builder as X,FastUpdatePathGeometry as Y,StaticPathGeometry as $,computeMinimumRotationTangentFrame as ee,vertexSpaceToProfileSpace as te}from"../../webgl-engine/lib/pathGeometryUtils.js";import{DefaultMaterial as re}from"../../webgl-engine/materials/DefaultMaterial.js";import{PathMaterial as ie}from"../../webgl-engine/materials/PathMaterial.js";const se=["polyline"];class ae extends U{constructor(e,t,r,i){super(e,t,r,i),this._intrinsicSize=l(1,1),this._upVectorAlignment="path",this._stencilWidth=.1,this.ensureDrapedStatus(!1)}async doLoad(){const t=i(this.symbolLayer.width)?this.symbolLayer.width:this.symbolLayer.height,r=i(this.symbolLayer.height)?this.symbolLayer.height:t;this._vvConvertOptions={modelSize:[1,1,1],symbolSize:[t,1,r],unitInMeters:this._context.renderCoordsHelper.unitInMeters,transformation:{anchor:[0,0,0],scale:[1,1,1],rotation:[0,0,0]},supportedTypes:{size:!0,color:!0,opacity:!0,rotation:!1}},this._context.renderer&&this._context.renderer.visualVariables&&this._context.renderer.visualVariables.length>0?this._fastUpdates=G(this._context.renderer,this._vvConvertOptions):this._fastUpdates={enabled:!1};const a=this.symbolLayer.anchor||"center";this._upVectorAlignment="path","heading"===this.symbolLayer.profileRotation&&(this._upVectorAlignment="world");const l=this.symbolLayer.profile||"circle";switch(l){case"circle":default:this._profile=H.circle(_e);break;case"quad":this._profile=H.rect()}let c=[0,0];"center"!==a&&(c={left:[.5,0],right:[-.5,0],top:[0,-.5],bottom:[0,.5]}[a],this._profile.translate(c[0],c[1]));switch(this.symbolLayer.join||"simple"){case"round":this._extruder=new N(0,ge);break;case"bevel":this._extruder=new N(0,1);break;case"miter":this._extruder=new N(.8*Math.PI,1);break;default:this._extruder=new T}const p=this.symbolLayer.cap||"butt";switch(p){case"none":this._startCap=new J,this._endCap=new J;break;case"butt":default:this._startCap=new Z(this._profile,0),this._endCap=new Z(this._profile,0,!0);break;case"square":this._startCap=new Z(this._profile,-.5),this._endCap=new Z(this._profile,.5,!0);break;case"round":{const e="quad"===l;this._startCap=new W({profile:this._profile,flip:!1,breakNormals:e,subdivisions:ye}),this._endCap=new W({profile:this._profile,flip:!0,breakNormals:e,subdivisions:ye});break}}const m=s(this.symbolLayer,"material","color"),d=this._getCombinedOpacityAndColor(m),f=b(d),u=d[3],g=u<1||this.needsDrivenTransparentPass,y={diffuse:f,ambient:f,opacity:u,transparent:g,hasVertexColors:!1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,cullFace:g||"none"===p?M.None:M.Back,offsetTransparentBackfaces:!0};if(!this._drivenProperties.size&&(o(this._intrinsicSize,t,r),!k(this._intrinsicSize[0])||!k(this._intrinsicSize[1])))throw new e("graphics3dpathsymbollayer:invalid-size","Symbol sizes may not be negative values");if(this._fastUpdates.enabled&&this._fastUpdates.visualVariables.size||n(this._intrinsicSize,this._intrinsicSize,1/this._context.renderCoordsHelper.unitInMeters),this._fastUpdates.enabled){const e={...y,...this._fastUpdates.materialParameters,size:h(this._intrinsicSize)};this._material=new ie(e)}else y.hasVertexColors=this._drivenProperties.color||this._drivenProperties.opacity,this._material=new re(y);this._material.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),this._context.stage.add(this._material)}destroy(){super.destroy(),this._context.stage.remove(this._material),this._material=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,se,this.symbolLayer.type))return null;const r=this.setGraphicElevationContext(t,new L),i=e.renderingInfo;return this._createAs3DShape(t,i,r,t.uid)}layerOpacityChanged(){const e=s(this.symbolLayer,"material","color"),t=this._getCombinedOpacity(e),r=t<1||this.needsDrivenTransparentPass;return this._material.setParameters({opacity:t,transparent:r}),!0}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,j)}slicePlaneEnabledChanged(){return this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return this._material.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),!0}pixelRatioChanged(){return!0}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return F.Recreate_Symbol;if(!I(this._fastUpdates,t,this._vvConvertOptions))return F.Recreate_Symbol;this._material.setParameters(this._fastUpdates.materialParameters)}return F.Fast_Update}getVertexData(e){let t=0;const r=e.paths,s=[],a=e.spatialReference,o=this._context.elevationProvider.spatialReference,n=this._context.renderCoordsHelper.spatialReference;for(const i of r)t+=i.length;const l=new Float64Array(3*t),h=new Float64Array(3*t),c=new Float64Array(3*t);let p=0;for(const i of r){s.push({index:p,numVertices:i.length});for(const t of i)l[p++]=t[0],l[p++]=t[1],l[p++]=e.hasZ?t[2]:0}let m=!0;return i(o)&&!a.equals(o)?m=x(l,a,0,h,o,0,t):this._copyVertices(l,0,h,0,t),i(o)&&!o.equals(n)?x(h,o,0,c,n,0,t):this._copyVertices(h,0,c,0,t),{pathVertexDataInfos:s,vertexDataGS:l,vertexDataES:h,vertexDataRS:c,projectionSuccess:m,terrainElevation:0}}_copyVertices(e,t,r,i,s){t*=3,i*=3;for(let a=0;a<s;++a)r[i++]=e[t++],r[i++]=e[t++],r[i++]=e[t++]}_createAs3DShape(e,t,r,s){const a=e.geometry,o=new Array,n=new Array,l=new Array,h=a.spatialReference,p=w(),m=this._context.renderCoordsHelper;pe.spatialReference=h;const d=this.getVertexData(a);if(!d.projectionSuccess)return this.logger.warn("PathSymbol3DLayer geometry failed to be created (failed to project geometry to view spatial reference)"),null;if(d.pathVertexDataInfos.length>0){for(let a=0;a<d.pathVertexDataInfos.length;++a){const f=d.pathVertexDataInfos[a],u=f.index,g=f.numVertices;if(g<2)continue;if(i(this._context.clippingExtent)&&(S(p),R(p,d.vertexDataES,3*u,g),!D(p,this._context.clippingExtent)))continue;const y=[];for(let e=u;e<u+3*g;){const t=e++,i=e++,s=e++,a=new K;c(a.posGS,d.vertexDataGS[t],d.vertexDataGS[i],d.vertexDataGS[s]),c(a.posES,d.vertexDataES[t],d.vertexDataES[i],d.vertexDataES[s]);const o=C(a.posES,this._context.elevationProvider,r,m);c(me,d.vertexDataRS[t],d.vertexDataRS[i],d.vertexDataRS[s]),m.setAltitude(me,o),c(a.pos,me[0],me[1],me[2]),y.push(a)}const _=new Q(y);oe(_,this._upVectorAlignment,this._context.renderCoordsHelper);const b=new X(_,this._profile,this._extruder,this._startCap,this._endCap);let v=null;if(this._fastUpdates.enabled){const t=this._fastUpdates.visualVariables,r=t.size?E(t.size.field,e):0,i=t.color?E(t.color.field,e):0,s=t.opacity?E(t.opacity.field,e):0;v=new Y(b,r,i,s)}else{const e=[this._intrinsicSize[0],this._intrinsicSize[1]];this._drivenProperties.size&&(e[0]*=ne(t.size[0],"symbol-value"===t.size[2]?this.symbolLayer.height||0:t.size[2],this.symbolLayer.width||0),e[1]*=ne(t.size[2],"symbol-value"===t.size[0]?this.symbolLayer.width||0:t.size[0],this.symbolLayer.height||0));let r=null;this._drivenProperties.color&&(r=t.color),this._drivenProperties.opacity&&null!=t.opacity&&(r=r?[r[0],r[1],r[2],t.opacity]:[1,1,1,t.opacity]);const i=new $(b);i.bake(e),r&&i.bakeVertexColors(r),v=i}const{vertexAttributes:x,indices:w}=v.createGeometryData(),P=this._context.stage.renderView._getObjectAndLayerIdColor({graphicUid:s,layerUid:this._context.layer.uid}),j=new O(x,w,v,h,this._upVectorAlignment,this._stencilWidth,P);o.push(j),n.push(this._material),l.push(v.xform)}if(o.length>0){const e={layerUid:this._context.layer.uid,graphicUid:s},t=new B({geometries:o,materials:n,transformations:l,metadata:e}),i=new z(this,t,o,null,null,he,r);return i.alignedSampledElevation=d.terrainElevation,i.needsElevationUpdates=j(r.mode),i}}else 0!==a.paths.length&&a.paths.some((e=>e.length>0))||this.logger.warn("PathSymbol3DLayer geometry failed to be created (no paths were defined)");return null}}function oe(e,i,s){switch(i){case"world":for(const t of e.vertices)p(de,t.pos,e.offset),s.worldUpAtPosition(de,me),t.setFrameFromUpVector(me),t.computeRotationAxisAndAngleFromUpVector();break;case"path":p(de,e.vertices[0].pos,e.offset),s.worldUpAtPosition(de,me),ee(e,me);for(const i of e.vertices){const e=Math.sign(m(i.frame.right,i.vRight));d(i.rotationFrame.up,i.vRight,i.vLeft),f(i.rotationFrame.up,i.rotationFrame.up,e),u(i.rotationFrame.up,i.rotationFrame.up);const s=m(i.rotationFrame.up,i.frame.up),o=m(i.rotationFrame.up,i.frame.right);if(f(de,i.frame.up,-o),f(fe,i.frame.right,s),p(de,de,fe),u(i.rotationFrame.right,de),te(i.rotationRight,i.frame,i.rotationFrame.right),g(de,i.vLeft),i.rotationAngle=-e*(Math.PI-t(m(de,i.vRight))),Math.abs(i.rotationAngle)>0){const e=r(Math.cos(.5*i.rotationAngle));a(i.miterStretch,1+(e-1)*i.rotationRight[0]*i.rotationRight[0],(e-1)*i.rotationRight[0]*i.rotationRight[1],(e-1)*i.rotationRight[0]*i.rotationRight[1],1+(e-1)*i.rotationRight[1]*i.rotationRight[1])}const n=Math.PI-i.rotationAngle;i.maxStretchDistance=Math.abs(Math.min(i.vLeftLength,i.vRightLength)*r(Math.cos(.5*n)))}}}function ne(e,t,r){switch(e){case"symbol-value":return r;case"proportional":return t;default:return e}}function le(e,t,r,i){let s=0;for(const a of e.vertices)V(a.posES,r,t,i,ue),s+=ue.sampledElevation,p(me,a.pos,e.offset),i.setAltitude(me,ue.z),y(a.pos,me,e.offset);return e.updatePathVertexInformation(),s/e.vertices.length}function he(e,t,r,i){const s=e.stageObject,a=s.geometryRecords;let o=0;ce.spatialReference=i.spatialReference;for(const n of a){const e=n.geometry;if(!q(e))continue;const a=e.path,l=a.builder.path,h=e.geometrySR;pe.spatialReference=h,o+=le(l,t,r,i),"world"!==e.upVectorAlignment&&oe(l,e.upVectorAlignment,i),a.onPathChanged(),e.invalidateBoundingInfo(),s.geometryVertexAttrsUpdated(n)}return o/a.length}const ce=P(0,0,0,null),pe=P(0,0,0,null),me=v(),de=_(),fe=_(),ue=new A,ge=3,ye=3,_e=10;export{ae as Graphics3DPathSymbolLayer,_e as NUM_CIRCLE_PROFILE_SUBDIVISIONS,ye as NUM_ROUND_CAP_EXTRUSION_SUBDIVISIONS,ge as NUM_ROUND_JOIN_SUBDIVISIONS};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import{isSome as t,get as i,isNone as r,unwrap as n}from"../../../../core/maybe.js";import{pt2px as o}from"../../../../core/screenUtils.js";import{e as a}from"../../../../chunks/earcut.js";import{I as s}from"../../../../chunks/mat4f64.js";import{s as l}from"../../../../chunks/vec4.js";import{create as u,empty as h,expandWithBuffer as c,intersectsClippingArea as p,expandWithAABB as d}from"../../../../geometry/support/aaBoundingBox.js";import{BufferViewMat3f64 as m,BufferViewVec3f64 as _,BufferViewVec4f as y}from"../../../../geometry/support/buffer/BufferView.js";import{SymbolUpdateType as g,elevationModeChangeUpdateType as f,needsElevationUpdates2D as x}from"./elevationAlignmentUtils.js";import{ElevationContext as b}from"./ElevationContext.js";import v from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as M}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as E}from"./Graphics3DSymbolLayer.js";import{mixinColorAndOpacity as O}from"./graphicUtils.js";import{parseCapType as D,createGeometry as S,RemoveDuplicateStartEnd as A}from"./lineUtils.js";import{geometryAsPolygon as U,geometryToRenderInfo as P,createColorGeometry as C,geometryToRenderInfoDraped as w}from"./polygonUtils.js";import{createMaterial as G,uvElevationAligner as T}from"../support/patternUtils.js";import{createMapSpaceUVCoords as j,createMapSpaceUVCoordsDraped as R}from"../support/uvUtils.js";import{Object3D as B}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as L}from"../../webgl-engine/lib/RenderGeometry.js";import{VertexAttribute as N}from"../../webgl-engine/lib/VertexAttribute.js";import{getStipplePatternForLinePattern as V}from"../../webgl-engine/materials/lineStippleUtils.js";import{PatternMaterial as F}from"../../webgl-engine/materials/PatternMaterial.js";import{RibbonLineMaterial as I}from"../../webgl-engine/materials/RibbonLineMaterial.js";const H=["polyline","polygon","extent"];class W extends E{constructor(e,t,i,r){super(e,t,i,r),this._needsUV=!1,this._hasOutline=!1}async doLoad(){}_ensureMaterials(){this._ensureFillMaterial(),this._ensureOutlineMaterial()}_ensureFillMaterial(){if(t(this._material))return;const e=i(this.symbolLayer,"material","color"),r=this._getCombinedOpacityAndColor(e);this._material=G(this.symbolLayer,{color:r,transparent:r[3]<1||this.needsDrivenTransparentPass,polygonOffset:!1,hasVertexColors:!0,writeLinearDepth:!0,hasSlicePlane:this._context.slicePlaneEnabled},{isDraped:this.draped}),this._needsUV=this._material instanceof F,this._context.stage.add(this._material)}_ensureOutlineMaterial(){const e=this.symbolLayer.outline;if(t(this._outlineMaterial)||!this._isValidOutline(e))return;this._hasOutline=!0;const i=t=>{const i=V(e.pattern);return new I({width:t,color:this._getOutlineColor(),hasPolygonOffset:!0,hasSlicePlane:this._context.slicePlaneEnabled,isClosed:!0,stipplePattern:i,stippleScaleWithLineWidth:!0,cap:D(e.patternCap||"butt")})};this._outlineMaterial=i(o(e.size)),this._context.stage.add(this._outlineMaterial)}_isValidOutline(e){return t(e)&&e.size&&e.size>0&&t(e.color)&&(r(e.pattern)||"style"!==e.pattern.type||"none"!==e.pattern.style)}destroy(){super.destroy(),this._context.stage.remove(this._material),this._material=null,this._context.stage.remove(this._outlineMaterial),this._outlineMaterial=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,H,this.symbolLayer.type))return null;const i=this._getVertexOpacityAndColor(e.renderingInfo,255),r=this.setGraphicElevationContext(t,new b);return this.ensureDrapedStatus("on-the-ground"===r.mode),this._ensureMaterials(),this.draped?this._createAsOverlay(t,i):this._createAs3DShape(t,i,r)}layerOpacityChanged(){if(t(this._material)){const e=this._material.parameters.color,t=i(this.symbolLayer,"material","color"),r=this._getCombinedOpacity(t);this._material.setParameters({color:[e[0],e[1],e[2],r],transparent:r<1||this.needsDrivenTransparentPass})}if(t(this._outlineMaterial)){const e=this._outlineMaterial.parameters.color;this._outlineMaterial.setParameters({color:[e[0],e[1],e[2],this._getOutlineOpacity()]})}return!0}layerElevationInfoChanged(e,t,i){const r=this._elevationContext.mode,n=f(W.elevationModeChangeTypes,i,r);if(n!==g.UPDATE)return n;const o=x(r);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>o))}slicePlaneEnabledChanged(){if(t(this._material)&&this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),t(this._outlineMaterial)){const e={hasSlicePlane:this._context.slicePlaneEnabled};this._outlineMaterial.setParameters(e)}return!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!0}_createAs3DShape(e,t,i){const n=U(e.geometry);if(r(n))return null;z.renderData=P(n,this._context.elevationProvider,this._context.renderCoordsHelper,i),z.color=t;const o=z.renderData.position.length/3;if(this._needsUV&&(z.uvMapSpace=new Float32Array(4*o),z.boundingRect=new Float64Array(9*o)),z.outNum=0,z.outGeometries=[],z.outTransforms=[],z.outMaterials=[],this._createAs3DShapeFill(z),this._hasOutline&&this._createAs3DShapeOutline(z),this._logGeometryCreationWarnings(z.renderData,n.rings,"rings","FillSymbol3DLayer"),0===z.outNum)return null;this._needsUV&&j(y.fromTypedArray(z.uvMapSpace),_.fromTypedArray(z.renderData.position),this._context.renderCoordsHelper,m.fromTypedArray(z.boundingRect));const a=new B({geometries:z.outGeometries,materials:z.outMaterials,transformations:z.outTransforms,castShadow:!1,metadata:{layerUid:this._context.layer.uid,graphicUid:e.uid}}),s=new M(this,a,z.outGeometries,null,null,T,i);return s.alignedSampledElevation=z.renderData.sampledElevation,s.needsElevationUpdates=x(i.mode),s}_createAs3DShapeFill(e){const i=e.renderData.polygons;for(const{position:r,mapPosition:o,holeIndices:l,index:u,count:d}of i){if(t(this._context.clippingExtent)&&(h(k),c(k,o),!p(k,this._context.clippingExtent)))continue;const i=a(o,l,3);if(0===i.length)continue;const m=new Uint32Array(i),_=C({indices:m,attributeData:{position:r,color:e.color,mapPosition:o,uvMapSpace:this._needsUV?new Float32Array(e.uvMapSpace.buffer,4*u*e.uvMapSpace.BYTES_PER_ELEMENT,4*d):null,boundingRect:this._needsUV?new Float64Array(e.boundingRect.buffer,9*u*e.boundingRect.BYTES_PER_ELEMENT,9*d):null}});e.outGeometries.push(_),e.outMaterials.push(n(this._material)),e.outTransforms.push(s),e.outNum++}}_createAs3DShapeOutline(e){if(!this._hasOutline)return;const i=e.renderData.outlines;for(let r=0;r<i.length;++r){const{mapPosition:o,position:a}=i[r];if(t(this._context.clippingExtent)&&(h(k),c(k,o),!p(k,this._context.clippingExtent)))continue;const l=S({overlayInfo:null,removeDuplicateStartEnd:A.REMOVE,attributeData:{position:a,mapPosition:o}}),u=l.vertexAttributes.get(N.POSITION);u.data===a&&(u.data=new Float64Array(a)),e.outGeometries.push(l),e.outMaterials.push(n(this._outlineMaterial)),e.outTransforms.push(s),e.outNum++}}_createAsOverlay(e,i){const o=U(e.geometry);if(r(o))return null;n(this._material).renderPriority=this._renderPriority+this._renderPriorityStep/2,t(this._outlineMaterial)&&(this._outlineMaterial.renderPriority=this._renderPriority),Y.renderData=w(o,this._context.overlaySR),Y.color=i;const a=Y.renderData.position.length/3;return this._needsUV&&(Y.uvMapSpace=new Float32Array(4*a)),Y.outNum=0,Y.outGeometries=[],Y.outBoundingBox=h(),Y.layerUid=this._context.layer.uid,Y.graphicsUid=e.uid,this._createAsOverlayFill(Y),this._hasOutline&&this._createAsOverlayOutline(Y),this._logGeometryCreationWarnings(Y.renderData,o.rings,"rings","FillSymbol3DLayer"),0===Y.outNum?null:(this._needsUV&&R(y.fromTypedArray(Y.uvMapSpace),_.fromTypedArray(Y.renderData.position),this._context.overlaySR,this._context.graphicsCoreOwner.view.state.viewingMode),Y.outNum>0?new v(this,Y.outGeometries,Y.outBoundingBox,this._context.drapeSourceRenderer):null)}_createAsOverlayFill(e){const t=e.renderData.polygons;for(const{position:i,holeIndices:r,index:o,count:s}of t){if(h(k),c(k,i),!p(k,this._context.clippingExtent))continue;const t=a(i,r,3);if(0===t.length)continue;d(e.outBoundingBox,k);const u=new Uint32Array(t),m=C({indices:u,attributeData:{position:i,color:e.color,uvMapSpace:this._needsUV?new Float32Array(e.uvMapSpace.buffer,4*o*e.uvMapSpace.BYTES_PER_ELEMENT,4*s):null}}),_=new L(m,n(this._material),{layerUid:e.layerUid,graphicUid:e.graphicsUid}),y=k;l(_.boundingSphere,.5*(y[0]+y[3]),.5*(y[1]+y[4]),0,.5*Math.sqrt((y[3]-y[0])*(y[3]-y[0])+(y[4]-y[1])*(y[4]-y[1]))),e.outGeometries.push(_),e.outNum++}}_createAsOverlayOutline(e){if(!this._hasOutline)return;const t=e.renderData.outlines;for(let i=0;i<t.length;++i){const{position:r}=t[i];if(h(k),c(k,r),!p(k,this._context.clippingExtent))continue;d(e.outBoundingBox,k);const o=S({overlayInfo:{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper},removeDuplicateStartEnd:A.REMOVE,attributeData:{position:r}}),a=new L(o,n(this._outlineMaterial),{layerUid:e.layerUid,graphicUid:e.graphicsUid}),s=k;l(a.boundingSphere,.5*(s[0]+s[3]),.5*(s[1]+s[4]),0,.5*Math.sqrt((s[3]-s[0])*(s[3]-s[0])+(s[4]-s[1])*(s[4]-s[1]))),e.outGeometries.push(a),e.outNum++}}_getOutlineOpacity(){const e=i(this.symbolLayer,"outline","color");return(this.draped?1:this._getLayerOpacity())*(t(e)?e.a:0)}_getOutlineColor(){const r=i(this.symbolLayer,"outline","color"),n=this._getOutlineOpacity();return O(t(r)?e.toUnitRGB(r):null,n)}test(){return{...super.test(),createAsOverlay:(e,t)=>this._createAsOverlay(e,t),createAs3DShape:(e,t,i)=>this._createAs3DShape(e,t,i)}}}W.elevationModeChangeTypes={definedChanged:g.RECREATE,staysOnTheGround:g.NONE,onTheGroundChanged:g.RECREATE};const k=u(),z={renderData:null,color:null,uvMapSpace:null,boundingRect:null,outNum:0,outBoundingBox:null,outGeometries:null,outMaterials:null,outTransforms:null},Y={renderData:null,color:null,uvMapSpace:null,outNum:0,outBoundingBox:null,outGeometries:null,outMaterials:null,outTransforms:null};export{W as Graphics3DPolygonFillSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import{isSome as t,get as i,isNone as r,unwrap as n}from"../../../../core/maybe.js";import{pt2px as o}from"../../../../core/screenUtils.js";import{e as a}from"../../../../chunks/earcut.js";import{I as s}from"../../../../chunks/mat4f64.js";import{s as l}from"../../../../chunks/vec4.js";import{create as u,empty as c,expandWithBuffer as h,intersectsClippingArea as p,expandWithAABB as d}from"../../../../geometry/support/aaBoundingBox.js";import{BufferViewMat3f64 as m,BufferViewVec3f64 as _,BufferViewVec4f as y}from"../../../../geometry/support/buffer/BufferView.js";import{SymbolUpdateType as g,elevationModeChangeUpdateType as f,needsElevationUpdates2D as x}from"./elevationAlignmentUtils.js";import{ElevationContext as b}from"./ElevationContext.js";import v from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as M}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as O}from"./Graphics3DSymbolLayer.js";import{mixinColorAndOpacity as E}from"./graphicUtils.js";import{createGeometry as D,RemoveDuplicateStartEnd as S,parseCapType as A}from"./lineUtils.js";import{geometryAsPolygon as U,geometryToRenderInfo as C,createColorGeometry as P,geometryToRenderInfoDraped as w}from"./polygonUtils.js";import{createMaterial as j,uvElevationAligner as G}from"../support/patternUtils.js";import{createMapSpaceUVCoords as T,createMapSpaceUVCoordsDraped as R}from"../support/uvUtils.js";import{Object3D as L}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as B}from"../../webgl-engine/lib/RenderGeometry.js";import{VertexAttribute as V}from"../../webgl-engine/lib/VertexAttribute.js";import{getStipplePatternForLinePattern as N}from"../../webgl-engine/materials/lineStippleUtils.js";import{PatternMaterial as F}from"../../webgl-engine/materials/PatternMaterial.js";import{RibbonLineMaterial as I}from"../../webgl-engine/materials/RibbonLineMaterial.js";const H=["polyline","polygon","extent"];class W extends O{constructor(e,t,i,r){super(e,t,i,r),this._needsUV=!1,this._hasOutline=!1}async doLoad(){}_ensureMaterials(){this._ensureFillMaterial(),this._ensureOutlineMaterial()}_ensureFillMaterial(){if(t(this._material))return;const e=i(this.symbolLayer,"material","color"),r=this._getCombinedOpacityAndColor(e);this._material=j(this.symbolLayer,{color:r,transparent:r[3]<1||this.needsDrivenTransparentPass,polygonOffset:!1,hasVertexColors:!0,writeLinearDepth:!0,hasSlicePlane:this._context.slicePlaneEnabled},{isDraped:this.draped}),this._needsUV=this._material instanceof F,this._context.stage.add(this._material)}_ensureOutlineMaterial(){const e=this.symbolLayer.outline;if(t(this._outlineMaterial)||!this._isValidOutline(e))return;this._hasOutline=!0;const i=t=>{const i=N(e.pattern);return new I({width:t,color:this._getOutlineColor(),hasPolygonOffset:!0,hasSlicePlane:this._context.slicePlaneEnabled,isClosed:!0,stipplePattern:i,stippleScaleWithLineWidth:!0,cap:A(e.patternCap||"butt")})};this._outlineMaterial=i(o(e.size)),this._context.stage.add(this._outlineMaterial)}_isValidOutline(e){return t(e)&&e.size&&e.size>0&&t(e.color)&&(r(e.pattern)||"style"!==e.pattern.type||"none"!==e.pattern.style)}destroy(){super.destroy(),this._context.stage.remove(this._material),this._material=null,this._context.stage.remove(this._outlineMaterial),this._outlineMaterial=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,H,this.symbolLayer.type))return null;const i=this._getVertexOpacityAndColor(e.renderingInfo,255),r=this.setGraphicElevationContext(t,new b);return this.ensureDrapedStatus("on-the-ground"===r.mode),this._ensureMaterials(),this.draped?this._createAsOverlay(t,i):this._createAs3DShape(t,i,r)}layerOpacityChanged(){if(t(this._material)){const e=this._material.parameters.color,t=i(this.symbolLayer,"material","color"),r=this._getCombinedOpacity(t);this._material.setParameters({color:[e[0],e[1],e[2],r],transparent:r<1||this.needsDrivenTransparentPass})}if(t(this._outlineMaterial)){const e=this._outlineMaterial.parameters.color;this._outlineMaterial.setParameters({color:[e[0],e[1],e[2],this._getOutlineOpacity()]})}return!0}layerElevationInfoChanged(e,t,i){const r=this._elevationContext.mode,n=f(W.elevationModeChangeTypes,i,r);if(n!==g.UPDATE)return n;const o=x(r);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>o))}slicePlaneEnabledChanged(){if(t(this._material)&&this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),t(this._outlineMaterial)){const e={hasSlicePlane:this._context.slicePlaneEnabled};this._outlineMaterial.setParameters(e)}return!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!0}_createAs3DShape(e,t,i){const n=U(e.geometry);if(r(n))return null;z.renderData=C(n,this._context.elevationProvider,this._context.renderCoordsHelper,i),z.color=t;const o=z.renderData.position.length/3;if(this._needsUV&&(z.uvMapSpace=new Float32Array(4*o),z.boundingRect=new Float64Array(9*o)),z.outNum=0,z.outGeometries=[],z.outTransforms=[],z.outMaterials=[],this._createAs3DShapeFill(z),this._hasOutline&&this._createAs3DShapeOutline(z,e.uid),this._logGeometryCreationWarnings(z.renderData,n.rings,"rings","FillSymbol3DLayer"),0===z.outNum)return null;this._needsUV&&T(y.fromTypedArray(z.uvMapSpace),_.fromTypedArray(z.renderData.position),this._context.renderCoordsHelper,m.fromTypedArray(z.boundingRect));const a=new L({geometries:z.outGeometries,materials:z.outMaterials,transformations:z.outTransforms,castShadow:!1,metadata:{layerUid:this._context.layer.uid,graphicUid:e.uid}}),s=new M(this,a,z.outGeometries,null,null,G,i);return s.alignedSampledElevation=z.renderData.sampledElevation,s.needsElevationUpdates=x(i.mode),s}_createAs3DShapeFill(e){const i=e.renderData.polygons;for(const{position:r,mapPosition:o,holeIndices:l,index:u,count:d}of i){if(t(this._context.clippingExtent)&&(c(k),h(k,o),!p(k,this._context.clippingExtent)))continue;const i=a(o,l,3);if(0===i.length)continue;const m=new Uint32Array(i),_=P({indices:m,attributeData:{position:r,color:e.color,mapPosition:o,uvMapSpace:this._needsUV?new Float32Array(e.uvMapSpace.buffer,4*u*e.uvMapSpace.BYTES_PER_ELEMENT,4*d):null,boundingRect:this._needsUV?new Float64Array(e.boundingRect.buffer,9*u*e.boundingRect.BYTES_PER_ELEMENT,9*d):null}});e.outGeometries.push(_),e.outMaterials.push(n(this._material)),e.outTransforms.push(s),e.outNum++}}_createAs3DShapeOutline(e,i){if(!this._hasOutline)return;const r=e.renderData.outlines;for(let o=0;o<r.length;++o){const{mapPosition:a,position:l}=r[o];if(t(this._context.clippingExtent)&&(c(k),h(k,a),!p(k,this._context.clippingExtent)))continue;const u=this._context.stage.renderView._getObjectAndLayerIdColor({graphicUid:i,layerUid:this._context.layer.uid}),d=D({overlayInfo:null,removeDuplicateStartEnd:S.REMOVE,attributeData:{position:l,mapPosition:a}},u),m=d.vertexAttributes.get(V.POSITION);m.data===l&&(m.data=new Float64Array(l)),e.outGeometries.push(d),e.outMaterials.push(n(this._outlineMaterial)),e.outTransforms.push(s),e.outNum++}}_createAsOverlay(e,i){const o=U(e.geometry);if(r(o))return null;n(this._material).renderPriority=this._renderPriority+this._renderPriorityStep/2,t(this._outlineMaterial)&&(this._outlineMaterial.renderPriority=this._renderPriority),Y.renderData=w(o,this._context.overlaySR),Y.color=i;const a=Y.renderData.position.length/3;return this._needsUV&&(Y.uvMapSpace=new Float32Array(4*a)),Y.outNum=0,Y.outGeometries=[],Y.outBoundingBox=c(),Y.layerUid=this._context.layer.uid,Y.graphicsUid=e.uid,this._createAsOverlayFill(Y),this._hasOutline&&this._createAsOverlayOutline(Y,e.uid),this._logGeometryCreationWarnings(Y.renderData,o.rings,"rings","FillSymbol3DLayer"),0===Y.outNum?null:(this._needsUV&&R(y.fromTypedArray(Y.uvMapSpace),_.fromTypedArray(Y.renderData.position),this._context.overlaySR,this._context.graphicsCoreOwner.view.state.viewingMode),Y.outNum>0?new v(this,Y.outGeometries,Y.outBoundingBox,this._context.drapeSourceRenderer):null)}_createAsOverlayFill(e){const t=e.renderData.polygons;for(const{position:i,holeIndices:r,index:o,count:s}of t){if(c(k),h(k,i),!p(k,this._context.clippingExtent))continue;const t=a(i,r,3);if(0===t.length)continue;d(e.outBoundingBox,k);const u=new Uint32Array(t),m=P({indices:u,attributeData:{position:i,color:e.color,uvMapSpace:this._needsUV?new Float32Array(e.uvMapSpace.buffer,4*o*e.uvMapSpace.BYTES_PER_ELEMENT,4*s):null}}),_=new B(m,n(this._material),{layerUid:e.layerUid,graphicUid:e.graphicsUid}),y=k;l(_.boundingSphere,.5*(y[0]+y[3]),.5*(y[1]+y[4]),0,.5*Math.sqrt((y[3]-y[0])*(y[3]-y[0])+(y[4]-y[1])*(y[4]-y[1]))),e.outGeometries.push(_),e.outNum++}}_createAsOverlayOutline(e,t){if(!this._hasOutline)return;const i=e.renderData.outlines;for(let r=0;r<i.length;++r){const{position:o}=i[r];if(c(k),h(k,o),!p(k,this._context.clippingExtent))continue;d(e.outBoundingBox,k);const a=this._context.stage.renderView._getObjectAndLayerIdColor({graphicUid:t,layerUid:this._context.layer.uid}),s=D({overlayInfo:{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper},removeDuplicateStartEnd:S.REMOVE,attributeData:{position:o}},a),u=new B(s,n(this._outlineMaterial),{layerUid:e.layerUid,graphicUid:e.graphicsUid}),m=k;l(u.boundingSphere,.5*(m[0]+m[3]),.5*(m[1]+m[4]),0,.5*Math.sqrt((m[3]-m[0])*(m[3]-m[0])+(m[4]-m[1])*(m[4]-m[1]))),e.outGeometries.push(u),e.outNum++}}_getOutlineOpacity(){const e=i(this.symbolLayer,"outline","color");return(this.draped?1:this._getLayerOpacity())*(t(e)?e.a:0)}_getOutlineColor(){const r=i(this.symbolLayer,"outline","color"),n=this._getOutlineOpacity();return E(t(r)?e.toUnitRGB(r):null,n)}test(){return{...super.test(),createAsOverlay:(e,t)=>this._createAsOverlay(e,t),createAs3DShape:(e,t,i)=>this._createAs3DShape(e,t,i)}}}W.elevationModeChangeTypes={definedChanged:g.RECREATE,staysOnTheGround:g.NONE,onTheGroundChanged:g.RECREATE};const k=u(),z={renderData:null,color:null,uvMapSpace:null,boundingRect:null,outNum:0,outBoundingBox:null,outGeometries:null,outMaterials:null,outTransforms:null},Y={renderData:null,color:null,uvMapSpace:null,outNum:0,outBoundingBox:null,outGeometries:null,outMaterials:null,outTransforms:null};export{W as Graphics3DPolygonFillSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../../core/has.js";import{isNone as t,isSome as e,unwrapOr as o}from"../../../../core/maybe.js";import{slice as n}from"../../../../core/typedArrayUtil.js";import{o as r}from"../../../../chunks/vec2.js";import{s as i}from"../../../../chunks/vec3.js";import{c as a}from"../../../../chunks/vec3f64.js";import{projectBuffer as s,lonLatToWebMercatorComparable as u}from"../../../../geometry/projection.js";import{getReferenceEllipsoid as c}from"../../../../geometry/projectionEllipsoid.js";import{CounterClockwiseMode as l,pathsToTriangulationInfo as p}from"../../../../geometry/support/triangulationUtils.js";import{ViewingMode as f}from"../../../ViewingMode.js";import{WHITE_UNIT as m}from"./constants.js";import{applyPerVertexElevationAlignment as h}from"./elevationAlignmentUtils.js";import{DRAPED_Z as E}from"../../terrain/OverlayRenderer.js";import{PrimitiveType as T}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as g}from"../../webgl-engine/lib/Geometry.js";import{VertexAttribute as y}from"../../webgl-engine/lib/VertexAttribute.js";import{CapType as A}from"../../webgl-engine/shaders/RibbonLineTechniqueConfiguration.js";function O(t){const
|
|
5
|
+
import"../../../../core/has.js";import{isNone as t,isSome as e,unwrapOr as o}from"../../../../core/maybe.js";import{slice as n}from"../../../../core/typedArrayUtil.js";import{o as r}from"../../../../chunks/vec2.js";import{s as i}from"../../../../chunks/vec3.js";import{c as a}from"../../../../chunks/vec3f64.js";import{projectBuffer as s,lonLatToWebMercatorComparable as u}from"../../../../geometry/projection.js";import{getReferenceEllipsoid as c}from"../../../../geometry/projectionEllipsoid.js";import{CounterClockwiseMode as l,pathsToTriangulationInfo as p}from"../../../../geometry/support/triangulationUtils.js";import{ViewingMode as f}from"../../../ViewingMode.js";import{WHITE_UNIT as m}from"./constants.js";import{applyPerVertexElevationAlignment as h}from"./elevationAlignmentUtils.js";import{DRAPED_Z as E}from"../../terrain/OverlayRenderer.js";import{PrimitiveType as T}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as g}from"../../webgl-engine/lib/Geometry.js";import{VertexAttribute as y}from"../../webgl-engine/lib/VertexAttribute.js";import{CapType as A}from"../../webgl-engine/shaders/RibbonLineTechniqueConfiguration.js";function O(t,e=null){const o=[],n=[];d(t,n,o);const r=n[0][1].data,i=o[0][1].length,a=new Uint16Array(i);return j(t,n,o),S(t,n,o,a),w(t,n,o,a),U(t,n,o,a),F(t,n,o,a),v(t,n,o,a),C(t,n,o,r),new g(n,o,T.Line,e)}function R(t,e,o,n){const r="polygon"===t.type?l.CCW_IS_HOLE:l.NONE,i="polygon"===t.type?t.rings:t.paths,{position:a,outlines:s}=p(i,t.hasZ,r),u=new Float64Array(a.length),c=h(a,t.spatialReference,0,u,0,a,0,a.length/3,e,o,n),f=null!=c;return{lines:f?b(s,a,u):[],projectionSuccess:f,sampledElevation:c}}function b(t,e,o){const n=new Array;for(const{index:r,count:i}of t){if(i<=1)continue;const t=3*r,a=t+3*i;n.push({position:e.subarray(t,a),mapPosition:o?o.subarray(t,a):void 0})}return n}function I(t,e){const o="polygon"===t.type?l.CCW_IS_HOLE:l.NONE,n="polygon"===t.type?t.rings:t.paths,{position:r,outlines:i}=p(n,!1,o),a=s(r,t.spatialReference,0,r,e,0,r.length/3);for(let s=2;s<r.length;s+=3)r[s]=E;return{lines:a?b(i,r):[],projectionSuccess:a}}function d(t,e,o){const{attributeData:{position:r},removeDuplicateStartEnd:i}=t,a=D(r)&&i===P.REMOVE,s=r.length/3-(a?1:0),u=new Uint32Array(2*(s-1)),c=a?n(r,0,r.length-3):r;let l=0;for(let n=0;n<s-1;n++)u[l++]=n,u[l++]=n+1;e.push([y.POSITION,{size:3,data:c,exclusive:a}]),o.push([y.POSITION,u])}function j(e,o,n){const r=e.attributeData.mapPosition;t(r)||(n.push([y.MAPPOS,n[0][1]]),o.push([y.MAPPOS,{size:3,data:r}]))}function S(t,n,r,i){if(e(t.attributeData.colorFeature))return;const a=t.attributeData.color;n.push([y.COLOR,{size:4,data:o(a,m)}]),r.push([y.COLOR,i])}function U(e,o,n,r){const i=e.attributeData.colorFeature;t(i)||(o.push([y.COLORFEATUREATTRIBUTE,{size:1,data:new Float32Array([i])}]),n.push([y.COLOR,r]))}function w(t,n,r,i){if(e(t.attributeData.sizeFeature))return;const a=t.attributeData.size;n.push([y.SIZE,{size:1,data:[o(a,1)]}]),r.push([y.SIZE,i])}function F(e,o,n,r){const i=e.attributeData.sizeFeature;t(i)||(o.push([y.SIZEFEATUREATTRIBUTE,{size:1,data:new Float32Array([i])}]),n.push([y.SIZEFEATUREATTRIBUTE,r]))}function v(e,o,n,r){const i=e.attributeData.opacityFeature;t(i)||(o.push([y.OPACITYFEATUREATTRIBUTE,{size:1,data:new Float32Array([i])}]),n.push([y.OPACITYFEATUREATTRIBUTE,r]))}function C(e,o,n,a){if(t(e.overlayInfo)||e.overlayInfo.renderCoordsHelper.viewingMode!==f.Global||!e.overlayInfo.spatialReference.isGeographic)return;const s=new Float64Array(a.length),l=c(e.overlayInfo.spatialReference);for(let t=0;t<s.length;t+=3)u(a,t,s,t,l);const p=a.length/3,m=new Float32Array(p+1);let h=z,E=N,T=0,g=0;i(h,s[g++],s[g++],s[g++]),m[0]=0;for(let t=1;t<p+1;++t)t===p&&(g=0),i(E,s[g++],s[g++],s[g++]),T+=r(h,E),m[t]=T,[h,E]=[E,h];o.push([y.DISTANCETOSTART,{size:1,data:m}]),n.push([y.DISTANCETOSTART,n[0][1]])}function D(t){const e=t.length;return t[0]===t[e-3]&&t[1]===t[e-2]&&t[2]===t[e-1]}var P;!function(t){t[t.KEEP=0]="KEEP",t[t.REMOVE=1]="REMOVE"}(P||(P={}));const z=a(),N=a();function L(t){switch(t){case"butt":return A.BUTT;case"square":return A.SQUARE;case"round":return A.ROUND;default:return null}}export{P as RemoveDuplicateStartEnd,O as createGeometry,R as geometryToRenderInfo,I as geometryToRenderInfoDraped,L as parseCapType};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isNone as t}from"../../../../core/maybe.js";import{t as e,a as o}from"../../../../chunks/vec3.js";import{c as r}from"../../../../chunks/vec3f64.js";import{projectBuffer as n}from"../../../../geometry/projection.js";import{create as a,set as m,
|
|
5
|
+
import{isNone as t}from"../../../../core/maybe.js";import{t as e,a as o}from"../../../../chunks/vec3.js";import{c as r}from"../../../../chunks/vec3f64.js";import{projectBuffer as n}from"../../../../geometry/projection.js";import{create as a,set as m,NEGATIVE_INFINITY as s,expandWithBuffer as c,ZERO as f}from"../../../../geometry/support/aaBoundingBox.js";function i(t,r,n,a){const m=r.getComponentAabb(n,t,p),s=r.getObjectTransform(n);for(let c=0;c<8;++c)b[0]=1&c?m[0]:m[3],b[1]=2&c?m[1]:m[4],b[2]=4&c?m[2]:m[5],e(b,b,s.rotationScale),o(b,b,s.position),a[3*c]=b[0],a[3*c+1]=b[1],a[3*c+2]=b[2];return a}function u(e,o,r){const a=new Float64Array(24);return u=>{let l=u.meta.featureExtents;if(t(l)){l=new Float64Array(6*u.meta.featureIds.length),u.meta.featureExtents=l;for(let t=0;t<l.length;t+=6)l[t]=Number.POSITIVE_INFINITY}const p=new Float64Array(l.buffer,6*u.index*Float64Array.BYTES_PER_ELEMENT,6);return p[0]===Number.POSITIVE_INFINITY&&(i(u.index,r,u.meta.objectHandle,a),n(a,o,0,a,e,0,8)?(m(p,s),c(p,a,0,8)):m(p,f)),p}}function l(t,r,n,a){const m=r.getComponentAabb(n,t,p),s=r.getObjectTransform(n);a[0]=0,a[1]=0,a[2]=0;for(let c=0;c<8;++c)b[0]=1&c?m[0]:m[3],b[1]=2&c?m[1]:m[4],b[2]=m[5],e(b,b,s.rotationScale),o(b,b,s.position),a[0]+=b[0],a[1]+=b[1],a[2]+=b[2];return a[0]/=8,a[1]/=8,a[2]/=8,a}const p=a(),b=r();export{i as boundingBoxCornerPoints,l as boundingBoxTop,u as createGetFeatureExtent};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isSome as e,isNone as t,unwrap as i}from"../../../../core/maybe.js";import s from"../../../../core/PooledArray.js";import{isAbortError as n}from"../../../../core/promiseUtils.js";import{l as r}from"../../../../chunks/vec3.js";import{b as o}from"../../../../chunks/vec4f64.js";import{LodMetric as a,NodeBase as d,Node as l,ElevationRange as h,NodeFilterImpact as u,NodeIMModificationImpact as c,NodeTraversalState as _}from"./I3SNode.js";import{addWraparound as g,invalidateMbs as m,invalidateObb as f}from"./I3SUtil.js";import{clone as v}from"../../support/orientedBoundingBox.js";class b{constructor(e,t,i,s,n){this.childOffset=e,this.childCount=t,this.visibilityCache=i,this.ref=s,this.node=n,this.useAsHole=0,this.filterImpact=u.NotChecked}}class p{constructor(e,t,i,n,r,o,d,l,h,u,c,_,g,m){this._streamDataController=i,this._viewportQueries=n,this._logger=r,this.holeFilling=o,this._isLoaded=d,this._isReloading=l,this._isSelected=h,this._enable=u,this._needsUpdate=c,this._canRequest=_,this._computeVisibilityObb=g,this._computeNodeFiltering=m,this._dirty=!0,this._nodePages=[],this._nodeCount=0,this._nodesPerPage=0,this._rootIndex=0,this._lodMetric=a.None,this._lodConversion=e=>e,this._urlPrefix="",this._loading=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.POSITIVE_INFINITY,this._nodeTraversalState=new Map,this._version=I(0),this._visibilityCacheVersion=I(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._missing=new s({deallocator:null}),this._prefetch=new s({deallocator:null}),this._updates=new N(this._missing),this._imModificationUncategorized=new s({deallocator:null}),this.ignoreServiceObb=!1,this.progressiveLoadPenalty=0,this._pageQueue=[],this.needNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._logLayer=e,e.serviceUpdateTimeStamp&&e.serviceUpdateTimeStamp.lastUpdate&&(this._lastUpdate=`${e.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,this._init(t)}_init(e){if("page"===e.type){switch(this._urlPrefix=e.urlPrefix,this._nodesPerPage=e.pageSize,this._rootIndex=e.rootIndex,e.lodMetric){case"maxScreenThreshold":this._lodMetric=a.MaxScreenThreshold;break;case"maxScreenThresholdSQ":this._lodMetric=a.MaxScreenThreshold,this._lodConversion=V}this._addPage(S(this._rootIndex,this._nodesPerPage),e.rootPage),this._updateParentsAndLevel()}else if("node"===e.type){this._urlPrefix=e.urlPrefix,this._nodePages.push({nodes:[],children:[],parents:[]}),this._makeRefNode(new d(e.rootNode.id,null),-1);const t=this._validateNode(e.rootNode.id,e.rootNode);t&&this._addNode(t,0)}}_loadPage(e){this._loading.add(e);const t=this._urlPrefix+e;this._streamDataController.request(t,"json").then((t=>{this._pageQueue.push({pageIndex:e,page:t})})).catch((t=>{this._loading.delete(e),n(t)||(this._failedPages.add(e),this._logger.error("#loadPage()",this._logLayer,`Error when loading page ${e}`,t))}))}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){const{pageIndex:t,page:i}=this._pageQueue.shift();this._addPage(t,i),this._loading.delete(t),e.madeProgress()}this._updateParentsAndLevel()}_addPage(e,t){for(let r=this._nodePages.length;r<e;r++)this._nodePages[r]=null;const i=[],s=[],n=t.nodes.map(((t,n)=>{const a=i.length,d=t.children?t.children.length:0;s.push(-1);for(let e=0;e<d;e++)i.push(t.children[e]);const h=`${t.index}`,u=v(t.obb),c=o([u.center[0],u.center[1],u.center[2],r(u.halfSize)]),_=t.mesh&&t.mesh.attribute,g=t.mesh&&t.mesh.geometry,m=t.mesh&&t.mesh.material,f={hasSharedResource:!1,hasFeatureData:!!g,attributes:_&&null!=_.resource?`${_.resource}`:null,geometry:g&&null!=g.resource?`${g.resource}`:null,texture:m&&null!=m.resource?`${m.resource}`:null,geometryDefinition:g?g.definition:-1,materialDefinition:m?m.definition:-1},p=new l(h,e*this._nodesPerPage+n,c,d,0,f,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),g?g.featureCount:null);return p.serviceObb=u,p.visibilityObb=this._computeVisibilityObb(p),p.vertexCount=g?g.vertexCount:0,new b(a,d,x(this._visibilityCacheVersion),null,p)}));this._nodePages[e]={nodes:n,children:i,parents:s},this._nodeCount+=n.length}_updateParentsAndLevel(){const t=new Array,i=(i,s,n)=>{const r=this._getPage(i);if(e(r)){const o=L(i,this._nodesPerPage);r.parents[o]=s;const a=r.nodes[o].node;e(a)&&(a.level=n,t.push(i))}};for(i(this._rootIndex,-1,0);t.length;){const s=t.pop(),n=this.getNode(s);if(e(n))for(let e=0;e<n.childCount;e++){i(this.getChildIndex(n.index,e),s,n.level+1),this._maxLevel=Math.max(this._maxLevel,n.level+1)}}}_getPage(e){return this._nodePages[S(e,this._nodesPerPage)]}_getNodeInternal(e){const i=this._getPage(e);return t(i)?null:i.nodes[L(e,this._nodesPerPage)]}_addNode(t,s){null!=t.children&&this.populateChildren(s,t.children);const n=this.getParent(s),r=e(n)?n.level+1:0;this._maxLevel=Math.max(this._maxLevel,t.children?r+1:r);const{lodMetric:a,maxError:d}=E(t.lodSelection),h=i(this._getNodeInternal(s));return h.node=new l(t.id,s,o(t.mbs),h.childCount,r,t.resources,t.version,a,d,t.numFeatures),t.obb&&(h.node.serviceObb=v(t.obb)),h.node.visibilityObb=this._computeVisibilityObb(h.node),e(h.ref)&&(null==h.ref.mbs&&(h.ref.mbs=t.mbs),h.node.renderMbs=h.ref.renderMbs,h.node.serviceObbInRenderSR=h.ref.serviceObbInRenderSR,h.ref.visibilityObb=h.node.visibilityObb),h.node}_makeRefNode(e,t){const i=this._nodePages[0],s=i.nodes.length;return i.nodes.push(new b(0,0,x(this._visibilityCacheVersion),e,null)),this._nodeCount++,i.parents.push(t),m(e.renderMbs),f(e.serviceObbInRenderSR),s}populateChildren(e,t){const s=i(this._getNodeInternal(e)),n=i(this._getPage(e));s.childOffset=n.children.length,s.childCount=t.length;for(let i=0;i<t.length;i++){const s=this._makeRefNode(t[i],e);n.children.push(s)}}getNode(t){const i=this._getNodeInternal(t);return e(i)?i.node:null}getIndexById(t){let i;return this._forAllNodes(((s,n)=>{(e(s.node)&&s.node.id===t||e(s.ref)&&s.ref.id===t)&&(i=n)})),i}getNodeById(e){const t=this.getIndexById(e);return t>=0?this.getNode(t):null}getChildIndex(e,i){const s=this._getPage(e);if(t(s))return-1;const n=s.nodes[L(e,this._nodesPerPage)];return s.children[n.childOffset+i]}getParentIndex(t){const i=this._getPage(t);return e(i)?i.parents[L(t,this._nodesPerPage)]:-1}getParent(e){return(e=this.getParentIndex(e))>=0?this.getNode(e):null}isLeaf(t){const i=this._getNodeInternal(t);return e(i)&&0===i.childCount}get rootNode(){return this.getNode(this._rootIndex)}get size(){return this._nodeCount}removeAllGeometryObbs(){this._forAllNodes((t=>{e(t.node)&&(t.node.geometryObb=null)}))}invalidateVisibilityCache(){this._visibilityCacheVersion=I(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(t){const i=this._getNodeInternal(t);e(i)&&this.invalidateNodeVisibilityCacheInternal(i)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=x(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(t){const i=this._getNodeInternal(t);e(i)&&(P(i),this.invalidateNodeVisibilityCacheInternal(i))}updateElevationChanged(i){const s=this._getNodeInternal(i);if(t(s))return;if(!this.needNodeElevationRange)return void this.invalidateBoundingVolumeCache(i);const n=e(s.node)?s.node:s.ref;if(t(n))return;const r=n.elevationRange;t(r)||(r.valid=!1)}invalidateGeometryVisibility(t){const i=this._getNodeInternal(t);e(i)&&e(i.node)&&(i.node.geometryObb=null,m(i.node.renderMbs),f(i.node.serviceObbInRenderSR))}invalidateVisibilityObbs(){t(this.rootNode)||this.traverse(this.rootNode,(e=>(e.visibilityObb=this._computeVisibilityObb(e),e.geometryObb=null,!0)))}_updateElevationRange(i){const s=this._getNodeInternal(i);if(t(s))return null;const n=e(s.node)?s.node:s.ref;if(t(n))return null;const r=n.elevationRange;if(e(r)&&r.valid)return r;const o=new h;let a=!1;for(let e=0;e<s.childCount;e++){const s=this._updateElevationRange(this.getChildIndex(i,e));t(s)?a=!0:(o.min=Math.min(o.min,s.min),o.max=Math.max(o.max,s.max))}if(0===s.childCount||a&&e(s.node)&&s.node.resources.geometry){const t=this._viewportQueries.getElevationRange(n);e(t)&&(o.min=Math.min(o.min,t.min),o.max=Math.max(o.max,t.max))}return e(r)&&r.min===o.min&&r.max===o.max?(r.valid=!0,r):(o.valid=!0,n.elevationRange=o,this.invalidateBoundingVolumeCache(i),o)}isNodeVisible(i){const s=this._getNodeInternal(i);if(t(s)||e(s.ref)&&!s.ref.mbs)return!0;if(this.needNodeElevationRange&&this._updateElevationRange(i),!w(s.visibilityCache,this._visibilityCacheVersion)){const i=s.node,n=e(i)&&(t(s.ref)||e(i.visibilityObb))?i:e(s.ref)?s.ref:null;if(this._layerHasFilter&&this._computeNodeFiltering&&(e(i)||e(s.ref))&&s.filterImpact===u.NotChecked){const t=e(i)?i.mbs:e(s.ref)?s.ref.mbs:null;s.filterImpact=null!=t?this._computeNodeFiltering(t):u.Unmodified}const r=e(i)&&s.filterImpact===u.Culled,o=!(e(i)&&i.imModificationImpact===c.Culled)&&(!n||this._viewportQueries.isNodeVisible(n))&&!r;return s.visibilityCache=C(o,this._visibilityCacheVersion),o}return M(s.visibilityCache)}isGeometryVisible(t){if(!this.isNodeVisible(t))return!1;const i=this._getNodeInternal(t);return!(e(i)&&e(i.node)&&e(i.node.geometryObb)&&(!this.layerHasModifications||i.node.imModificationImpact!==c.NotChecked))||this._viewportQueries.isGeometryVisible(i.node)}_traverseCoverage(s,n,r,o,a){const d=this._getPage(s);if(t(d)||0===n.childCount)return;const l=n.childOffset+n.childCount,h=new Array;for(let t=n.childOffset;t<l;++t){const i=d.children[t],s=this._getNodeInternal(i);e(s)&&e(s.node)&&this.isGeometryVisible(i)&&h.push(s)}o/=h.length;for(const e of h){const t=i(e.node).index;this._isLoaded(t)||this._isReloading(t)?(a.delta=Math.max(a.delta,r),a.coverage+=o):this._traverseCoverage(t,e,r+1,o,a)}}useNodeAsHole(e){if("off"===this.holeFilling)return!1;const i=this._getNodeInternal(e);if(t(i))return!1;if("always"===this.holeFilling)return!0;if(w(i.useAsHole,this._version))return M(i.useAsHole);const s={delta:0,coverage:0};this._traverseCoverage(e,i,0,1,s);const n=s.delta*s.coverage<=.5;return i.useAsHole=C(n,this._version),n}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.add.prune(),this._updates.update.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=I(this._version)}imModificationsChanged(t){this.layerHasModifications=t,this._forAllNodes((({node:t})=>{e(t)&&(t.imModificationImpact=c.NotChecked,t.visibilityObb=this._computeVisibilityObb(t),t.hasModifications&&this.invalidateGeometryVisibility(t.index))})),this.invalidateVisibilityCache()}layerFilterChanged(t){this._layerHasFilter=t,this._forAllNodes((t=>{if(e(t)){t.filterImpact=u.NotChecked;const i=t.node;e(i)&&this.invalidateNodeVisibilityCache(i.index)}})),this.invalidateVisibilityCache()}update(s,n,r){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(n),this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.NEGATIVE_INFINITY,this._missing.clear(),this._prefetch.clear(),this._updates.reset(s),y.clear();let o=!0;const a=new O,d=new O,l=this._imModificationUncategorized;l.clear();const h=new Set,u=(u,_,g)=>{if(t(_)){let e=this._entryPriority(u);e===1/0&&(e=this._entryPriority(g));const t=S(u,this._nodesPerPage);return y.set(t,Math.max(e,y.get(t)||0)),this._loading.has(t)||this._failedPages.has(t)||this._missing.push(t),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const m=_.node;if(this._updateNodeFeatureEstimate(m,d),t(m)){const e=this._entryPriority(u);return this._loading.has(u)||this._failedNodes.has(u)||(this._missing.push(u),y.set(u,e)),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const f=i(this._getPage(u));if(0===this._missing.length&&0===this._nodesPerPage)for(let t=0;t<_.childCount;t++){const i=f.children[_.childOffset+t],s=this._getNodeInternal(i);!e(s)||s.node||this._loading.has(i)||this._failedNodes.has(i)||(y.set(i,this._entryPriority(i)),this._prefetch.push(i))}if(m.failed||!m.resources.hasFeatureData)return void(o&&_.childCount>0&&this._isSelected(m)&&(o=!1));if(h.add(m.id),this._isLoaded(u)){if(a.known+=m.memory,++a.knownNodes,this._isSelected(m)?_.childCount>0&&(o=!1):(a.unremoved+=m.memory,o=!1),this._needsUpdate(m)){const e=this._entryPriority(u);y.set(u,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(u)}return}if(m.memory&&(a.known+=m.memory,++a.knownNodes),!this._isSelected(m))return void(this._isReloading(u)&&this._updates.remove.push(u));if(_.childCount>0&&(o=!1),m.memory?(a.missing+=m.memory,a.known+=m.memory,++a.knownNodes):++a.missingNodes,s.includes(m.index))return this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._entryPriority(u)),void(this._updates.cancel=this._updates.cancel.filter((e=>e!==m.index)));if(!n.done&&this._enable(m))return void n.madeProgress();const v=this._entryPriority(u);y.set(u,v),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,v),this._updates.add.push(u),this.layerHasModifications&&r&&e(m)&&m.imModificationImpact===c.NotChecked&&l.push(u)};this.traverseVisible(u);const _=this._updates.add;_.length>0&&this.layerHasModifications&&(l.length>0&&r(l),_.filterInPlace((e=>{const i=this._getNodeInternal(e),s=t(i)||t(i.node)||i.node.imModificationImpact!==c.Culled;return s||this.invalidateNodeVisibilityCache(e),s}))),this._unloadedMemoryEstimate=a.missing-a.unremoved,a.knownNodes>3&&a.missingNodes>0&&(this._unloadedMemoryEstimate+=a.known/a.knownNodes*a.missingNodes),this._unloadedMemoryEstimate=.8*Math.max(0,this._unloadedMemoryEstimate),this._featureEstimate.estimate=this._computeFeatureEstimate(d),this._featureEstimate.leavesReached=o,this._missing.sort(((e,t)=>e-t)),this._missing.filterInPlace(((e,t)=>t<1||this._missing.data[t-1]!==e)),this._missing.sort(((e,t)=>y.get(e)-y.get(t))),this._missing.length>0&&(this._maxUnloadedPrio=y.get(this._missing.back()),this._prefetch.clear()),this._updates.add.filterInPlace((e=>y.get(e)>=this._maxUnloadedPrio)).sort(((e,t)=>y.get(e)-y.get(t))),this._updates.update.sort(((e,t)=>y.get(e)-y.get(t))),this._indexMissing=this._loading.size+this._missing.length,this._dirty=this._indexMissing>0,y.clear()}checkFeatureTarget(e,t){const i=this._viewportQueries.updateScreenSpaceErrorBias(t);let s=t,n=t,r=i,o=10;for(;o--;){const i=new O;this._updateFeatureEstimate(s,i);if(this._computeFeatureEstimate(i)<=e){if(s>=t||i.missingNodes>0||0===o)break;r=s,s=.5*(s+n)}else n=s,s=.5*(s+r)}return this._version=I(this._version),this._viewportQueries.updateScreenSpaceErrorBias(i),Math.min(t,s)}_updateFeatureEstimate(t,i){this._version=I(this._version),this._viewportQueries.updateScreenSpaceErrorBias(t),this.traverseVisible(((t,s)=>this._updateNodeFeatureEstimate(e(s)&&s.node,i)))}_updateNodeFeatureEstimate(i,s){if(!(t(i)||i.failed||t(i.numFeatures)))return this._isLoaded(i.index)?(s.known+=i.numFeatures,++s.knownNodes,void(this._isSelected(i)||(s.unremoved+=i.numFeatures))):void(this._isSelected(i)&&(e(i.numFeatures)?(s.missing+=i.numFeatures,s.known+=i.numFeatures,++s.knownNodes):++s.missingNodes))}_computeFeatureEstimate(e){let t=e.known-e.unremoved;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.known/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._missing)}prefetch(){return this._prefetch.sort(((e,t)=>y.get(e)-y.get(t))),this._load(this._prefetch)}_load(e){if(0===e.length||!this._canRequest())return!1;for(;e.length>0&&this._canRequest();)0===this._nodesPerPage?this._loadNode(e.pop()):this._loadPage(e.pop());return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetch.length>0}get indexLoading(){return this._loading.size}get indexMissing(){return this._indexMissing}get unloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}get maxPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}nodeTraversalState(e){if(t(e))return null;let i=this._nodeTraversalState.get(e.index);if(i&&w(i.version,this._version))return i;const s=this._viewportQueries.getLodLevel(e),n=this._viewportQueries.hasLOD(e);let r=!0;if(n){const t=this.getParentIndex(e.index);if(t>=0){const e=this._nodeTraversalState.get(t);r=e&&s>e.lodLevel}else r=s>0}else r=0===e.childCount;return i?(i.lodLevel=s,i.isChosen=r,i.version=C(!0,this._version),i):(i=new _(n,r,s,C(!0,this._version)),this._nodeTraversalState.set(e.index,i),i)}_loadNode(e){this._loading.add(e);const s=i(this._getNodeInternal(e)).ref;if(t(s))return void this._failedNodes.add(e);const r=s.id,o=this._urlPrefix+r,a=()=>{this._loading.delete(e),0===this._missing.length&&0===this._loading.size&&this.requestUpdate()};this._streamDataController.request(o,"json").then((t=>{a();const i=this._validateNode(r,t);if(null==i)return;i.obb&&this.invalidateNodeVisibilityCache(e);const s=this._addNode(i,e);this.nodeTraversalState(s)}),(t=>{a(),n(t)||(this._logger.error("#loadNode()",this._logLayer,"Error loading node: "+o),this._failedNodes.add(e))}))}_validateNode(e,t){if(null==t||"object"!=typeof t||t.id!==e)return this._logger.error("#validateNode()",this._logLayer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this._logger.error("#validateNode()",this._logLayer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&"./shared"!==t.sharedResource.href&&"./shared/"!==t.sharedResource.href&&this._logger.warn("#validateNode()",this._logLayer,`Invalid shared resource href on node "${e}"`),null==t.geometryData||Array.isArray(t.geometryData)&&1===t.geometryData.length&&"./geometries/0"===t.geometryData[0].href||this._logger.warn("#validateNode()",this._logLayer,`Invalid geometry data on node "${e}"`),null==t.attributeData||Array.isArray(t.attributeData)&&!t.attributeData.some(((e,t)=>e.href!==`./attributes/f_${t}/0`))||this._logger.warn("#validateNode()",this._logLayer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this._logger.warn("#validateNode()",this._logLayer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);const i=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,s=t.featureData&&1===t.featureData.length&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:null,n=t=>{if(null==t)return null;const i=t=>this._logger.error("#validateNode()",this._logLayer,`Invalid node reference on node ${e}: ${t}`);if("number"==typeof t.id)i(`id ${t.id} is a number instead of a string.`);else if("string"!=typeof t.id||!Array.isArray(t.mbs))return i("Missing or invalid id."),null;if(!Array.isArray(t.mbs))return i(`Invalid bounding volume on reference ${t.id}.`),null;t.href&&t.href!=="../"+t.id&&this._logger.error("#validateNode()",this._logLayer,`Invalid node href on node "${e}"`);const s=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,n=new d(`${t.id}`,t.mbs);return n.serviceObb=s,n.visibilityObb=this._computeVisibilityObb(n),n},r=Array.isArray(t.children)?t.children.map(n).filter((e=>null!=e)):null;return{id:e,mbs:t.mbs,obb:i,children:r,resources:{hasFeatureData:t.featureData&&t.featureData.length>0,hasSharedResource:null!=t.sharedResource,attributes:t.attributeData?e:null,texture:t.textureData&&t.textureData.length>0?e:null,geometry:null!=t.geometryData?e:null},version:"string"==typeof t.version?t.version:null,lodSelection:Array.isArray(t.lodSelection)?t.lodSelection:null,numFeatures:s}}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes((t=>{e(t.node)&&(t.node.failed=!1)}))}_entryPriority(i){const s=this._getNodeInternal(i),n=this.getParentIndex(i);if(t(s)||n<0&&null==s.node)return n<0?1/0:this._entryPriority(n);let r=0;if(s.node&&n>=0){const e=this._nodeTraversalState.get(n);null!=e&&(r=e.lodLevel)}let o=this.progressiveLoadPenalty;for(let e=i;e>=0;e=this.getParentIndex(e))if(this._isLoaded(e)){o=0;break}const a=e(s.ref)?this._viewportQueries.distToPOI(s.ref):e(s.node)?this._viewportQueries.distToPOI(s.node):0;return-a-r*(a+this.progressiveLoadPenalty)+o}traverseVisible(e){const i=this._getNodeInternal(this._rootIndex);t(i)?e(this._rootIndex,null,null):this._traverseVisible(this._rootIndex,-1,i,e)}_traverseVisible(t,s,n,r){if(n.node&&0===n.childCount)return void(this.isGeometryVisible(t)&&r(t,n,s));if(!this.isNodeVisible(t))return;if(r(t,n,s),null==n.node)return;const o=this.nodeTraversalState(n.node);if(o.nodeHasLOD&&o.lodLevel===this._maxLodLevel)return;const a=i(this._getPage(t));for(let i=0;i<n.childCount;i++){const s=a.children[n.childOffset+i],o=this._getNodeInternal(s);e(o)?this._traverseVisible(s,t,o,r):r(s,null,t)}}traverse(e,t){t(e)&&this.traverseChildren(e,t)}traverseChildren(t,i){const s=t.index,n=this._getNodeInternal(s);e(n)&&this._traverseChildren(s,n,i)}_traverseChildren(i,s,n){const r=this._getPage(i);if(t(r))return;const o=s.childOffset+s.childCount;for(let t=s.childOffset;t<o;++t){const i=r.children[t],s=this._getNodeInternal(i);e(s)&&e(s.node)&&n(s.node)&&this._traverseChildren(i,s,n)}}updateChildrenLoaded(t,i){let s=this.getNode(t);for(;e(s);)s.childrenLoaded+=i,s=this.getParent(s.index)}checkChildrenLoadedInvariant(){if(t(this.rootNode))return!0;const e=[],i=t=>{let s=this._isLoaded(t.index)||this._isReloading(t.index)?1:0;return this.traverseChildren(t,(e=>(s+=i(e),!1))),t.childrenLoaded!==s&&e.push(t.index),s};return i(this.rootNode),e.length&&this._logger.error("childrenLoaded invariant broken at following nodes: "+e.join(",")),e.length>0}updateStats(e){if(this._updates.add.length>0&&(e.nodes+=" + "+this._updates.add.length),(this._indexMissing||this._prefetch.length>0)&&(e.index+=" + "+this._indexMissing||this._prefetch.length),e.prio=this._maxProcessingPrio,this._featureEstimate.estimate){const t=this._featureEstimate.estimate-e.features;t>0?e.features+=" + "+t:t<0&&(e.features+=" - "+-t)}}updateElevationInfo(t,i){this.needNodeElevationRange=i&&t&&("relative-to-ground"===t.mode||"on-the-ground"===t.mode),this._forAllNodes((t=>{P(t),e(t.node)&&(t.node.elevationRange=null),e(t.ref)&&(t.ref.elevationRange=null)})),this._viewportQueries.updateElevationInfo(t)}_forAllNodes(e){for(let t=0;t<this._nodePages.length;t++){const i=this._nodePages[t];if(i){const s=t*this._nodesPerPage;for(let t=0;t<i.nodes.length;t++)e(i.nodes[t],s+t)}}}get test(){return{addNode:(e,t)=>this._addNode(e,t)}}}const y=new Map;class N{constructor(e){this.missing=e,this.update=new s({deallocator:null}),this.add=new s({deallocator:null}),this.remove=new s({deallocator:null}),this.cancel=[]}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function P(t){e(t.node)&&(m(t.node.renderMbs),f(t.node.serviceObbInRenderSR)),e(t.ref)&&(m(t.ref.renderMbs),f(t.ref.serviceObbInRenderSR))}function x(e){return g(e,-2)}function I(e){return g(e,2)}function C(e,t){return t+(e?1:0)}function w(e,t){return(-2&e)===t}function M(e){return 1==(1&e)}function S(e,t){return 0===t?0:e/t|0}function L(e,t){return 0===t?e:e%t}const R=[["maxScreenThreshold",a.MaxScreenThreshold],["screenSpaceRelative",a.ScreenSpaceRelative],["removedFeatureDiameter",a.RemovedFeatureDiameter],["distanceRangeFromDefaultCamera",a.DistanceRangeFromDefaultCamera]];function E(e){if(e)for(let t=0;t<e.length;t++)for(const i of R)if(i[0]===e[t].metricType)return{lodMetric:i[1],maxError:e[t].maxError};return{lodMetric:a.None,maxError:0}}class O{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}function V(e){return Math.sqrt(e*(4/Math.PI))}export{p as I3SIndex,E as selectErrorMetric};
|
|
5
|
+
import{isSome as e,isNone as t,unwrap as i}from"../../../../core/maybe.js";import s from"../../../../core/PooledArray.js";import{isAbortError as n}from"../../../../core/promiseUtils.js";import{l as r}from"../../../../chunks/vec3.js";import{b as o}from"../../../../chunks/vec4f64.js";import{LodMetric as a,NodeBase as d,Node as l,ElevationRange as h,NodeFilterImpact as u,NodeIMModificationImpact as c,NodeTraversalState as _}from"./I3SNode.js";import{invalidateMbs as g,invalidateObb as m,addWraparound as f}from"./I3SUtil.js";import{clone as v}from"../../support/orientedBoundingBox.js";class b{constructor(e,t,i,s,n){this.childOffset=e,this.childCount=t,this.visibilityCache=i,this.ref=s,this.node=n,this.useAsHole=0,this.filterImpact=u.NotChecked}}class p{constructor(e,t,i,n,r,o,d,l,h,u,c,_,g,m){this._streamDataController=i,this._viewportQueries=n,this._logger=r,this.holeFilling=o,this._isLoaded=d,this._isReloading=l,this._isSelected=h,this._enable=u,this._needsUpdate=c,this._canRequest=_,this._computeVisibilityObb=g,this._computeNodeFiltering=m,this._dirty=!0,this._nodePages=[],this._nodeCount=0,this._nodesPerPage=0,this._rootIndex=0,this._lodMetric=a.None,this._lodConversion=e=>e,this._urlPrefix="",this._loading=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.POSITIVE_INFINITY,this._nodeTraversalState=new Map,this._version=I(0),this._visibilityCacheVersion=I(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._missing=new s({deallocator:null}),this._prefetch=new s({deallocator:null}),this._updates=new N(this._missing),this._imModificationUncategorized=new s({deallocator:null}),this.ignoreServiceObb=!1,this.progressiveLoadPenalty=0,this._pageQueue=[],this.needNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._logLayer=e,e.serviceUpdateTimeStamp&&e.serviceUpdateTimeStamp.lastUpdate&&(this._lastUpdate=`${e.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,this._init(t)}_init(e){if("page"===e.type){switch(this._urlPrefix=e.urlPrefix,this._nodesPerPage=e.pageSize,this._rootIndex=e.rootIndex,e.lodMetric){case"maxScreenThreshold":this._lodMetric=a.MaxScreenThreshold;break;case"maxScreenThresholdSQ":this._lodMetric=a.MaxScreenThreshold,this._lodConversion=V}this._addPage(S(this._rootIndex,this._nodesPerPage),e.rootPage),this._updateParentsAndLevel()}else if("node"===e.type){this._urlPrefix=e.urlPrefix,this._nodePages.push({nodes:[],children:[],parents:[]}),this._makeRefNode(new d(e.rootNode.id,null),-1);const t=this._validateNode(e.rootNode.id,e.rootNode);t&&this._addNode(t,0)}}_loadPage(e){this._loading.add(e);const t=this._urlPrefix+e;this._streamDataController.request(t,"json").then((t=>{this._pageQueue.push({pageIndex:e,page:t})})).catch((t=>{this._loading.delete(e),n(t)||(this._failedPages.add(e),this._logger.error("#loadPage()",this._logLayer,`Error when loading page ${e}`,t))}))}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){const{pageIndex:t,page:i}=this._pageQueue.shift();this._addPage(t,i),this._loading.delete(t),e.madeProgress()}this._updateParentsAndLevel()}_addPage(e,t){for(let r=this._nodePages.length;r<e;r++)this._nodePages[r]=null;const i=[],s=[],n=t.nodes.map(((t,n)=>{const a=i.length,d=t.children?t.children.length:0;s.push(-1);for(let e=0;e<d;e++)i.push(t.children[e]);const h=`${t.index}`,u=v(t.obb),c=o([u.center[0],u.center[1],u.center[2],r(u.halfSize)]),_=t.mesh&&t.mesh.attribute,g=t.mesh&&t.mesh.geometry,m=t.mesh&&t.mesh.material,f={hasSharedResource:!1,hasFeatureData:!!g,attributes:_&&null!=_.resource?`${_.resource}`:null,geometry:g&&null!=g.resource?`${g.resource}`:null,texture:m&&null!=m.resource?`${m.resource}`:null,geometryDefinition:g?g.definition:-1,materialDefinition:m?m.definition:-1},p=new l(h,e*this._nodesPerPage+n,c,d,0,f,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),g?g.featureCount:null);return p.serviceObb=u,p.visibilityObb=this._computeVisibilityObb(p),p.vertexCount=g?g.vertexCount:0,new b(a,d,x(this._visibilityCacheVersion),null,p)}));this._nodePages[e]={nodes:n,children:i,parents:s},this._nodeCount+=n.length}_updateParentsAndLevel(){const t=new Array,i=(i,s,n)=>{const r=this._getPage(i);if(e(r)){const o=L(i,this._nodesPerPage);r.parents[o]=s;const a=r.nodes[o].node;e(a)&&(a.level=n,t.push(i))}};for(i(this._rootIndex,-1,0);t.length;){const s=t.pop(),n=this.getNode(s);if(e(n))for(let e=0;e<n.childCount;e++){i(this.getChildIndex(n.index,e),s,n.level+1),this._maxLevel=Math.max(this._maxLevel,n.level+1)}}}_getPage(e){return this._nodePages[S(e,this._nodesPerPage)]}_getNodeInternal(e){const i=this._getPage(e);return t(i)?null:i.nodes[L(e,this._nodesPerPage)]}_addNode(t,s){null!=t.children&&this.populateChildren(s,t.children);const n=this.getParent(s),r=e(n)?n.level+1:0;this._maxLevel=Math.max(this._maxLevel,t.children?r+1:r);const{lodMetric:a,maxError:d}=E(t.lodSelection),h=i(this._getNodeInternal(s));return h.node=new l(t.id,s,o(t.mbs),h.childCount,r,t.resources,t.version,a,d,t.numFeatures),t.obb&&(h.node.serviceObb=v(t.obb)),h.node.visibilityObb=this._computeVisibilityObb(h.node),e(h.ref)&&(null==h.ref.mbs&&(h.ref.mbs=t.mbs),h.node.renderMbs=h.ref.renderMbs,h.node.serviceObbInRenderSR=h.ref.serviceObbInRenderSR,h.ref.visibilityObb=h.node.visibilityObb),h.node}_makeRefNode(e,t){const i=this._nodePages[0],s=i.nodes.length;return i.nodes.push(new b(0,0,x(this._visibilityCacheVersion),e,null)),this._nodeCount++,i.parents.push(t),g(e.renderMbs),m(e.serviceObbInRenderSR),s}populateChildren(e,t){const s=i(this._getNodeInternal(e)),n=i(this._getPage(e));s.childOffset=n.children.length,s.childCount=t.length;for(let i=0;i<t.length;i++){const s=this._makeRefNode(t[i],e);n.children.push(s)}}getNode(t){const i=this._getNodeInternal(t);return e(i)?i.node:null}getIndexById(t){let i;return this._forAllNodes(((s,n)=>{(e(s.node)&&s.node.id===t||e(s.ref)&&s.ref.id===t)&&(i=n)})),i}getNodeById(e){const t=this.getIndexById(e);return t>=0?this.getNode(t):null}getChildIndex(e,i){const s=this._getPage(e);if(t(s))return-1;const n=s.nodes[L(e,this._nodesPerPage)];return s.children[n.childOffset+i]}getParentIndex(t){const i=this._getPage(t);return e(i)?i.parents[L(t,this._nodesPerPage)]:-1}getParent(e){return(e=this.getParentIndex(e))>=0?this.getNode(e):null}isLeaf(t){const i=this._getNodeInternal(t);return e(i)&&0===i.childCount}get rootNode(){return this.getNode(this._rootIndex)}get size(){return this._nodeCount}removeAllGeometryObbs(){this._forAllNodes((t=>{e(t.node)&&(t.node.geometryObb=null)}))}invalidateVisibilityCache(){this._visibilityCacheVersion=I(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(t){const i=this._getNodeInternal(t);e(i)&&this.invalidateNodeVisibilityCacheInternal(i)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=x(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(t){const i=this._getNodeInternal(t);e(i)&&(P(i),this.invalidateNodeVisibilityCacheInternal(i))}updateElevationChanged(i){const s=this._getNodeInternal(i);if(t(s))return;if(!this.needNodeElevationRange)return void this.invalidateBoundingVolumeCache(i);const n=e(s.node)?s.node:s.ref;if(t(n))return;const r=n.elevationRange;t(r)||(r.valid=!1)}invalidateGeometryVisibility(t){const i=this._getNodeInternal(t);e(i)&&e(i.node)&&(i.node.geometryObb=null,g(i.node.renderMbs),m(i.node.serviceObbInRenderSR))}invalidateVisibilityObbs(){t(this.rootNode)||this.traverse(this.rootNode,(e=>(e.visibilityObb=this._computeVisibilityObb(e),e.geometryObb=null,!0)))}_updateElevationRange(i){const s=this._getNodeInternal(i);if(t(s))return null;const n=e(s.node)?s.node:s.ref;if(t(n))return null;const r=n.elevationRange;if(e(r)&&r.valid)return r;const o=new h;let a=!1;for(let e=0;e<s.childCount;e++){const s=this._updateElevationRange(this.getChildIndex(i,e));t(s)?a=!0:(o.min=Math.min(o.min,s.min),o.max=Math.max(o.max,s.max))}if(0===s.childCount||a&&e(s.node)&&s.node.resources.geometry){const t=this._viewportQueries.getElevationRange(n);e(t)&&(o.min=Math.min(o.min,t.min),o.max=Math.max(o.max,t.max))}return e(r)&&r.min===o.min&&r.max===o.max?(r.valid=!0,r):(o.valid=!0,n.elevationRange=o,this.invalidateBoundingVolumeCache(i),o)}isNodeVisible(i){const s=this._getNodeInternal(i);if(t(s)||e(s.ref)&&!s.ref.mbs)return!0;if(this.needNodeElevationRange&&this._updateElevationRange(i),!w(s.visibilityCache,this._visibilityCacheVersion)){const i=s.node,n=e(i)&&(t(s.ref)||e(i.visibilityObb))?i:e(s.ref)?s.ref:null;if(this._layerHasFilter&&this._computeNodeFiltering&&(e(i)||e(s.ref))&&s.filterImpact===u.NotChecked){const t=e(i)?i.mbs:e(s.ref)?s.ref.mbs:null;s.filterImpact=null!=t?this._computeNodeFiltering(t):u.Unmodified}const r=e(i)&&s.filterImpact===u.Culled,o=!(e(i)&&i.imModificationImpact===c.Culled)&&(!n||this._viewportQueries.isNodeVisible(n))&&!r;return s.visibilityCache=C(o,this._visibilityCacheVersion),o}return M(s.visibilityCache)}isGeometryVisible(t){if(!this.isNodeVisible(t))return!1;const i=this._getNodeInternal(t);return!(e(i)&&e(i.node)&&e(i.node.geometryObb)&&(!this.layerHasModifications||i.node.imModificationImpact!==c.NotChecked))||this._viewportQueries.isGeometryVisible(i.node)}_traverseCoverage(s,n,r,o,a){const d=this._getPage(s);if(t(d)||0===n.childCount)return;const l=n.childOffset+n.childCount,h=new Array;for(let t=n.childOffset;t<l;++t){const i=d.children[t],s=this._getNodeInternal(i);e(s)&&e(s.node)&&this.isGeometryVisible(i)&&h.push(s)}o/=h.length;for(const e of h){const t=i(e.node).index;this._isLoaded(t)||this._isReloading(t)?(a.delta=Math.max(a.delta,r),a.coverage+=o):this._traverseCoverage(t,e,r+1,o,a)}}useNodeAsHole(e){if("off"===this.holeFilling)return!1;const i=this._getNodeInternal(e);if(t(i))return!1;if("always"===this.holeFilling)return!0;if(w(i.useAsHole,this._version))return M(i.useAsHole);const s={delta:0,coverage:0};this._traverseCoverage(e,i,0,1,s);const n=s.delta*s.coverage<=.5;return i.useAsHole=C(n,this._version),n}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.add.prune(),this._updates.update.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=I(this._version)}imModificationsChanged(t){this.layerHasModifications=t,this._forAllNodes((({node:t})=>{e(t)&&(t.imModificationImpact=c.NotChecked,t.visibilityObb=this._computeVisibilityObb(t),t.hasModifications&&this.invalidateGeometryVisibility(t.index))})),this.invalidateVisibilityCache()}layerFilterChanged(t){this._layerHasFilter=t,this._forAllNodes((t=>{if(e(t)){t.filterImpact=u.NotChecked;const i=t.node;e(i)&&this.invalidateNodeVisibilityCache(i.index)}})),this.invalidateVisibilityCache()}update(s,n,r){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(n),this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.NEGATIVE_INFINITY,this._missing.clear(),this._prefetch.clear(),this._updates.reset(s),y.clear();let o=!0;const a=new O,d=new O,l=this._imModificationUncategorized;l.clear();const h=new Set,u=(u,_,g)=>{if(t(_)){let e=this._entryPriority(u);e===1/0&&(e=this._entryPriority(g));const t=S(u,this._nodesPerPage);return y.set(t,Math.max(e,y.get(t)||0)),this._loading.has(t)||this._failedPages.has(t)||this._missing.push(t),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const m=_.node;if(this._updateNodeFeatureEstimate(m,d),t(m)){const e=this._entryPriority(u);return this._loading.has(u)||this._failedNodes.has(u)||(this._missing.push(u),y.set(u,e)),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const f=i(this._getPage(u));if(0===this._missing.length&&0===this._nodesPerPage)for(let t=0;t<_.childCount;t++){const i=f.children[_.childOffset+t],s=this._getNodeInternal(i);!e(s)||s.node||this._loading.has(i)||this._failedNodes.has(i)||(y.set(i,this._entryPriority(i)),this._prefetch.push(i))}if(m.failed||!m.resources.hasFeatureData)return void(o&&_.childCount>0&&this._isSelected(m)&&(o=!1));if(h.add(m.id),this._isLoaded(u)){if(a.known+=m.memory,++a.knownNodes,this._isSelected(m)?_.childCount>0&&(o=!1):(a.unremoved+=m.memory,o=!1),this._needsUpdate(m)){const e=this._entryPriority(u);y.set(u,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(u)}return}if(m.memory&&(a.known+=m.memory,++a.knownNodes),!this._isSelected(m))return void(this._isReloading(u)&&this._updates.remove.push(u));if(_.childCount>0&&(o=!1),m.memory?(a.missing+=m.memory,a.known+=m.memory,++a.knownNodes):++a.missingNodes,s.includes(m.index))return this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._entryPriority(u)),void(this._updates.cancel=this._updates.cancel.filter((e=>e!==m.index)));if(!n.done&&this._enable(m))return void n.madeProgress();const v=this._entryPriority(u);y.set(u,v),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,v),this._updates.add.push(u),this.layerHasModifications&&r&&e(m)&&m.imModificationImpact===c.NotChecked&&l.push(u)};this.traverseVisible(u);const _=this._updates.add;_.length>0&&this.layerHasModifications&&(l.length>0&&r(l),_.filterInPlace((e=>{const i=this._getNodeInternal(e),s=t(i)||t(i.node)||i.node.imModificationImpact!==c.Culled;return s||this.invalidateNodeVisibilityCache(e),s}))),this._unloadedMemoryEstimate=a.missing-a.unremoved,a.knownNodes>3&&a.missingNodes>0&&(this._unloadedMemoryEstimate+=a.known/a.knownNodes*a.missingNodes),this._unloadedMemoryEstimate=.8*Math.max(0,this._unloadedMemoryEstimate),this._featureEstimate.estimate=this._computeFeatureEstimate(d),this._featureEstimate.leavesReached=o,this._missing.sort(((e,t)=>e-t)),this._missing.filterInPlace(((e,t)=>t<1||this._missing.data[t-1]!==e)),this._missing.sort(((e,t)=>y.get(e)-y.get(t))),this._missing.length>0&&(this._maxUnloadedPrio=y.get(this._missing.back()),this._prefetch.clear()),this._updates.add.filterInPlace((e=>y.get(e)>=this._maxUnloadedPrio)).sort(((e,t)=>y.get(e)-y.get(t))),this._updates.update.sort(((e,t)=>y.get(e)-y.get(t))),this._indexMissing=this._loading.size+this._missing.length,this._dirty=this._indexMissing>0,y.clear()}checkFeatureTarget(e,t){const i=this._viewportQueries.updateScreenSpaceErrorBias(t);let s=t,n=t,r=i,o=10;for(;o--;){const i=new O;this._updateFeatureEstimate(s,i);if(this._computeFeatureEstimate(i)<=e){if(s>=t||i.missingNodes>0||0===o)break;r=s,s=.5*(s+n)}else n=s,s=.5*(s+r)}return this._version=I(this._version),this._viewportQueries.updateScreenSpaceErrorBias(i),Math.min(t,s)}_updateFeatureEstimate(t,i){this._version=I(this._version),this._viewportQueries.updateScreenSpaceErrorBias(t),this.traverseVisible(((t,s)=>this._updateNodeFeatureEstimate(e(s)&&s.node,i)))}_updateNodeFeatureEstimate(i,s){if(!(t(i)||i.failed||t(i.numFeatures)))return this._isLoaded(i.index)?(s.known+=i.numFeatures,++s.knownNodes,void(this._isSelected(i)||(s.unremoved+=i.numFeatures))):void(this._isSelected(i)&&(e(i.numFeatures)?(s.missing+=i.numFeatures,s.known+=i.numFeatures,++s.knownNodes):++s.missingNodes))}_computeFeatureEstimate(e){let t=e.known-e.unremoved;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.known/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._missing)}prefetch(){return this._prefetch.sort(((e,t)=>y.get(e)-y.get(t))),this._load(this._prefetch)}_load(e){if(0===e.length||!this._canRequest())return!1;for(;e.length>0&&this._canRequest();)0===this._nodesPerPage?this._loadNode(e.pop()):this._loadPage(e.pop());return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetch.length>0}get indexLoading(){return this._loading.size}get indexMissing(){return this._indexMissing}get unloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}get maxPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}nodeTraversalState(e){if(t(e))return null;let i=this._nodeTraversalState.get(e.index);if(i&&w(i.version,this._version))return i;const s=this._viewportQueries.getLodLevel(e),n=this._viewportQueries.hasLOD(e);let r=!0;if(n){const t=this.getParentIndex(e.index);if(t>=0){const e=this._nodeTraversalState.get(t);r=e&&s>e.lodLevel}else r=s>0}else r=0===e.childCount;return i?(i.lodLevel=s,i.isChosen=r,i.version=C(!0,this._version),i):(i=new _(n,r,s,C(!0,this._version)),this._nodeTraversalState.set(e.index,i),i)}_loadNode(e){this._loading.add(e);const s=i(this._getNodeInternal(e)).ref;if(t(s))return void this._failedNodes.add(e);const r=s.id,o=this._urlPrefix+r,a=()=>{this._loading.delete(e),0===this._missing.length&&0===this._loading.size&&this.requestUpdate()};this._streamDataController.request(o,"json").then((t=>{a();const i=this._validateNode(r,t);if(null==i)return;i.obb&&this.invalidateNodeVisibilityCache(e);const s=this._addNode(i,e);this.nodeTraversalState(s)}),(t=>{a(),n(t)||(this._logger.error("#loadNode()",this._logLayer,"Error loading node: "+o),this._failedNodes.add(e))}))}_validateNode(e,t){if(null==t||"object"!=typeof t||t.id!==e)return this._logger.error("#validateNode()",this._logLayer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this._logger.error("#validateNode()",this._logLayer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&"./shared"!==t.sharedResource.href&&"./shared/"!==t.sharedResource.href&&this._logger.warn("#validateNode()",this._logLayer,`Invalid shared resource href on node "${e}"`),null==t.geometryData||Array.isArray(t.geometryData)&&1===t.geometryData.length&&"./geometries/0"===t.geometryData[0].href||this._logger.warn("#validateNode()",this._logLayer,`Invalid geometry data on node "${e}"`),null==t.attributeData||Array.isArray(t.attributeData)&&!t.attributeData.some(((e,t)=>e.href!==`./attributes/f_${t}/0`))||this._logger.warn("#validateNode()",this._logLayer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this._logger.warn("#validateNode()",this._logLayer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);const i=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,s=t.featureData&&1===t.featureData.length&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:null,n=t=>{if(null==t)return null;const i=t=>this._logger.error("#validateNode()",this._logLayer,`Invalid node reference on node ${e}: ${t}`);if("number"==typeof t.id)i(`id ${t.id} is a number instead of a string.`);else if("string"!=typeof t.id||!Array.isArray(t.mbs))return i("Missing or invalid id."),null;if(!Array.isArray(t.mbs))return i(`Invalid bounding volume on reference ${t.id}.`),null;t.href&&t.href!=="../"+t.id&&this._logger.error("#validateNode()",this._logLayer,`Invalid node href on node "${e}"`);const s=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,n=new d(`${t.id}`,t.mbs);return n.serviceObb=s,n.visibilityObb=this._computeVisibilityObb(n),n},r=Array.isArray(t.children)?t.children.map(n).filter((e=>null!=e)):null;return{id:e,mbs:t.mbs,obb:i,children:r,resources:{hasFeatureData:t.featureData&&t.featureData.length>0,hasSharedResource:null!=t.sharedResource,attributes:t.attributeData?e:null,texture:t.textureData&&t.textureData.length>0?e:null,geometry:null!=t.geometryData?e:null},version:"string"==typeof t.version?t.version:null,lodSelection:Array.isArray(t.lodSelection)?t.lodSelection:null,numFeatures:s}}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes((t=>{e(t.node)&&(t.node.failed=!1)}))}_entryPriority(i){const s=this._getNodeInternal(i),n=this.getParentIndex(i);if(t(s)||n<0&&null==s.node)return n<0?1/0:this._entryPriority(n);let r=0;if(s.node&&n>=0){const e=this._nodeTraversalState.get(n);null!=e&&(r=e.lodLevel)}let o=this.progressiveLoadPenalty;for(let e=i;e>=0;e=this.getParentIndex(e))if(this._isLoaded(e)){o=0;break}const a=e(s.ref)?this._viewportQueries.distToPOI(s.ref):e(s.node)?this._viewportQueries.distToPOI(s.node):0;return-a-r*(a+this.progressiveLoadPenalty)+o}traverseVisible(e){const i=this._getNodeInternal(this._rootIndex);t(i)?e(this._rootIndex,null,null):this._traverseVisible(this._rootIndex,-1,i,e)}_traverseVisible(t,s,n,r){if(n.node&&0===n.childCount)return void(this.isGeometryVisible(t)&&r(t,n,s));if(!this.isNodeVisible(t))return;if(r(t,n,s),null==n.node)return;const o=this.nodeTraversalState(n.node);if(o.nodeHasLOD&&o.lodLevel===this._maxLodLevel)return;const a=i(this._getPage(t));for(let i=0;i<n.childCount;i++){const s=a.children[n.childOffset+i],o=this._getNodeInternal(s);e(o)?this._traverseVisible(s,t,o,r):r(s,null,t)}}traverse(e,t){t(e)&&this.traverseChildren(e,t)}traverseChildren(t,i){const s=t.index,n=this._getNodeInternal(s);e(n)&&this._traverseChildren(s,n,i)}_traverseChildren(i,s,n){const r=this._getPage(i);if(t(r))return;const o=s.childOffset+s.childCount;for(let t=s.childOffset;t<o;++t){const i=r.children[t],s=this._getNodeInternal(i);e(s)&&e(s.node)&&n(s.node)&&this._traverseChildren(i,s,n)}}updateChildrenLoaded(t,i){let s=this.getNode(t);for(;e(s);)s.childrenLoaded+=i,s=this.getParent(s.index)}checkChildrenLoadedInvariant(){if(t(this.rootNode))return!0;const e=[],i=t=>{let s=this._isLoaded(t.index)||this._isReloading(t.index)?1:0;return this.traverseChildren(t,(e=>(s+=i(e),!1))),t.childrenLoaded!==s&&e.push(t.index),s};return i(this.rootNode),e.length&&this._logger.error("childrenLoaded invariant broken at following nodes: "+e.join(",")),e.length>0}updateStats(e){if(this._updates.add.length>0&&(e.nodes+=" + "+this._updates.add.length),(this._indexMissing||this._prefetch.length>0)&&(e.index+=" + "+this._indexMissing||this._prefetch.length),e.prio=this._maxProcessingPrio,this._featureEstimate.estimate){const t=this._featureEstimate.estimate-e.features;t>0?e.features+=" + "+t:t<0&&(e.features+=" - "+-t)}}updateElevationInfo(t,i){this.needNodeElevationRange=i&&t&&("relative-to-ground"===t.mode||"on-the-ground"===t.mode),this._forAllNodes((t=>{P(t),e(t.node)&&(t.node.elevationRange=null),e(t.ref)&&(t.ref.elevationRange=null)})),this._viewportQueries.updateElevationInfo(t)}_forAllNodes(e){for(let t=0;t<this._nodePages.length;t++){const i=this._nodePages[t];if(i){const s=t*this._nodesPerPage;for(let t=0;t<i.nodes.length;t++)e(i.nodes[t],s+t)}}}get test(){return{addNode:(e,t)=>this._addNode(e,t)}}}const y=new Map;class N{constructor(e){this.missing=e,this.update=new s({deallocator:null}),this.add=new s({deallocator:null}),this.remove=new s({deallocator:null}),this.cancel=[]}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function P(t){e(t.node)&&(g(t.node.renderMbs),m(t.node.serviceObbInRenderSR)),e(t.ref)&&(g(t.ref.renderMbs),m(t.ref.serviceObbInRenderSR))}function x(e){return f(e,-2)}function I(e){return f(e,2)}function C(e,t){return t+(e?1:0)}function w(e,t){return(-2&e)===t}function M(e){return 1==(1&e)}function S(e,t){return 0===t?0:e/t|0}function L(e,t){return 0===t?e:e%t}const R=[["maxScreenThreshold",a.MaxScreenThreshold],["screenSpaceRelative",a.ScreenSpaceRelative],["removedFeatureDiameter",a.RemovedFeatureDiameter],["distanceRangeFromDefaultCamera",a.DistanceRangeFromDefaultCamera]];function E(e){if(e)for(let t=0;t<e.length;t++)for(const i of R)if(i[0]===e[t].metricType)return{lodMetric:i[1],maxError:e[t].maxError};return{lodMetric:a.None,maxError:0}}class O{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}function V(e){return Math.sqrt(e*(4/Math.PI))}export{p as I3SIndex,E as selectErrorMetric};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{ByteSizeUnit as e}from"../../../../core/byteSizeEstimations.js";import t from"../../../../core/Error.js";import{isSome as s}from"../../../../core/maybe.js";import{onAbort as r,throwIfAborted as
|
|
5
|
+
import{ByteSizeUnit as e}from"../../../../core/byteSizeEstimations.js";import t from"../../../../core/Error.js";import{isSome as s}from"../../../../core/maybe.js";import{onAbort as r,throwIfAborted as o}from"../../../../core/promiseUtils.js";const i=14;class n{constructor(t,s,r=i){this._version=r,this._db=null,this._quotaReductionPromise=null,this._gcCounter=0,this._hit=0,this._miss=0,this._destroyed=!1,this.gcFrequency=50,this.maxByteSize=e.GIGABYTES,this.quotaReductionFactor=.2,this._dbName=t,this._storeName=s}init(){return Promise.resolve().then((()=>{const e=indexedDB.open(this._dbName,this._version);return e.onupgradeneeded=t=>{const s=e.result,r=e.transaction,o=s.objectStoreNames.contains(this._storeName)?r.objectStore(this._storeName):s.createObjectStore(this._storeName),i=s.objectStoreNames.contains("last_access")?r.objectStore("last_access"):s.createObjectStore("last_access");i.indexNames.contains("date")||i.createIndex("date","date",{unique:!1}),i.indexNames.contains("byteSize")||i.createIndex("byteSize","byteSize",{unique:!1}),t.oldVersion<this._version&&(o.clear(),i.clear())},a(e)})).then((e=>{this._destroyed?e.close():this._db=e}))}destroy(){this._db&&(this._db.close(),this._db=null),this._destroyed=!0}get initialized(){return null!=this._db}getHitRate(){return this._hit/(this._hit+this._miss)}put(e,s){if(null==this._db)return Promise.reject(new t("indexedb:not-initialized","IndexedDB Cache is not initialized"));return(null!=this._quotaReductionPromise?this._quotaReductionPromise:Promise.resolve()).then((()=>this._put(e,s))).catch((t=>{if(t&&"QuotaExceededError"===t.name)return null==this._quotaReductionPromise&&(this._quotaReductionPromise=this._getCacheSize().then((e=>this._removeLeastRecentlyAccessed(s.byteSize+Math.ceil(e*this.quotaReductionFactor)))),this._quotaReductionPromise.then((()=>this._quotaReductionPromise=null),(()=>this._quotaReductionPromise=null))),this._quotaReductionPromise.then((()=>this._put(e,s)));throw t})).then((()=>{this._gcCounter--,this._gcCounter<0&&null!=this._db&&(this._gcCounter=this.gcFrequency,this._getCacheSize().then((e=>this._removeLeastRecentlyAccessed(e-this.maxByteSize))))}))}get(e,t){const i=this._db;if(null==i)return Promise.resolve(void 0);let n=null;return Promise.resolve().then((()=>{const s=i.transaction(this._storeName,"readonly");n=r(t,(()=>{s.abort()}));return a(s.objectStore(this._storeName).get(e))})).then((t=>{if(null==t)++this._miss;else if(this._db){++this._hit;this._db.transaction("last_access","readwrite").objectStore("last_access").put({date:Date.now(),byteSize:t.byteSize},e)}return s(n)&&n.remove(),t})).catch((()=>{++this._miss,o(t),s(n)&&n.remove()}))}remove(e){const t=this._db;return null==t?Promise.resolve():Promise.resolve().then((async()=>{const s=t.transaction([this._storeName,"last_access"],"readwrite"),r=s.objectStore(this._storeName),o=s.objectStore("last_access"),i=r.delete(e),n=o.delete(e);await Promise.all([a(i),a(n),c(s)])}))}_put(e,t){const s=this._db;if(null==s)return Promise.resolve();const r=s.transaction([this._storeName,"last_access"],"readwrite"),o=r.objectStore(this._storeName),i=r.objectStore("last_access"),n=o.put(t,e),u=i.put({date:Date.now(),byteSize:t.byteSize},e);return Promise.all([a(n),a(u),c(r)])}_removeLeastRecentlyAccessed(e){if(e<=0||!this._db)return Promise.resolve();const t=this._db.transaction([this._storeName,"last_access"],"readwrite"),s=t.objectStore(this._storeName),r=t.objectStore("last_access");let o=0;const i=r.index("date").openCursor(null,"next");return i.onsuccess=()=>{const t=i.result;null!=t&&(null!=t.value.byteSize&&(o+=t.value.byteSize),s.delete(t.primaryKey),r.delete(t.primaryKey),o<e&&t.continue())},c(t)}_getCacheSize(){const e=this._db;if(null==e)return Promise.resolve(0);const t=e.transaction("last_access"),s=t.objectStore("last_access");let r=0;const o=s.index("byteSize").openKeyCursor();return o.onsuccess=()=>{const e=o.result;if(!e)return;const t=e.key;null!=t&&(r+=t),e.continue()},c(t).then((()=>r))}}function c(e){return new Promise(((t,s)=>{e.oncomplete=()=>t(),e.onerror=()=>s(e.error),e.onabort=()=>s(e.error)}))}function a(e){return new Promise(((t,s)=>{"done"===e.readyState?null!=e.error?s(e.error):t(e.result):(e.onsuccess=()=>t(e.result),e.onerror=()=>s(e.error))}))}export{n as IDBCache,a as whenRequest,c as whenTransaction};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
class t{constructor(){this._data=new Map,this._miss=0,this._hit=0,this.initialized=!0}init(){return Promise.resolve()}async get(t,
|
|
5
|
+
class t{constructor(){this._data=new Map,this._miss=0,this._hit=0,this.initialized=!0}init(){return Promise.resolve()}async get(t,i){if(this._data.has(t))return this._hit++,this._data.get(t)??void 0;this._miss++}destroy(){}put(t,i){return this._data.set(t,i),Promise.resolve()}remove(t){return this._data.delete(t),Promise.resolve()}getHitRate(){return this._hit/(this._hit+this._miss)}}export{t as IDBMockCache};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{
|
|
5
|
+
import{isNone as e,unwrap as t,disposeMaybe as s,isSome as i}from"../../../../core/maybe.js";import r from"../../../../core/PooledArray.js";import{b as n,l as o,g as a,o as h,e as l,p as c}from"../../../../chunks/vec3.js";import{c as d}from"../../../../chunks/vec3f64.js";import{s as u}from"../../../../chunks/vec4.js";import{create as p,offset as g,contains as m,containsPoint as _,set as f,POSITIVE_INFINITY as P,equals as b}from"../../../../geometry/support/aaBoundingBox.js";import{create as S}from"../../../../geometry/support/plane.js";import{fromPoints as x}from"../../../../geometry/support/ray.js";import{PointHighlights as z}from"./PointHighlights.js";import{minimumDistancePlane as R,maximumDistancePlane as q,intersectLine as w,toAaBoundingBox as y}from"../../support/orientedBoundingBox.js";import{ShaderOutput as A}from"../../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{Default3D as j}from"../../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{newIntersectorResult as I}from"../../webgl-engine/lib/Intersector.js";import{IntersectorType as F,StoreResults as v}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{VertexArrayObject as C}from"../../webgl-engine/lib/VertexArrayObject.js";import{VertexAttribute as E}from"../../webgl-engine/lib/VertexAttribute.js";import{P as H,a as N,g as O}from"../../../../chunks/PointRenderer.glsl.js";import{PointRendererTechnique as T}from"../../webgl-engine/shaders/PointRendererTechnique.js";import{PointRendererTechniqueConfiguration as L}from"../../webgl-engine/shaders/PointRendererTechniqueConfiguration.js";import{BufferObject as B}from"../../../webgl/BufferObject.js";import{DataType as D,PrimitiveType as M,Usage as U}from"../../../webgl/enums.js";import{VertexElementDescriptor as V}from"../../../webgl/VertexElementDescriptor.js";const W={positions:[new V(E.POSITION,3,D.FLOAT,0,12)],colors:[new V(E.COLOR,3,D.UNSIGNED_BYTE,0,3,!0)]};class k{constructor(e){this._params=e,this.type=F.PCL,this.isGround=!1,this._passParameters=new H,this._highlights=new z({forEachNode:e=>this.forEachNode(e),addHighlight:(e,t,s)=>this._addHighlight(e,t,s),removeHighlight:(e,t)=>this._removeHighlight(e,t)}),this.canRender=!0,this.layerUid="",this._slicePlaneEnabled=!1,this._techniqueConfig=new L,this._nodes=new r}get needsHighlight(){return this._highlights.hasHighlights}initializeRenderContext(e){this._context=e,this._techniqueRep=this._context.shaderTechniqueRepository,e.requestRender()}uninitializeRenderContext(){}intersect(e,t,s,i){const r=d(),f=d(),P=d(),b=d(),z=S(),A=e.camera.perScreenPixelRatio/2,j=e.camera.near;n(f,i,s);const F=1/o(f);a(f,f,F),h(P,f),u(z,f[0],f[1],f[2],-l(f,s));const C=new ee,E=new ee,H=new Array,N=p(),O=p(this._passParameters.clipBox);g(O,-s[0],-s[1],-s[2],O),this._nodes.forAll((o=>{const a=o.splatSize*this._passParameters.scaleFactor;let h=R(o.obb,z),d=q(o.obb,z);h-=K(a,h+j,this._passParameters,A,o.isLeaf),d-=K(a,d+j,this._passParameters,A,o.isLeaf);const u=d<0,p=null!=C.dist&&null!=E.dist&&C.dist<h*F&&E.dist>d*F;if(u||p)return;const S=J(a,d+j,this._passParameters,A,o.isLeaf);if(!w(o.obb,s,f,S))return;const x=S*S;y(o.obb,N),g(N,-s[0],-s[1],-s[2],N);const I=!m(O,N);n(b,o.origin,s);const T=o.coordinates.length/3;for(let n=0;n<T;n++){if(r[0]=b[0]+o.coordinates[3*n],r[1]=b[1]+o.coordinates[3*n+1],r[2]=b[2]+o.coordinates[3*n+2],I&&!_(O,r))continue;const h=l(r,f),d=c(r)-h*h;if(d>x)continue;let u=h+j;const p=K(a,u,this._passParameters,A,o.isLeaf);if(h-p<0)continue;u-=p;const g=J(a,u,this._passParameters,A,o.isLeaf);if(d>g*g)continue;const m=(h-p)*F,S=e=>(e.point=Q(o,n,e.point),e.dist=m,e.normal=P,e.node=o,e.pointId=n,e.layerUid=this.layerUid,e);if((null==C.dist||m<C.dist)&&(null==t||t(s,i,m))&&S(C),e.options.store!==v.MIN&&(null==E.dist||m>E.dist)&&(null==t||t(s,i,m))&&S(E),e.options.store===v.ALL&&(null==t||t(s,i,m))){const e=new ee;H.push(S(e))}}}));const T=e=>{const{layerUid:t,node:s,pointId:i}=e;return{point:e.point,layerUid:t,graphicUid:i,createGraphic:()=>this._params.createGraphic(s,i,e.point)}},L=(e,t)=>{const s=T(t);e.set(this.type,s,t.dist,t.normal)};if(te(C)){const t=e.results.min;(null==t.dist||C.dist<t.dist)&&L(t,C)}if(te(E)&&e.options.store!==v.MIN){const t=e.results.max;(null==t.dist||E.dist>t.dist)&&L(t,E)}if(e.options.store===v.ALL){const t=x(s,i);for(const s of H){const i=I(t);L(i,s),e.results.all.push(i)}}}prepareTechnique(e){return 0===this._nodes.length||e.output!==A.Color&&e.output!==A.Depth&&e.output!==A.Highlight?null:(this._nodes.forAll((t=>{null==t.vao&&this._initNode(e,t)})),this._techniqueConfig.drawScreenSize=this._passParameters.drawScreenSpace,this._techniqueConfig.useFixedSizes=this._passParameters.useFixedSizes,this._techniqueConfig.hasSlicePlane=this._slicePlaneEnabled,this._techniqueConfig.hasOccludees=e.bindParameters.hasOccludees,this._techniqueConfig.clippingEnabled=this._clippingEnabled,this._techniqueConfig.output=e.output===A.Depth?A.Depth:e.output===A.Highlight?A.Highlight:A.Color,this._techniqueRep.releaseAndAcquire(T,this._techniqueConfig,this._technique))}render(e,t){const s=e.rctx,i=s.bindTechnique(t,this._passParameters,e.bindParameters),r=e.output===A.Highlight;this._nodes.forAll((t=>{0===t.coordinates.length||r&&!t.highlights||(i.bindDraw(t,e.bindParameters,this._passParameters),s.bindVAO(t.vao),r?this._renderHighlightFragments(s,t):s.drawArrays(M.POINTS,0,t.coordinates.length/3))}))}_renderHighlightFragments(s,i){const r=i.highlights;if(e(r))return;let n=t(r[0].component),o=n+1;for(let e=1;e<r.length;e++){const i=t(r[e].component);if(i!==o){const e=o-n;e>0&&s.drawArrays(M.POINTS,n,e),n=i}o=i+1}const a=o-n;a>0&&s.drawArrays(M.POINTS,n,a)}set useFixedSizes(e){this._passParameters.useFixedSizes!==e&&(this._passParameters.useFixedSizes=e,this._requestRender())}get useFixedSizes(){return this._passParameters.useFixedSizes}set scaleFactor(e){this._passParameters.scaleFactor!==e&&(this._passParameters.scaleFactor=e,this._requestRender())}get scaleFactor(){return this._passParameters.scaleFactor}set minSizePx(e){this._passParameters.minSizePx!==e&&(this._passParameters.minSizePx=e,this._requestRender())}get minSizePx(){return this._passParameters.minSizePx}set useRealWorldSymbolSizes(e){this._passParameters.useRealWorldSymbolSizes!==e&&(this._passParameters.useRealWorldSymbolSizes=e,this._requestRender())}get useRealWorldSymbolSizes(){return this._passParameters.useRealWorldSymbolSizes}set size(e){this._passParameters.size!==e&&(this._passParameters.size=e,this._requestRender())}get size(){return this._passParameters.size}set sizePx(e){this._passParameters.sizePx!==e&&(this._passParameters.sizePx=e,this._requestRender())}get sizePx(){return this._passParameters.sizePx}set clippingBox(e){f(this._passParameters.clipBox,e||P)}get _clippingEnabled(){return!b(this._passParameters.clipBox,P,((e,t)=>e===t))}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this._requestRender())}addNode(e){this._nodes.push(e),this._highlights.nodeAdded(e),this._requestRender()}removeNode(e){let t=null;return this._nodes.filterInPlace((i=>i.id!==e||(t=i,i.vao=s(i.vao),this._highlights.nodeRemoved(i),!1))),this._requestRender(),t}forEachNode(e){this._nodes.forAll(e)}removeAll(){this._nodes.forAll((e=>e.vao=s(e.vao))),this._highlights.removeAll(),this._nodes.clear(),this._requestRender()}highlight(e){return this._highlights.add(e)}_addHighlight(e,t,s){e.highlights=Z(e.highlights,t,s),this._requestRender()}_removeHighlight(e,t){e.highlights=$(e.highlights,t),this._requestRender()}_initNode(e,t){const s=e.rctx;t.vao=new C(s,j,W,{positions:B.createVertex(s,U.STATIC_DRAW,t.coordinates),colors:B.createVertex(s,U.STATIC_DRAW,t.rgb)})}_requestRender(){this._context&&this._context.requestRender()}}class G extends N{constructor(e,t,s,i,r,n,o,a,h=null,l=null){super(s,r,t),this.id=e,this.obb=i,this.coordinates=n,this.rgb=o,this.attributes=a,this.pointIdFilterMap=h,this.highlights=l}}function Y(e){return e.hasOwnProperty("splatSize")}function J(e,t,s,i,r){if(s.drawScreenSpace)return s.fixedSize*t*i;const n=O(r)*t*i;return s.useFixedSizes?Math.min(s.fixedSize/2,n):s.screenMinSize>0?Math.min(Math.max(s.screenMinSize*t*i,e/2),n):Math.min(e/2,n)}function K(e,t,s,i,r){return s.drawScreenSpace?0:J(e,t,s,i,r)}function Q(t,s,i){return e(i)&&(i=d()),i[0]=t.origin[0]+t.coordinates[3*s],i[1]=t.origin[1]+t.coordinates[3*s+1],i[2]=t.origin[2]+t.coordinates[3*s+2],i}function X(e){return i(e.component)?e.component:-1}function Z(t,s,i){e(t)&&(t=[]);const r={component:s,id:i};t.push(r);const n=X(r);let o=t.length-1;for(;o>0&&n<X(t[o-1]);)[t[o-1],t[o]]=[t[o],t[o-1]],--o;return t}function $(t,s){if(e(t))return t;const i=t.filter((e=>e.id!==s));return 0===i.length?null:i}class ee{constructor(){this.node=null,this.pointId=null,this.point=null,this.dist=null,this.normal=null,this.layerUid=""}}function te(e){return i(e.dist)&&i(e.point)&&i(e.pointId)&&i(e.node)}export{k as PointRenderer,G as PointRendererNode,Y as isInstanceOfNode};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{isSome as t,isNone as s,destroyMaybe as o}from"../../../../core/maybe.js";import{throwIfAborted as u,createAbortError as a}from"../../../../core/promiseUtils.js";import{property as y}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import{fromFeatureSetJSON as p}from"../../../../layers/graphics/dehydratedFeatures.js";import{runQuery as c,executeQuery as n}from"../../../../rest/query/operations/query.js";import{PBFDecoder as l}from"../../support/PBFDecoder.js";let d=class extends r{constructor(e){super(e)}get queryFeaturesDehydrated(){const e=this.layer.capabilities,r=e&&e.query;if(r&&r.supportsFormatPBF){s(this._decoder)&&(this._decoder=new l(this.schedule));const e={sourceSpatialReference:this.layer.spatialReference?.toJSON()??null,applyTransform:!0,maxStringAttributeLength:1024};return(r,s)=>c(this.layer.parsedUrl,r,"pbf",this._createRequestOptions(s)).then((r=>(u(s),t(this._decoder)?this._decoder.invoke({buffer:r.data,options:e},s.signal):Promise.reject(a()))))}return(e,r)=>n(this.layer.parsedUrl,e,this.layer.spatialReference,this._createRequestOptions(r)).then((e=>p(e.data)))}queryFeatureCount(e,r){return this.layer.queryFeatureCount(e,r)}destroy(){this._decoder=o(this._decoder)}_createRequestOptions(e){return{...e,query:{...this.layer.customParameters,token:this.layer.apiKey,...e?.query}}}};e([y({constructOnly:!0})],d.prototype,"layer",void 0),e([y({constructOnly:!0})],d.prototype,"schedule",void 0),e([y({readOnly:!0})],d.prototype,"queryFeaturesDehydrated",null),d=e([i("esri.views.3d.layers.support.featureTileQuery3D.FeatureTileServiceQuery3D")],d);let h=class extends r{constructor(e){super(e)}queryFeaturesDehydrated(e,r){return this.layer.queryFeatures(e,r)}queryFeatureCount(e,r){return this.layer.queryFeatureCount(e,r)}};e([y({constructOnly:!0})],h.prototype,"layer",void 0),e([y({readOnly:!0})],h.prototype,"queryFeaturesDehydrated",null),h=e([i("esri.views.3d.layers.support.featureTileQuery3D.FeatureTileServiceMeshQuery3D")],h);let m=class extends r{constructor(e){super(e)}queryFeaturesDehydrated(e,r){return this.layer.queryFeatures(e,r)}};e([y({constructOnly:!0})],m.prototype,"layer",void 0),m=e([i("esri.views.3d.layers.support.featureTileQuery3D.FeatureTileServiceQuery3D")],m);let f=class extends r{constructor(e){super(e)}queryFeaturesDehydrated(e,r){return this.source.queryFeaturesJSON(e,r).then(p,(t=>{if(t&&"query-features-json:unsupported"===t.name)return this.layer.queryFeatures(e,r);throw t}))}queryFeatureCount(e,r){return this.layer.queryFeatureCount(e,r)}};function q(e,r){return"feature"===e.type&&"feature-layer"===e.source.type?t(e.infoFor3D)?new h({layer:e}):new d({layer:e,schedule:r}):"feature"===e.type&&"memory"===e.source.type||"csv"===e.type||"geojson"===e.type||"wfs"===e.type?new f({layer:e,source:e.source}):"ogc-feature"===e.type?new m({layer:e}):null}e([y({constructOnly:!0})],f.prototype,"layer",void 0),e([y({constructOnly:!0})],f.prototype,"source",void 0),f=e([i("esri.views.3d.layers.support.featureTileQuery3D.FeatureTileClientQuery3D")],f);export{q as createFeatureTileQuery3D};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.25/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{isSome as o}from"../../../core/maybe.js";import{watch as a,sync as i}from"../../../core/reactiveUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{afterDispatch as l}from"../../../core/accessorSupport/watch.js";import{f as p}from"../../../chunks/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../geometry/projectionEllipsoid.js";import m from"../../ViewAnimation.js";import{ViewingMode as h}from"../../ViewingMode.js";import{Constraints as d}from"./Constraints.js";import{AnimationController as u}from"./controllers/AnimationController.js";import{State as g}from"./controllers/CameraController.js";import{PropertiesPool as C}from"../support/PropertiesPool.js";import{Camera as _,PaddingSide as
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import r from"../../../core/Evented.js";import{isSome as o}from"../../../core/maybe.js";import{watch as a,sync as i}from"../../../core/reactiveUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{afterDispatch as l}from"../../../core/accessorSupport/watch.js";import{f as p}from"../../../chunks/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../geometry/projectionEllipsoid.js";import m from"../../ViewAnimation.js";import{ViewingMode as h}from"../../ViewingMode.js";import{Constraints as d}from"./Constraints.js";import{AnimationController as u}from"./controllers/AnimationController.js";import{State as g}from"./controllers/CameraController.js";import{PropertiesPool as C}from"../support/PropertiesPool.js";import{Camera as _,PaddingSide as f}from"../webgl-engine/lib/Camera.js";let y=class extends t{constructor(){super(...arguments),this._propertiesPool=new C({camera:_},this),this._lastSeenCameraProjectionValues=new _,this.events=new r,this.viewingMode=h.Global,this._cameraChanged=!1,this._updateQueue=new Array,this._processingUpdates=!1}init(e,t){this._set("viewingMode",e),this._set("spatialReference",t),this._set("constraints",new d({mode:this.viewingMode}))}exit(){this.cameraController=null,this._propertiesPool.destroy(),this._propertiesPool=new C({camera:_},this)}createInitialCamera(){if(this.viewingMode===h.Global){const e=c(this.spatialReference).radius;this.camera=new _(p(4*e,0,0),p(e,0,0),p(0,0,1))}else this.camera=new _(p(0,0,100),p(0,0,0),p(0,1,0))}get animation(){return this.cameraController instanceof u&&o(this.cameraController.viewAnimation)?this.cameraController.viewAnimation:null}get camera(){return this._get("camera")}set camera(e){e!==v&&v.copyFrom(e),v.computeUp(this.viewingMode),j.camera=v,this.events.emit("before-camera-change",j);const t=this._get("camera");if(this._cameraProjectionChanged(this._lastSeenCameraProjectionValues,v)&&(this._lastSeenCameraProjectionValues.copyFrom(v),V.camera=this._lastSeenCameraProjectionValues,this.events.emit("camera-projection-changed",V)),(!t||!t.equals(v))&&(this._set("camera",this._propertiesPool.get("camera").copyFrom(v)),this._cameraChanged=!t||!t.almostEquals(v),this._cameraChanged)){const e=l((()=>{this._cameraChanged=!1,e.remove()}))}}get pixelRatio(){return this.camera.pixelRatio}get contentCamera(){return o(this._contentCamera)?this._contentCamera:this.camera}set contentCamera(e){this._contentCamera=o(e)?e.clone():null}get fixedContentCamera(){return o(this._contentCamera)}get isGlobal(){return this.viewingMode===h.Global}get isLocal(){return this.viewingMode===h.Local}get navigating(){return!(!this.cameraController||!this.cameraController.isInteractive)}get stationary(){return!this._cameraChanged&&!this.navigating}get cameraController(){return this._get("cameraController")}set cameraController(e){this.stopActiveCameraController()?(e&&(this.addHandles(a((()=>e.state),(t=>{t!==g.Finished&&t!==g.Stopped||(this._set("cameraController",null),this.updateCamera((t=>e.onControllerEnd(t))))}),i)),e.onControllerStart(this.camera)),this._set("cameraController",e)):e&&(e.state=g.Rejected)}switchCameraController(e){return this.cameraController=e,e.state!==g.Rejected}stopActiveCameraController(){return!(this.cameraController&&!this.cameraController.stopController())}updateCamera(e){this._updateQueue.push(e),this._processUpdateQueue()}_processUpdateQueue(){if(0===this._updateQueue.length||this._processingUpdates)return;this._processingUpdates=!0;const e=this._updateQueue.shift();v.copyFrom(this._get("camera")),e(v),this.camera=v,this._processingUpdates=!1,this._processUpdateQueue()}_cameraProjectionChanged(e,t){return e.fov!==t.fov||(e.fullViewport[0]!==t.fullViewport[0]||e.fullViewport[1]!==t.fullViewport[1]||e.fullViewport[2]!==t.fullViewport[2]||e.fullViewport[3]!==t.fullViewport[3]||(e.padding[f.TOP]!==t.padding[f.TOP]||e.padding[f.RIGHT]!==t.padding[f.RIGHT]||e.padding[f.BOTTOM]!==t.padding[f.BOTTOM]||e.padding[f.LEFT]!==t.padding[f.LEFT]))}};e([s({readOnly:!0,type:m})],y.prototype,"animation",null),e([s({type:_})],y.prototype,"camera",null),e([s()],y.prototype,"pixelRatio",null),e([s({})],y.prototype,"_contentCamera",void 0),e([s({type:_})],y.prototype,"contentCamera",null),e([s({readOnly:!0})],y.prototype,"fixedContentCamera",null),e([s({readOnly:!0})],y.prototype,"constraints",void 0),e([s({readOnly:!0})],y.prototype,"events",void 0),e([s({readOnly:!0})],y.prototype,"isGlobal",null),e([s({readOnly:!0})],y.prototype,"isLocal",null),e([s({readOnly:!0})],y.prototype,"viewingMode",void 0),e([s({readOnly:!0})],y.prototype,"spatialReference",void 0),e([s()],y.prototype,"navigating",null),e([s()],y.prototype,"stationary",null),e([s()],y.prototype,"_cameraChanged",void 0),e([s()],y.prototype,"cameraController",null),y=e([n("esri.views.3d.state.ViewState")],y);const w=y,v=new _,j={camera:null},V={camera:null};export{w as default};
|