@arcgis/core 5.0.0-next.86 → 5.0.0-next.88
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/Ground.js +1 -1
- package/Map.d.ts +4 -0
- package/WebLinkChart.d.ts +6 -3
- package/WebScene.js +1 -1
- package/analysis/ShadowCastAnalysis.d.ts +1 -0
- package/analysis/VolumeMeasurement/VolumeMeasurementDisplayUnits.d.ts +14 -2
- package/analysis/VolumeMeasurement/VolumeMeasurementDisplayUnits.js +1 -1
- package/applications/Components/OrientedImageryViewer/galleryUtils.d.ts +80 -0
- package/applications/Components/OrientedImageryViewer/galleryUtils.js +5 -0
- package/applications/Components/clipboard.d.ts +106 -0
- package/applications/Components/clipboard.js +5 -0
- package/assets/esri/core/libs/libtess/libtess-f32.wasm +0 -0
- package/assets/esri/core/libs/libtess/libtess-f64.wasm +0 -0
- package/assets/esri/core/t9n/Units.json +1 -1
- package/assets/esri/core/t9n/Units_ar.json +1 -1
- package/assets/esri/core/t9n/Units_bg.json +1 -1
- package/assets/esri/core/t9n/Units_bs.json +1 -1
- package/assets/esri/core/t9n/Units_ca.json +1 -1
- package/assets/esri/core/t9n/Units_cs.json +1 -1
- package/assets/esri/core/t9n/Units_da.json +1 -1
- package/assets/esri/core/t9n/Units_de.json +1 -1
- package/assets/esri/core/t9n/Units_el.json +1 -1
- package/assets/esri/core/t9n/Units_en.json +1 -1
- package/assets/esri/core/t9n/Units_es.json +1 -1
- package/assets/esri/core/t9n/Units_et.json +1 -1
- package/assets/esri/core/t9n/Units_fi.json +1 -1
- package/assets/esri/core/t9n/Units_fr.json +1 -1
- package/assets/esri/core/t9n/Units_he.json +1 -1
- package/assets/esri/core/t9n/Units_hr.json +1 -1
- package/assets/esri/core/t9n/Units_hu.json +1 -1
- package/assets/esri/core/t9n/Units_id.json +1 -1
- package/assets/esri/core/t9n/Units_it.json +1 -1
- package/assets/esri/core/t9n/Units_ja.json +1 -1
- package/assets/esri/core/t9n/Units_ko.json +1 -1
- package/assets/esri/core/t9n/Units_lt.json +1 -1
- package/assets/esri/core/t9n/Units_lv.json +1 -1
- package/assets/esri/core/t9n/Units_nl.json +1 -1
- package/assets/esri/core/t9n/Units_no.json +1 -1
- package/assets/esri/core/t9n/Units_pl.json +1 -1
- package/assets/esri/core/t9n/Units_pt-BR.json +1 -1
- package/assets/esri/core/t9n/Units_pt-PT.json +1 -1
- package/assets/esri/core/t9n/Units_ro.json +1 -1
- package/assets/esri/core/t9n/Units_ru.json +1 -1
- package/assets/esri/core/t9n/Units_sk.json +1 -1
- package/assets/esri/core/t9n/Units_sl.json +1 -1
- package/assets/esri/core/t9n/Units_sr.json +1 -1
- package/assets/esri/core/t9n/Units_sv.json +1 -1
- package/assets/esri/core/t9n/Units_th.json +1 -1
- package/assets/esri/core/t9n/Units_tr.json +1 -1
- package/assets/esri/core/t9n/Units_uk.json +1 -1
- package/assets/esri/core/t9n/Units_vi.json +1 -1
- package/assets/esri/core/t9n/Units_zh-CN.json +1 -1
- package/assets/esri/core/t9n/Units_zh-HK.json +1 -1
- package/assets/esri/core/t9n/Units_zh-TW.json +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{6298e71e6c480d6f46e3.js → 0276e689e1371b40cff3.js} +1 -1
- package/assets/esri/core/workers/chunks/045a9cc900bb4ac8afde.js +1 -0
- package/assets/esri/core/workers/chunks/048173088bbeb1f6b8b6.js +1 -0
- package/assets/esri/core/workers/chunks/0be8b9d9ef56c37e74c3.js +1 -0
- package/assets/esri/core/workers/chunks/0bef671165e64f90ac86.js +1 -0
- package/assets/esri/core/workers/chunks/0c025d2b0d3162b07feb.js +1 -0
- package/assets/esri/core/workers/chunks/0c4ed18d67dea0c99f01.js +1 -0
- package/assets/esri/core/workers/chunks/0e0208b87566f4470f1d.js +1 -0
- package/assets/esri/core/workers/chunks/{981f05b5ef6f9c3f7e8a.js → 0fc0fd7618ef25dd6b67.js} +1 -1
- package/assets/esri/core/workers/chunks/{1facc1b45345a095b9a7.js → 149c4181eaea32e9ac15.js} +1 -1
- package/assets/esri/core/workers/chunks/{f1e1666bede364c069fc.js → 15c180deb8d09127ad31.js} +1 -1
- package/assets/esri/core/workers/chunks/1616ee2f6dce0203f1d5.js +1 -0
- package/assets/esri/core/workers/chunks/21bb414cb0623ffad577.js +1 -0
- package/assets/esri/core/workers/chunks/21c84e014c73bd85f4a3.js +1 -0
- package/assets/esri/core/workers/chunks/262677294d8c653e2b0b.js +1 -0
- package/assets/esri/core/workers/chunks/{5139bbe8f94df01467c7.js → 28a6a59033baa44bafab.js} +1 -1
- package/assets/esri/core/workers/chunks/{c5d56b85d34026507902.js → 28c273f34ffde25cebc6.js} +1 -1
- package/assets/esri/core/workers/chunks/{b7e40118b4d645e9f8e1.js → 2a12026f1ca9e8900a8b.js} +1 -1
- package/assets/esri/core/workers/chunks/2bc9f407f89d554a43ce.js +1 -0
- package/assets/esri/core/workers/chunks/2f21c5ae4fbe85c2792b.js +1 -0
- package/assets/esri/core/workers/chunks/3332ee9727874953523c.js +1 -0
- package/assets/esri/core/workers/chunks/{c477b0ce55211339c4cb.js → 33f44cc192c72064b5b6.js} +1 -1
- package/assets/esri/core/workers/chunks/{1cf27708d17a4de75b68.js → 3672125daca3df24c8ab.js} +1 -1
- package/assets/esri/core/workers/chunks/37a607f3835ec6f60834.js +1 -0
- package/assets/esri/core/workers/chunks/{3ebd4cdafa7682062447.js → 39dd80c184ac48f877f1.js} +1 -1
- package/assets/esri/core/workers/chunks/3a3adf9b6502ad698aea.js +1 -0
- package/assets/esri/core/workers/chunks/{4a857a7f5e00dfab2b44.js → 3c663035cf872b66cb98.js} +1 -1
- package/assets/esri/core/workers/chunks/{32b09ca094377a305881.js → 3d924488471601a17915.js} +1 -1
- package/assets/esri/core/workers/chunks/{743165f9bc4d85748a0d.js → 42b56932340b6d0bc712.js} +1 -1
- package/assets/esri/core/workers/chunks/4de93e9f91fd891ed96f.js +1 -0
- package/assets/esri/core/workers/chunks/4eb02a03956d1c9c77ee.js +1 -0
- package/assets/esri/core/workers/chunks/{15132d36e7ccbb3c009e.js → 555a252bdb87e340bd02.js} +1 -1
- package/assets/esri/core/workers/chunks/{5d791bfca20791d8e0af.js → 5670e430584f020a3530.js} +1 -1
- package/assets/esri/core/workers/chunks/{70df4331ed29d823bf38.js → 5b297353b058323f8080.js} +1 -1
- package/assets/esri/core/workers/chunks/5ef5dcca7c9b376f7f77.js +1 -0
- package/assets/esri/core/workers/chunks/{c12c095937b21e39ad3c.js → 614c63dae0158da0ed3d.js} +1 -1
- package/assets/esri/core/workers/chunks/{5734aefbce8b6425630c.js → 63b46983155b1672e07a.js} +1 -1
- package/assets/esri/core/workers/chunks/{8b575ac55bc396c0c477.js → 687677acc05b5e87effe.js} +1 -1
- package/assets/esri/core/workers/chunks/{1aee859eaffa54ef2515.js → 727321c615f35d708d46.js} +1 -1
- package/assets/esri/core/workers/chunks/731cab5887c05f221279.js +1 -0
- package/assets/esri/core/workers/chunks/779fe8ccc4041f0b65a0.js +1 -0
- package/assets/esri/core/workers/chunks/782c24211daacb47b0b2.js +1 -0
- package/assets/esri/core/workers/chunks/79067e7d1ebc46afd775.js +1 -0
- package/assets/esri/core/workers/chunks/7a454e4d6df3360e0ab9.js +1 -0
- package/assets/esri/core/workers/chunks/7da56ba34c81d2bbaf25.js +1 -0
- package/assets/esri/core/workers/chunks/{d8b72c6f5f9b2d013b7f.js → 824b45b04b4f4f91dbce.js} +1 -1
- package/assets/esri/core/workers/chunks/836d10ceb93ed19f0aa6.js +1 -0
- package/assets/esri/core/workers/chunks/{68d0bae1816061d96307.js → 837d39e70880e4310bda.js} +1 -1
- package/assets/esri/core/workers/chunks/{746190bb70aa78ba0bfc.js → 8936f9398414be26b83f.js} +4 -4
- package/assets/esri/core/workers/chunks/8bcb2180ecc88a39b317.js +1 -0
- package/assets/esri/core/workers/chunks/{e95f90d59041640727da.js → 8c5d827cbf8869defb87.js} +1 -1
- package/assets/esri/core/workers/chunks/{7449af8f3637c1694660.js → 97155c8ac832d7c46f24.js} +1 -1
- package/assets/esri/core/workers/chunks/{fbf21fda283836e8633c.js → 98cb131b62e30aee35e1.js} +1 -1
- package/assets/esri/core/workers/chunks/{e067bbf12f711fd5b9a6.js → 9b3b9df0aa0fdcc77aa2.js} +1 -1
- package/assets/esri/core/workers/chunks/{5852d291ef41201030d5.js → 9fa1512baa6e95d3f878.js} +21 -21
- package/assets/esri/core/workers/chunks/{8cb13b3776f07536c79f.js → a0d459bdb91ee892d4b6.js} +1 -1
- package/assets/esri/core/workers/chunks/{96616126aaf319cd1c6f.js → a5ed35f53769feb751db.js} +1 -1
- package/assets/esri/core/workers/chunks/{b6530c66804bede649d7.js → aa09e261d1f7dffaad8c.js} +1 -1
- package/assets/esri/core/workers/chunks/b268b4cbf5b0c856f88e.js +1 -0
- package/assets/esri/core/workers/chunks/b2f6cee006788ce3bd16.js +1 -0
- package/assets/esri/core/workers/chunks/{198ae9e02366870d3ec8.js → b46e772e415e2cfca896.js} +1 -1
- package/assets/esri/core/workers/chunks/{cee29c3a94376f6740d7.js → b4ab715a3c506e122f35.js} +1 -1
- package/assets/esri/core/workers/chunks/{b5ca894a6cb1a19676d5.js → b9756dce0b3af1a9dc54.js} +1 -1
- package/assets/esri/core/workers/chunks/baa7e90ec5259057d86b.js +1 -0
- package/assets/esri/core/workers/chunks/{52ae2073604deef63ea2.js → c083045d21636b95f26f.js} +1 -1
- package/assets/esri/core/workers/chunks/c267e57eb7f779115aba.js +1 -0
- package/assets/esri/core/workers/chunks/{5a0c5271304189a2401d.js → c38098f7073a10efdb1e.js} +1 -1
- package/assets/esri/core/workers/chunks/{adecd31fd64d6753682d.js → c7c865dc1a93e781a3e3.js} +1 -1
- package/assets/esri/core/workers/chunks/c8e56dc1239118ac2a60.js +1 -0
- package/assets/esri/core/workers/chunks/cb6083f7294c8de297e1.js +1 -0
- package/assets/esri/core/workers/chunks/cb6c9469d7c16727cd12.js +1 -0
- package/assets/esri/core/workers/chunks/{e7e508258ad27468a6a5.js → cc6d9b2062b9de629111.js} +1 -1
- package/assets/esri/core/workers/chunks/d5386c0e77063c87fddd.js +1 -0
- package/assets/esri/core/workers/chunks/d782671235af2db1c458.js +1 -0
- package/assets/esri/core/workers/chunks/de33ce9b6f4e6c0e1389.js +1 -0
- package/assets/esri/core/workers/chunks/{0abb084b8a137f4fcdfc.js → e1c5773c12d9947bdc5f.js} +1 -1
- package/assets/esri/core/workers/chunks/e55ce8466aa979ac1e6b.js +1 -0
- package/assets/esri/core/workers/chunks/{21739c37160061f229ef.js → e585883d0036aa866420.js} +1 -1
- package/assets/esri/core/workers/chunks/e6d6d664fc9f2cd6a042.js +1 -0
- package/assets/esri/core/workers/chunks/e7cdc2a21104d84aec4a.js +1 -0
- package/assets/esri/core/workers/chunks/e9edf3987039def65859.js +1 -0
- package/assets/esri/core/workers/chunks/{3b434f318fdbbe4111e3.js → edbe52c2848486d64b16.js} +1 -1
- package/assets/esri/core/workers/chunks/{4f8895eb57ec6ab4b318.js → f5a61fa75ac877b5bb74.js} +1 -1
- package/assets/esri/core/workers/chunks/feba6c9ae162a0a8ea3a.js +1 -0
- package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
- package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
- package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
- package/assets/esri/themes/base/widgets/_FeatureTable.scss +9 -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/{TextureOnly.glsl.js → Texture.glsl.js} +2 -2
- package/chunks/{WaterSurface.glsl.js → Water.glsl.js} +6 -6
- package/chunks/bundle.js +1 -1
- package/chunks/libtess-f32.js +1 -1
- package/chunks/libtess-f64.js +1 -1
- package/config.js +1 -1
- package/copyright.txt +84 -0
- package/core/Promise.d.ts +1 -1
- package/core/arrayUtils.js +1 -1
- package/core/quantity.js +1 -1
- package/core/quantityFormatUtils.js +1 -1
- package/core/units.d.ts +1 -1
- package/core/units.js +1 -1
- package/core/workers/WorkerHandle.js +1 -1
- package/editing/Clipboard.js +5 -0
- package/effects/FocusAreas.d.ts +1 -0
- package/form/FormTemplate.js +1 -1
- package/geometry/ellipsoidUtils.js +1 -1
- package/geometry/libtess.js +1 -1
- package/geometry/operators/geodesicBufferOperator.d.ts +1 -0
- package/geometry/operators/geodesicProximityOperator.d.ts +1 -0
- package/geometry/operators/geodeticAreaOperator.d.ts +1 -0
- package/geometry/operators/geodeticDensifyOperator.d.ts +1 -0
- package/geometry/operators/geodeticDistanceOperator.d.ts +1 -0
- package/geometry/operators/geodeticLengthOperator.d.ts +1 -0
- package/geometry/operators/geodeticUtilsOperator.d.ts +1 -0
- package/geometry/operators/shapePreservingProjectOperator.d.ts +1 -0
- package/geometry/operators/support/geographicTransformationUtils.d.ts +1 -0
- package/geometry/projection/projectors.js +1 -1
- package/geometry/projectionUtils.js +1 -1
- package/geometry/support/meshUtils/projection.js +1 -1
- package/geometry/support/meshUtils/vertexSpaceConversion.js +1 -1
- package/geometry/support/planetGCSUtils.js +1 -1
- package/geometry/support/spatialReferenceUtils.js +1 -1
- package/identity/IdentityModal.js +1 -1
- package/interfaces.d.ts +2 -2
- package/kernel.js +1 -1
- package/layers/CatalogLayer.d.ts +1 -0
- package/layers/FeatureLayer.d.ts +6 -0
- package/layers/GeoJSONLayer.d.ts +1 -0
- package/layers/Layer.d.ts +1 -0
- package/layers/LinkChartLayer.d.ts +2 -2
- package/layers/MediaLayer.d.ts +1 -0
- package/layers/OGCFeatureLayer.d.ts +1 -0
- package/layers/ParquetLayer.d.ts +6 -0
- package/layers/SubtypeGroupLayer.d.ts +1 -0
- package/layers/WFSLayer.d.ts +1 -0
- package/layers/catalog/CatalogFootprintLayer.d.ts +1 -0
- package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
- package/layers/mixins/ArcGISImageService.d.ts +30 -16
- package/layers/mixins/BlendLayer.d.ts +1 -0
- package/layers/mixins/FeatureEffectLayer.d.ts +2 -0
- package/layers/mixins/ImageryTileMixin.d.ts +2 -1
- package/layers/mixins/ImageryTileMixin.js +1 -1
- package/layers/mixins/ScaleRangeLayer.d.ts +0 -42
- package/layers/orientedImagery/transformations/utils.js +1 -1
- package/layers/raster/datasets/RawBlockCache.js +1 -1
- package/layers/raster/functions/SpectralConversionFunction.js +5 -0
- package/layers/raster/functions/SpectralConversionFunctionArguments.js +5 -0
- package/layers/raster/functions/conversionUtils.js +1 -1
- package/layers/raster/functions/rasterFunctionHelper.js +1 -1
- package/layers/raster/functions/vectorFieldUtils.js +1 -1
- package/layers/support/FeatureFilter.d.ts +4 -0
- package/layers/support/parquetUtils.d.ts +44 -1
- package/layers/support/rasterFunctionUtils.d.ts +0 -4
- package/layers/support/vectorTileLayerLoader.js +1 -1
- package/layers/support/wmsUtils.js +1 -1
- package/networks/CircuitManager.d.ts +6 -5
- package/networks/CircuitManager.js +1 -1
- package/networks/Network.d.ts +1 -0
- package/networks/UtilityNetwork.js +1 -1
- package/networks/support/Circuit.d.ts +2 -4
- package/networks/support/CircuitLocation.d.ts +1 -7
- package/networks/support/CircuitLocation.js +1 -1
- package/networks/support/CircuitPathConnectivityElement.js +1 -1
- package/networks/support/CircuitSection.d.ts +2 -4
- package/networks/support/Subcircuit.d.ts +2 -2
- package/package.json +4 -4
- package/renderers/FlowRenderer.d.ts +1 -0
- package/renderers/support/colorRampUtils.js +1 -1
- package/rest/featureService/types.d.ts +2 -2
- package/rest/imageService.d.ts +36 -19
- package/rest/imageService.js +1 -1
- package/rest/knowledgeGraph/GraphSearch.d.ts +0 -1
- package/rest/knowledgeGraph/GraphSearchStreaming.d.ts +0 -1
- package/rest/networks/circuits/support/QueryCircuitsParameters.js +1 -1
- package/rest/networks/circuits/support/VerifyCircuitsParameters.d.ts +30 -0
- package/rest/networks/circuits/support/VerifyCircuitsParameters.js +1 -1
- package/rest/networks/circuits/verifyCircuits.js +1 -1
- package/rest/networks/support/Association.js +1 -1
- package/rest/networks/support/NetworkElement.d.ts +2 -1
- package/rest/networks/support/TelecomNetworkElement.js +1 -1
- package/rest/networks/support/TraceLocation.d.ts +1 -1
- package/rest/query.d.ts +4 -0
- package/rest/support/BinParametersBase.d.ts +9 -28
- package/rest/support/DateBinParameters.d.ts +0 -17
- package/rest/support/TopFeaturesQuery.d.ts +1 -0
- package/smartMapping/raster/support/adapters/ImageryLayerAdapter.js +1 -1
- package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/CIMSymbol.d.ts +1 -0
- package/symbols/LineSymbolMarker.d.ts +2 -2
- package/symbols/SimpleFillSymbol.d.ts +2 -1
- package/symbols/SimpleLineSymbol.d.ts +4 -4
- package/symbols/support/cimSymbolUtils.d.ts +2 -0
- package/symbols/types.d.ts +140 -28
- package/views/2d/constraints/ZoomConstraint.js +1 -1
- package/views/2d/engine/imagery/RasterBitmap.js +1 -1
- package/views/2d/engine/imagery/RasterVFContainer.js +1 -1
- package/views/2d/engine/imagery/RasterVFDisplayObject.js +1 -1
- package/views/2d/engine/imagery/RasterVFTileContainer.js +1 -1
- package/views/2d/engine/rasterBrushes.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterProcessorTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/VectorFieldTechnique.js +5 -0
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/AspectTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/BandArithmeticTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ColormapToRGBTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/CompositeBandTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ComputeChangeTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ContrastBrightnessTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ConvolutionTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/CurvatureTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ExtractBandTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/FocalStatisticsTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/GrayscaleTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/HillshadeTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/LocalTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/MaskTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/NDVITechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/RemapTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ReprojectTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ShadedReliefTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/SlopeTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/SpectralConversionTechnique.js +5 -0
- package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/StretchTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/MagDirShader.js +5 -0
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/ScalarShader.js +5 -0
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/SpectralConversionShader.js +5 -0
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/2d/layers/imagery/ImageryVFStrategy.js +1 -1
- package/views/2d/layers/imagery/VectorFieldTileView2D.js +1 -1
- package/views/2d/types.d.ts +6 -1
- package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementVisualization.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
- package/views/3d/analysis/AreaMeasurementAnalysisView3D.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementRawResult.js +5 -0
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementResult.d.ts +5 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementResult.js +1 -1
- package/views/3d/analysis/VolumeMeasurementAnalysisView3D.js +1 -1
- package/views/3d/environment/EnvironmentManager.js +1 -1
- package/views/3d/environment/EnvironmentRenderer.js +1 -1
- package/views/3d/interactive/visualElements/LaserlineVisualElement.js +1 -1
- package/views/3d/layers/FlowSubView3D.js +1 -1
- package/views/3d/layers/I3SMeshViewLabeler.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerWorker.js +1 -1
- package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.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/emissiveUtils.js +5 -0
- package/views/3d/layers/i3s/I3SMeshViewFilter.js +1 -1
- package/views/3d/layers/support/layerUtils.js +1 -1
- package/views/3d/state/ViewState.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatFadeHelper.js +1 -1
- package/views/3d/support/mathUtils.js +1 -1
- package/views/3d/support/pointsOfInterest/StableSurfaceCenter.js +1 -1
- package/views/3d/support/supportedSpatialReference.js +1 -1
- package/views/3d/terrain/BlendLayers.glsl.js +5 -0
- package/views/3d/terrain/BlendLayersTechnique.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/RasterColorizer.glsl.js +5 -0
- package/views/3d/terrain/RasterColorizerTechnique.js +1 -1
- package/views/3d/terrain/terrainUtils.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js +3 -3
- package/views/3d/webgl-engine/core/shaderLibrary/shading/{Water.glsl.js → WaterColor.glsl.js} +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/util/EllipsoidMode.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/HighlightApply.glsl.js +5 -0
- package/views/3d/webgl-engine/effects/highlight/HighlightApplyTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/HighlightBlur.glsl.js +5 -0
- package/views/3d/webgl-engine/effects/highlight/HighlightBlurTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/HighlightDownsample.glsl.js +5 -0
- package/views/3d/webgl-engine/effects/highlight/HighlightDownsampleTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/HighlightToSingle.glsl.js +5 -0
- package/views/3d/webgl-engine/effects/highlight/HighlightToSingleTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.glsl.js +5 -0
- package/views/3d/webgl-engine/effects/highlight/ShadowHighlightTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/laserlines/Laserline.glsl.js +5 -0
- package/views/3d/webgl-engine/effects/laserlines/LaserlinePath.glsl.js +5 -0
- package/views/3d/webgl-engine/effects/laserlines/LaserlinePathTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/laserlines/LaserlineTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/magnifier/Magnifier.glsl.js +5 -0
- package/views/3d/webgl-engine/effects/magnifier/Magnifier.js +1 -1
- package/views/3d/webgl-engine/effects/magnifier/MagnifierTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/BlendWeights.glsl.js +5 -0
- package/views/3d/webgl-engine/effects/smaa/Blur.glsl.js +5 -0
- package/views/3d/webgl-engine/effects/smaa/EdgeDetect.glsl.js +5 -0
- package/views/3d/webgl-engine/effects/smaa/SMAABlendWeightsTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAABlurTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAAEdgeDetectTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/ssao/SSAO.glsl.js +5 -0
- package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
- package/views/3d/webgl-engine/effects/ssao/SSAOBlur.glsl.js +5 -0
- package/views/3d/webgl-engine/effects/ssao/SSAOBlurTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/ssao/SSAOTechnique.js +1 -1
- package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
- package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/Texture.glsl.js +5 -0
- package/views/3d/webgl-engine/lib/TextureTechnique.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeShader.glsl.js +5 -0
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeShaderTechnique.js +1 -1
- package/views/3d/webgl-engine/{shaders → materials}/Path.glsl.js +1 -1
- package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
- package/views/3d/webgl-engine/{shaders/WaterSurface.glsl.js → materials/Water.glsl.js} +1 -1
- package/views/3d/webgl-engine/materials/WaterTechnique.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedBuffer.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/shaders/AnimatedLine.glsl.js +31 -23
- package/views/3d/webgl.js +1 -1
- package/views/VideoView.d.ts +1 -0
- package/views/VideoView.js +1 -1
- package/views/input/ViewEvents.js +1 -1
- package/views/input/recognizers/VerticalTwoFingerDrag.js +1 -1
- package/views/input/types.d.ts +94 -0
- package/views/interactive/snapping/FeatureSnappingLayerSource.d.ts +1 -0
- package/views/interactive/tooltip/components/DrawHeaderActions.js +1 -1
- package/views/layers/FeatureLayerViewMixin.d.ts +1 -0
- package/views/support/MeasurementWorker.js +1 -1
- package/views/support/MeasurementWorkerHandle.js +1 -1
- package/views/support/euclideanAreaMeasurementUtils.js +1 -1
- package/views/support/measurementUtils.js +1 -1
- package/views/support/screenUtils.js +1 -1
- package/views/webgl/ShaderBuilder.js +1 -1
- package/widgets/AreaMeasurement2D/AreaMeasurement2DTool.js +1 -1
- package/widgets/AreaMeasurement2D.d.ts +1 -0
- package/widgets/AreaMeasurement2D.js +1 -1
- package/widgets/Attachments.d.ts +1 -0
- package/widgets/BasemapLayerList.d.ts +1 -0
- package/widgets/BasemapLayerList.js +1 -1
- package/widgets/BuildingExplorer.d.ts +1 -1
- package/widgets/CatalogLayerList.d.ts +1 -0
- package/widgets/CatalogLayerList.js +1 -1
- package/widgets/Directions.d.ts +1 -0
- package/widgets/Directions.js +1 -1
- package/widgets/DistanceMeasurement2D.d.ts +1 -0
- package/widgets/DistanceMeasurement2D.js +1 -1
- package/widgets/Editor/AddAssociationWorkflow.js +1 -1
- package/widgets/Editor.d.ts +1 -0
- package/widgets/Editor.js +1 -1
- package/widgets/FeatureForm.d.ts +1 -0
- package/widgets/FeatureForm.js +1 -1
- package/widgets/FeatureTable.d.ts +1 -0
- package/widgets/FeatureTable.js +1 -1
- package/widgets/FloorFilter.d.ts +1 -0
- package/widgets/FloorFilter.js +1 -1
- package/widgets/LayerList.d.ts +1 -0
- package/widgets/LayerList.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/sketch/DataCaptureAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/view/MapViewAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageOverlays.js +1 -1
- package/widgets/OrientedImageryViewer/components/OverlayLayersListViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/services/TransformationService.js +5 -0
- package/widgets/OrientedImageryViewer/support/dataCaptureUtils.js +5 -0
- package/widgets/OrientedImageryViewer/support/geometryUtils.js +5 -0
- package/widgets/OrientedImageryViewer/support/typeUtils.js +5 -0
- package/widgets/ScaleRangeSlider/ScaleRanges.d.ts +43 -1
- package/widgets/ScaleRangeSlider.d.ts +1 -0
- package/widgets/ScaleRangeSlider.js +1 -1
- package/widgets/Sketch.d.ts +1 -0
- package/widgets/Sketch.js +1 -1
- package/widgets/Slider/SliderViewModel.js +1 -1
- package/widgets/Swipe.d.ts +1 -1
- package/widgets/TableList.d.ts +2 -0
- package/widgets/TableList.js +1 -1
- package/widgets/TimeSlider.d.ts +1 -0
- package/widgets/TimeSlider.js +1 -1
- package/widgets/UtilityNetworkAssociations.d.ts +2 -0
- package/widgets/UtilityNetworkAssociations.js +1 -1
- package/widgets/UtilityNetworkTrace/support/GeometryHandler.js +1 -1
- package/widgets/UtilityNetworkTrace.d.ts +2 -0
- package/widgets/UtilityNetworkTrace.js +1 -1
- package/widgets/UtilityNetworkValidateTopology.d.ts +2 -0
- package/widgets/UtilityNetworkValidateTopology.js +1 -1
- package/widgets/ValuePicker.d.ts +1 -0
- package/widgets/ValuePicker.js +1 -1
- package/widgets/support/SnappingControls.d.ts +1 -0
- package/widgets/support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js +1 -1
- package/widgets/support/UtilityNetworkAssociations/utils/createAssociation.js +1 -1
- package/assets/esri/core/workers/chunks/00e135dc1b4cb024973d.js +0 -1
- package/assets/esri/core/workers/chunks/03d037f9f04f165aac63.js +0 -1
- package/assets/esri/core/workers/chunks/03da31c7635d077e8d99.js +0 -1
- package/assets/esri/core/workers/chunks/0dcf1f3b6aa84cbe03a9.js +0 -1
- package/assets/esri/core/workers/chunks/165cf8031af160c99d70.js +0 -1
- package/assets/esri/core/workers/chunks/185c97bc63ce546995ce.js +0 -1
- package/assets/esri/core/workers/chunks/1a62c456e791c82050fe.js +0 -1
- package/assets/esri/core/workers/chunks/21163137e345badb1aaf.js +0 -1
- package/assets/esri/core/workers/chunks/25dead73dfc5a4c19285.js +0 -1
- package/assets/esri/core/workers/chunks/2767b69085c9f7a1e1af.js +0 -1
- package/assets/esri/core/workers/chunks/43e9eaedf65921b58eb2.js +0 -1
- package/assets/esri/core/workers/chunks/4caec60ac0a5851730c6.js +0 -1
- package/assets/esri/core/workers/chunks/4f4bdf9f5323fa702e6c.js +0 -1
- package/assets/esri/core/workers/chunks/5119e3159617b8e1ea13.js +0 -1
- package/assets/esri/core/workers/chunks/59d3f3fbae775fd7686e.js +0 -1
- package/assets/esri/core/workers/chunks/5a706eecd8a988fae6b7.js +0 -1
- package/assets/esri/core/workers/chunks/5ba2bbbb42ef1920579d.js +0 -1
- package/assets/esri/core/workers/chunks/5cc731f161012b63c77a.js +0 -1
- package/assets/esri/core/workers/chunks/5fa8fe6353dbdda0b06a.js +0 -1
- package/assets/esri/core/workers/chunks/6107b58457a70c8de9da.js +0 -1
- package/assets/esri/core/workers/chunks/654eef3ad30f34c42e12.js +0 -1
- package/assets/esri/core/workers/chunks/6d9e92d9c2503d5dc8dd.js +0 -1
- package/assets/esri/core/workers/chunks/7130b09300032d3a5925.js +0 -1
- package/assets/esri/core/workers/chunks/7f7c4ffbdf7b20dc7a54.js +0 -1
- package/assets/esri/core/workers/chunks/804c9666d0dc548b9f79.js +0 -1
- package/assets/esri/core/workers/chunks/8258b1c8ba6d44ba19c3.js +0 -1
- package/assets/esri/core/workers/chunks/8f2fc50eb988c0228b05.js +0 -1
- package/assets/esri/core/workers/chunks/8f3abaabc61858e929a5.js +0 -1
- package/assets/esri/core/workers/chunks/97ad3eb25ad003c16148.js +0 -1
- package/assets/esri/core/workers/chunks/a270e34bb248114ec280.js +0 -1
- package/assets/esri/core/workers/chunks/a56a5e00964d4cd59a66.js +0 -1
- package/assets/esri/core/workers/chunks/a774b4fc7df801503bea.js +0 -1
- package/assets/esri/core/workers/chunks/b1015e1f25b60c08d2cf.js +0 -1
- package/assets/esri/core/workers/chunks/c18a2948ae3cb527d8bb.js +0 -1
- package/assets/esri/core/workers/chunks/cb66a74448a6c0c20d5d.js +0 -1
- package/assets/esri/core/workers/chunks/d4f4c0201d8b641709c0.js +0 -1
- package/assets/esri/core/workers/chunks/d6d9d56b3733622deab6.js +0 -1
- package/assets/esri/core/workers/chunks/dedd9d47ccc019ffc484.js +0 -1
- package/assets/esri/core/workers/chunks/e271065410ba5c872f53.js +0 -1
- package/assets/esri/core/workers/chunks/e8a0654cebafa22b5b56.js +0 -1
- package/assets/esri/core/workers/chunks/ecf7d34b37ce6f0877af.js +0 -1
- package/assets/esri/core/workers/chunks/f25eb512592a84a508c1.js +0 -1
- package/assets/esri/core/workers/chunks/f64ec13167eb51da2f9b.js +0 -1
- package/layers/graphics/sources/ParquetSource.d.ts +0 -45
- package/views/2d/engine/imagery/BrushVectorField.js +0 -5
- package/views/3d/analysis/AreaMeasurement/support/utils.js +0 -5
- package/views/3d/analysis/VolumeMeasurement/volumeMeasurementUtils.js +0 -5
- package/views/3d/webgl-engine/core/shaderLibrary/raster/RasterColorizer.glsl.js +0 -5
- package/views/3d/webgl-engine/core/shaderLibrary/util/BlendLayers.glsl.js +0 -5
- package/views/3d/webgl-engine/core/shaderLibrary/util/TextureOnly.glsl.js +0 -5
- package/views/3d/webgl-engine/shaders/BlendWeights.glsl.js +0 -5
- package/views/3d/webgl-engine/shaders/Blur.glsl.js +0 -5
- package/views/3d/webgl-engine/shaders/EdgeDetect.glsl.js +0 -5
- package/views/3d/webgl-engine/shaders/HighlightApply.glsl.js +0 -5
- package/views/3d/webgl-engine/shaders/HighlightBlur.glsl.js +0 -5
- package/views/3d/webgl-engine/shaders/HighlightDownsample.glsl.js +0 -5
- package/views/3d/webgl-engine/shaders/HighlightToSingle.glsl.js +0 -5
- package/views/3d/webgl-engine/shaders/LaserlinePath.glsl.js +0 -5
- package/views/3d/webgl-engine/shaders/Laserlines.glsl.js +0 -5
- package/views/3d/webgl-engine/shaders/Magnifier.glsl.js +0 -5
- package/views/3d/webgl-engine/shaders/SSAO.glsl.js +0 -5
- package/views/3d/webgl-engine/shaders/SSAOBlur.glsl.js +0 -5
- package/views/3d/webgl-engine/shaders/ShadowHighlight.glsl.js +0 -5
- package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeShader.glsl.js +0 -5
- package/widgets/OrientedImageryViewer/dataCaptureUtils.js +0 -5
- /package/chunks/{Laserlines.glsl.js → Laserline.glsl.js} +0 -0
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{equals as t}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{removeMaybe as i,abortMaybe as s}from"../../../core/maybe.js";import{debounce as r,ignoreAbortErrors as l,throwIfAborted as n}from"../../../core/promiseUtils.js";import{watch as a,when as o,sync as u,whenOnce as d}from"../../../core/reactiveUtils.js";import{addFrameTask as h}from"../../../core/scheduling.js";import{Seconds as c,secondsFromMilliseconds as p}from"../../../core/time.js";import{property as m,subclass as g}from"../../../core/accessorSupport/decorators.js";import{projectOrLoad as f}from"../../../geometry/projectionUtils.js";import _ from"../../../geometry/SpatialReference.js";import{fromExtent as y,intersection as v,toExtent as T,create as w,contains as S,area as b,intersects as R}from"../../../geometry/support/aaBoundingRect.js";import{getInfo as x}from"../../../geometry/support/spatialReferenceUtils.js";import A from"../../../symbols/support/ElevationInfo.js";import{simulationSettingsEqual as L,getPositions as j,getFlowSimulationSettings as E}from"../../2d/engine/flow/utils.js";import M from"./SubView3D.js";import{getFeatureTileId as P}from"./support/FeatureTileDescriptor.js";import{makeScheduleFunction as U}from"./support/makeScheduleFunction.js";import{debugFlags as C}from"../support/debugFlags.js";import{tileFilterDistance as W,scaleThresholdForLoadingAllTiles as F,defaultTransitionDuration as I,transitionDurationFactor as D,seamlessTransitionEnabled as k,densityFactor as q,loadAllTilesDensityFactor as V,averageLoadingTimeSmoothingFactor as G,fadeOutTime as O,fadeInTime as B,minimumTracingResolution as H}from"../support/flow/constants.js";import{isFullExtent as z,wrappedWidth as N,FlowQuery3D as Q}from"../support/flow/FlowQuery3D.js";import{FlowWorkerHandle as J}from"../support/flow/FlowWorkerHandle.js";import{materialParametersFromRenderer as K,createStreamlineGeometry as X}from"../support/flow/geometryUtils.js";import{boundingRectOfTiles as Y}from"../support/flow/loadUtils.js";import{StreamlineResources3DOverlay as Z}from"../support/flow/StreamlineResources3DOverlay.js";import{StreamlineResources3DShape as $}from"../support/flow/StreamlineResources3DShape.js";import{webMercatorWorldExtent as ee}from"../terrain/TerrainConst.js";import{descendantsAtLevel as te,tilesAreRelated as ie}from"../terrain/tileUtils.js";import{isScreenSizePerspectiveEnabled as se}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{RibbonLineMaterial as re}from"../webgl-engine/materials/RibbonLineMaterial.js";import{isInEffectiveScaleRange as le,hasLayerBasedScaleVisibility as ne}from"../../support/layerViewUtils.js";import{TaskPriority as ae}from"../../support/Scheduler.js";let oe=class extends M{constructor(e){super(e),this.type="flow",this.renderedTiles=null,this.requireLoad=!1,this.workerHandle=null,this.frameTask=null,this._averageLoadingTime=c(0),this._abortController=null,this._loadingState="ready-to-load",this._tilesUpdateIsWaiting=!1,this._debugAllowAutoLoading=!0,this.emissiveStrength=0,this._overrideMaterialParameters=null,this._overrideSimulationSettings=null,this._overrideTransitionEnabled=null,this._updateTask=null,this._debouncedTileUpdate=r(async()=>{const{allTiles:e}=this.surface,t=this._getTileFilterFunction(),i=new Set;function*s(s){for(let r=0;r<e.length;++r){const l=e.at(r);t(l)&&i.add(l),s.madeProgress(),s.done&&(s=yield)}}await this.frameTask.scheduleGenerator(s),this.renderedTiles=i})}initialize(){const{surface:e,view:t}=this,{resourceController:i}=t;this.workerHandle=new J(U(i)),this.frameTask=i.scheduler.registerTask(ae.FLOW_GENERATOR),this._updateTask=h({update:()=>this._update()}),this.addHandles([a(()=>this._simulationSettings,()=>this.triggerLoad(),{sync:!0,equals:(e,t)=>null==e&&null==t||null!=e&&null!=t&&L(e,t)}),a(()=>{const{elevationInfo:e}=this;return[this._clippingArea,this.visible,this._draped,this.view.state.contentPixelRatio,this.view.viewingMode,e?.mode,e?.offset,e?.unit,this._effectiveDensity]},()=>this.triggerLoad(),u),o(()=>!this.view.animationsEnabled,()=>{const{_resources:e,_lastResources:t}=this;null!=e&&(e.startTime=ce),null!=t&&(t.startTime=ce)},u),a(()=>this._materialParameters,e=>{this._resources?.setMaterialParameters(e),this._lastResources?.setMaterialParameters(e)}),o(()=>e.allTilesCreated,()=>this._triggerTilesUpdate,u),t.enableFeatureTiles(),a(()=>[this._dataBounds,this._featureTilesBounds,this.loadAllTiles],()=>this._triggerTilesUpdate()),a(()=>this._flowRenderer,(e,t)=>{const i=t?.visualVariables??[],s=e?.visualVariables??[];s.length===i.length&&s.every((e,t)=>e.type===i[t].type)||this.clear()}),o(()=>!t.featureTiles?.updating,()=>{this._triggerTilesUpdate()})]),this._triggerTilesUpdate()}destroy(){this._updateTask=i(this._updateTask),this.abort(),this.clear()}abort(){this._abortController=s(this._abortController),this.requireLoad=!1}get _clippingArea(){const e=f(this.view.clippingArea,this.surface.spatialReference).geometry;return null==e?null:y(e)}get _dataBounds(){const e=this._fullExtentSurfaceSpatialReference;return null==e?null:y(e)}get _fullExtentSurfaceSpatialReference(){return f(this.layer.fullExtent,this.surface.spatialReference).geometry}get _draped(){return"on-the-ground"===this.elevationInfo.mode}get extent(){if(this.loadAllTiles)return pe(this._fullExtentSurfaceSpatialReference);const{spatialReference:e}=this.surface;let t=this.renderedTiles;if(null==e||null==t)return null;const i=this.view.terrainLevel;if(null!=i){const e=new Set;t.forEach(t=>{Math.abs(i-t.level)<W&&e.add(t)}),t=e}const s=Y(t,this.spatialReferenceInfo);return null==s?null:(v(s,this._clippingArea,s),pe(T(s,e)))}get loadAllTiles(){return this.view.scale>(C.FLOW_GLOBAL_SCALE_THRESHOLD??F)}get isDataGlobal(){const{extent:e,spatialReferenceInfo:t}=this;return null!=e&&z(e.xmin,e.xmax,t)}get loadAllTilesLevel(){const{tilingScheme:e}=this.surface;return Math.min(Math.ceil(e.levelAtScale(C.FLOW_GLOBAL_SCALE_THRESHOLD??F)),e.getMaxLod())}get targetTiles(){const e=new Map;if(this.loadAllTiles){const{_dataBounds:t}=this;if(null==t)return e;const i=w(),s=this.loadAllTilesLevel,r=this.surface.tilingScheme,l=r.rootTilesInExtent(t).flatMap(e=>te(e,s));for(const n of l){const[l,a,o]=n;r.getExtent(s,a,o,i),de(t,i)&&e.set(P(s,a,o),n)}return e}const{renderedTiles:t}=this;for(const i of t??[])e.set(i.key,i.lij);return e}get _featureTilesBounds(){const e=this.view.featureTiles?.filterExtent,t=f(e,this.surface.spatialReference).geometry;return null==t?null:y(t)}get _flowRenderer(){const e=this.layer.renderer;return"flow"!==e?.type?null:e}get _materialParameters(){return{...K(this._flowRenderer,this.layerView.fullOpacity,this.emissiveStrength),...this._overrideMaterialParameters,hasSlicePlane:this.layerView.slicePlaneEnabled,screenSizePerspective:!this._draped&&se(this.layer.screenSizePerspectiveEnabled)?this.view.screenSizePerspective.parameters:null}}get _opacity(){return this.layerView.fullOpacity}get _seamlessTransitionWaitingTime(){const{_averageLoadingTime:e}=this;return c(0===e?I:this._averageLoadingTime*D)}get _seamlessTransitionEnabled(){return null!=this._overrideTransitionEnabled?this._overrideTransitionEnabled:k}get _tracingResolution(){const{extent:e}=this;if(!e)return[0,0];const t=N(e.xmin,e.xmax,this.spatialReferenceInfo?.valid)/(e.ymax-e.ymin),[i,s]=this.view.size;let r,l;i<s?(r=i,l=i/t):(r=s*t,l=s);const n=H,a=this.view.qualitySettings.flow.maxTracingResolution,o=Math.max(1,n/Math.min(r,l)),u=o*Math.min(1,a/Math.max(r*o,l*o));return[Math.round(r*u),Math.round(l*u)]}get visible(){const e=this._flowRenderer?.color;return this.visibleAtCurrentScale&&this.layer.effectiveVisible&&this._opacity>0&&(null==e||e.a>0)}get _estimatedStreamlines(){const{extent:e,_simulationSettings:t,renderedTiles:i,loadAllTiles:s}=this;if(null==t||null==i)return 0;const r=this._tracingResolution[0]*this._tracingResolution[1]/t.lineSpacing**2*t.density;if(s)return 2*r;const l=null==e?null:y(e);if(null==l)return 0;let n=0;for(const u of i)S(l,u.extent)&&(n+=b(u.extent));const a=b(l),o=0===a?0:n/a;return 2*Math.round(r*o)}get _effectiveDensity(){const{_estimatedStreamlines:e,_simulationSettings:t}=this,{qualitySettings:i,quality:s}=this.view;if(null==t)return 0;const r=i.flow.maxTotalNumberOfStreamlines,l=e>=r?r/e:1,n=t.density*l*s;return t.lineSpacing/Math.sqrt(n)<t.lineCollisionWidth?(t.lineSpacing/t.lineCollisionWidth)**2:n}get elevationInfo(){return this.layer.elevationInfo??ue}startPositions(e){if(!this._seamlessTransitionEnabled)return[];const{_flowRenderer:t,_resources:i}=this;return null==t||null==i?[]:j(i.streamlines,i.query,e,t.flowSpeed)}get needsMagnitude(){return this._flowRenderer?.hasVisualVariables()??!1}get spatialReferenceInfo(){return x(this.surface.spatialReference)}get layer(){return this.layerView.layer}get loadingState(){return this._loadingState}get loadRequirementsMet(){return null!=this.renderedTiles&&(this.renderedTiles.size>0||this.loadAllTiles)&&null!=this.extent}hasWork(){return null==this.extent||this.updatingHandles.updating||this.requireLoad||"before-transition"===this._loadingState}get updating(){return this._debugAllowAutoLoading&&this.visible&&!(this.destroyed||this.destroying)&&this.hasWork()}get visibleAtCurrentScale(){return!ne()||le(this.layer.effectiveScaleRange,this.view.scale)}get _simulationSettings(){const{_flowRenderer:e,_overrideSimulationSettings:t}=this;if(null==e)return null;let i=E(e);return i.segmentLength=i.lineCollisionWidth/2,i.onlyForwardTracing=!1,i.density*=q,this.loadAllTiles&&this.isDataGlobal&&(i.density*=V),null!=t&&(i={...i,...t}),i}getSimulationSettings(e){const{_simulationSettings:t,spatialReferenceInfo:i}=this;if(null==t)return null;const s="global"===this.view.viewingMode&&null!=i&&z(e.extent.xmin,e.extent.xmax,i);return{...t,wrapAround:s,density:this._effectiveDensity}}get surface(){return this.view.basemapTerrain}doRefresh(){}clear(){this._resources?.detach(),this._resources=null,this._lastResources?.detach(),this._lastResources=null,this._loadingState="ready-to-load"}_update(){const e=this._time;this._lastResources?.hasFadedOut(e)&&this._lastResources.detach();const t=this._nextStateForTransition(e);if(!this.requireLoad||this.updatingHandles.updating||"ready-to-load"!==t||!this.loadRequirementsMet)return void(this._loadingState=t);this._loadingState="loading";const i=async()=>{const t=this._time,i=this._seamlessTransitionEnabled&&null!=this._resources?c(e+this._seamlessTransitionWaitingTime):e;await this._load(i);const s=c((this._time-t)/1e3);this._updateAverageLoadingTime(s)};this.updatingHandles.addPromise(l(i())),this.requireLoad=!1}_updateAverageLoadingTime(e){const t=G;this._averageLoadingTime=c(t*e+(1-t)*this._averageLoadingTime)}triggerLoad(){this._debugAllowAutoLoading&&(this.visible?this.requireLoad=!0:this.clear())}get _time(){return p(this.layerView.view.stage.renderer.renderContext.time)}async _load(e){const{extent:t,view:i}=this;if(!this.visible)return void this.clear();if(null==t)return void(this._loadingState="ready-to-load");const s=new Q(t,this.layerView.timeExtent,this._tracingResolution,i.state.contentPixelRatio,e);null==this._abortController&&(this._abortController=new AbortController);const r=this._abortController,l=await this._loadStreamlines(s,r.signal);if(n(r.signal),null!=l){this._lastResources?.detach(),this._lastResources=this._resources,this._resources=l;const t=this._getStartTime(e);null!=this._lastResources&&(this._lastResources.endTime=t),this._resources.startTime=t,this.view.animationsEnabled||(this._lastResources?.detach(),this._lastResources=null),await l.attach(),this._loadingState=this._seamlessTransitionEnabled?"before-transition":"transitioning"}else this._loadingState="ready-to-load"}async _loadStreamlines(e,t){const i=await this.fetchDataAndGenerateStreamlines(e,t);if(null==i)return null;const{geometries:s,material:r}=await this._createGeometry(e,i);return this._draped?new Z(e,i,r,s,this.layerView):new $(e,i,r,s,this.view)}async fetchDataAndGenerateStreamlines(e,t){return null}async _createGeometry(e,t){const i=new re(this._materialParameters,this.view.state.isGlobal),s=new Array,{elevationInfo:r,_draped:l,view:n}=this;function*a(a){for(let o=0;o<t.length;++o)s.push(X(n,e,t[o],r,i,l)),a.madeProgress(),a.done&&(a=yield)}return await this.frameTask.scheduleGenerator(a),{geometries:s,material:i}}_triggerTilesUpdate(){if(this._tilesUpdateIsWaiting)return;this._tilesUpdateIsWaiting=!0;const e=async()=>{await d(()=>this.view.stationary),this._tilesUpdateIsWaiting=!1,await this._debouncedTileUpdate()};this.updatingHandles.addPromise(l(e()))}_getTileFilterFunction(){const{_dataBounds:e,view:i,_featureTilesBounds:s,loadAllTiles:r}=this;if(r){const{loadAllTilesLevel:t}=this;return i=>i.level===t&&de(e,i.extent)}const l=t=>t.rendered&&t.visible&&de(e,t.extent),{featureTiles:n}=i;if(!n)return l;const a=n.tiles.filter(e=>e.measures.visible);return e=>l(e)&&de(s,e.extent)&&a.some(({lij:i})=>t(i,e.lij)||ie(i,e.lij))}_nextStateForTransition(e){const{_resources:t}=this;if(null==this._flowRenderer||null==t||"ready-to-load"===this._loadingState||"loading"===this._loadingState)return this._loadingState;const i=t.startTime;return e<i?"before-transition":e<i+O?"transitioning":"ready-to-load"}_getStartTime(e){if(!this.view.animationsEnabled)return ce;const t=this._time;return c(t>e?t:e)}get usedMemory(){return(this._lastResources?.usedMemory??0)+(this._resources?.usedMemory??0)}get test(){}};e([m()],oe.prototype,"type",void 0),e([m()],oe.prototype,"renderedTiles",void 0),e([m()],oe.prototype,"_resources",void 0),e([m()],oe.prototype,"_lastResources",void 0),e([m()],oe.prototype,"requireLoad",void 0),e([m()],oe.prototype,"_averageLoadingTime",void 0),e([m()],oe.prototype,"_loadingState",void 0),e([m()],oe.prototype,"emissiveStrength",void 0),e([m()],oe.prototype,"_clippingArea",null),e([m()],oe.prototype,"_dataBounds",null),e([m()],oe.prototype,"_fullExtentSurfaceSpatialReference",null),e([m()],oe.prototype,"_draped",null),e([m()],oe.prototype,"extent",null),e([m()],oe.prototype,"loadAllTiles",null),e([m()],oe.prototype,"isDataGlobal",null),e([m()],oe.prototype,"loadAllTilesLevel",null),e([m()],oe.prototype,"targetTiles",null),e([m()],oe.prototype,"_featureTilesBounds",null),e([m()],oe.prototype,"_flowRenderer",null),e([m()],oe.prototype,"_materialParameters",null),e([m()],oe.prototype,"_opacity",null),e([m()],oe.prototype,"_seamlessTransitionWaitingTime",null),e([m()],oe.prototype,"_seamlessTransitionEnabled",null),e([m()],oe.prototype,"_tracingResolution",null),e([m()],oe.prototype,"visible",null),e([m()],oe.prototype,"_estimatedStreamlines",null),e([m()],oe.prototype,"_effectiveDensity",null),e([m()],oe.prototype,"elevationInfo",null),e([m()],oe.prototype,"needsMagnitude",null),e([m()],oe.prototype,"spatialReferenceInfo",null),e([m()],oe.prototype,"layer",null),e([m()],oe.prototype,"loadingState",null),e([m()],oe.prototype,"updating",null),e([m()],oe.prototype,"visibleAtCurrentScale",null),e([m()],oe.prototype,"_overrideMaterialParameters",void 0),e([m()],oe.prototype,"_overrideSimulationSettings",void 0),e([m()],oe.prototype,"_overrideTransitionEnabled",void 0),e([m()],oe.prototype,"_simulationSettings",null),e([m()],oe.prototype,"surface",null),oe=e([g("esri.views.3d.layers.FlowSubView3D")],oe);const ue=new A({mode:"on-the-ground"});function de(e,t){return null==e||null==t||R(e,t)}const he=T(ee,_.WebMercator),ce=c(-B);function pe(e){return null!=e&&e.spatialReference.isWebMercator?e?.intersection(he):e}export{oe as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import{equals as t}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{removeMaybe as i,abortMaybe as s}from"../../../core/maybe.js";import{debounce as r,ignoreAbortErrors as l,throwIfAborted as n}from"../../../core/promiseUtils.js";import{watch as a,when as o,sync as u,whenOnce as d}from"../../../core/reactiveUtils.js";import{addFrameTask as h}from"../../../core/scheduling.js";import{Seconds as c,secondsFromMilliseconds as p}from"../../../core/time.js";import{property as m,subclass as g}from"../../../core/accessorSupport/decorators.js";import{projectOrLoad as f}from"../../../geometry/projectionUtils.js";import _ from"../../../geometry/SpatialReference.js";import{fromExtent as y,intersection as v,toExtent as T,create as w,contains as S,area as b,intersects as R}from"../../../geometry/support/aaBoundingRect.js";import{getInfo as x}from"../../../geometry/support/spatialReferenceUtils.js";import A from"../../../symbols/support/ElevationInfo.js";import{simulationSettingsEqual as L,getPositions as j,getFlowSimulationSettings as E}from"../../2d/engine/flow/utils.js";import M from"./SubView3D.js";import{getFeatureTileId as P}from"./support/FeatureTileDescriptor.js";import{makeScheduleFunction as U}from"./support/makeScheduleFunction.js";import{debugFlags as C}from"../support/debugFlags.js";import{tileFilterDistance as W,scaleThresholdForLoadingAllTiles as F,defaultTransitionDuration as I,transitionDurationFactor as D,seamlessTransitionEnabled as k,densityFactor as q,loadAllTilesDensityFactor as V,averageLoadingTimeSmoothingFactor as G,fadeOutTime as O,fadeInTime as B,minimumTracingResolution as H}from"../support/flow/constants.js";import{isFullExtent as z,wrappedWidth as N,FlowQuery3D as Q}from"../support/flow/FlowQuery3D.js";import{FlowWorkerHandle as J}from"../support/flow/FlowWorkerHandle.js";import{materialParametersFromRenderer as K,createStreamlineGeometry as X}from"../support/flow/geometryUtils.js";import{boundingRectOfTiles as Y}from"../support/flow/loadUtils.js";import{StreamlineResources3DOverlay as Z}from"../support/flow/StreamlineResources3DOverlay.js";import{StreamlineResources3DShape as $}from"../support/flow/StreamlineResources3DShape.js";import{webMercatorWorldExtent as ee}from"../terrain/TerrainConst.js";import{descendantsAtLevel as te,tilesAreRelated as ie}from"../terrain/tileUtils.js";import{isScreenSizePerspectiveEnabled as se}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{RibbonLineMaterial as re}from"../webgl-engine/materials/RibbonLineMaterial.js";import{isInEffectiveScaleRange as le,hasLayerBasedScaleVisibility as ne}from"../../support/layerViewUtils.js";import{TaskPriority as ae}from"../../support/Scheduler.js";let oe=class extends M{constructor(e){super(e),this.type="flow",this.renderedTiles=null,this.requireLoad=!1,this.workerHandle=null,this.frameTask=null,this._averageLoadingTime=c(0),this._abortController=null,this._loadingState="ready-to-load",this._tilesUpdateIsWaiting=!1,this._debugAllowAutoLoading=!0,this.emissiveStrength=0,this._overrideMaterialParameters=null,this._overrideSimulationSettings=null,this._overrideTransitionEnabled=null,this._updateTask=null,this._debouncedTileUpdate=r(async()=>{const{allTiles:e}=this.surface,t=this._getTileFilterFunction(),i=new Set;function*s(s){for(let r=0;r<e.length;++r){const l=e.at(r);t(l)&&i.add(l),s.madeProgress(),s.done&&(s=yield)}}await this.frameTask.scheduleGenerator(s),this.renderedTiles=i})}initialize(){const{surface:e,view:t}=this,{resourceController:i}=t;this.workerHandle=new J(U(i)),this.frameTask=i.scheduler.registerTask(ae.FLOW_GENERATOR),this._updateTask=h({update:()=>this._update()}),this.addHandles([a(()=>this._simulationSettings,()=>this.triggerLoad(),{sync:!0,equals:(e,t)=>null==e&&null==t||null!=e&&null!=t&&L(e,t)}),a(()=>{const{elevationInfo:e}=this;return[this._clippingArea,this.visible,this._draped,this.view.state.contentPixelRatio,this.view.viewingMode,e?.mode,e?.offset,e?.unit,this._effectiveDensity]},()=>this.triggerLoad(),u),o(()=>!this.view.animationsEnabled,()=>{const{_resources:e,_lastResources:t}=this;null!=e&&(e.startTime=ce),null!=t&&(t.startTime=ce)},u),a(()=>this._materialParameters,e=>{this._resources?.setMaterialParameters(e),this._lastResources?.setMaterialParameters(e)}),o(()=>e.allTilesCreated,()=>this._triggerTilesUpdate,u),t.enableFeatureTiles(),a(()=>[this._dataBounds,this._featureTilesBounds,this.loadAllTiles],()=>this._triggerTilesUpdate()),a(()=>this._flowRenderer,(e,t)=>{const i=t?.visualVariables??[],s=e?.visualVariables??[];s.length===i.length&&s.every((e,t)=>e.type===i[t].type)||this.clear()}),o(()=>!t.featureTiles?.updating,()=>{this._triggerTilesUpdate()})]),this._triggerTilesUpdate()}destroy(){this._updateTask=i(this._updateTask),this.abort(),this.clear(),this.notifyChange("updating")}abort(){this._abortController=s(this._abortController),this.requireLoad=!1}get _clippingArea(){const e=f(this.view.clippingArea,this.surface.spatialReference).geometry;return null==e?null:y(e)}get _dataBounds(){const e=this._fullExtentSurfaceSpatialReference;return null==e?null:y(e)}get _fullExtentSurfaceSpatialReference(){return f(this.layer.fullExtent,this.surface.spatialReference).geometry}get _draped(){return"on-the-ground"===this.elevationInfo.mode}get extent(){if(this.loadAllTiles)return pe(this._fullExtentSurfaceSpatialReference);const{spatialReference:e}=this.surface;let t=this.renderedTiles;if(null==e||null==t)return null;const i=this.view.terrainLevel;if(null!=i){const e=new Set;t.forEach(t=>{Math.abs(i-t.level)<W&&e.add(t)}),t=e}const s=Y(t,this.spatialReferenceInfo);return null==s?null:(v(s,this._clippingArea,s),pe(T(s,e)))}get loadAllTiles(){return this.view.scale>(C.FLOW_GLOBAL_SCALE_THRESHOLD??F)}get isDataGlobal(){const{extent:e,spatialReferenceInfo:t}=this;return null!=e&&z(e.xmin,e.xmax,t)}get loadAllTilesLevel(){const{tilingScheme:e}=this.surface;return Math.min(Math.ceil(e.levelAtScale(C.FLOW_GLOBAL_SCALE_THRESHOLD??F)),e.getMaxLod())}get targetTiles(){const e=new Map;if(this.loadAllTiles){const{_dataBounds:t}=this;if(null==t)return e;const i=w(),s=this.loadAllTilesLevel,r=this.surface.tilingScheme,l=r.rootTilesInExtent(t).flatMap(e=>te(e,s));for(const n of l){const[l,a,o]=n;r.getExtent(s,a,o,i),de(t,i)&&e.set(P(s,a,o),n)}return e}const{renderedTiles:t}=this;for(const i of t??[])e.set(i.key,i.lij);return e}get _featureTilesBounds(){const e=this.view.featureTiles?.filterExtent,t=f(e,this.surface.spatialReference).geometry;return null==t?null:y(t)}get _flowRenderer(){const e=this.layer.renderer;return"flow"!==e?.type?null:e}get _materialParameters(){return{...K(this._flowRenderer,this.layerView.fullOpacity,this.emissiveStrength),...this._overrideMaterialParameters,hasSlicePlane:this.layerView.slicePlaneEnabled,screenSizePerspective:!this._draped&&se(this.layer.screenSizePerspectiveEnabled)?this.view.screenSizePerspective.parameters:null}}get _opacity(){return this.layerView.fullOpacity}get _seamlessTransitionWaitingTime(){const{_averageLoadingTime:e}=this;return c(0===e?I:this._averageLoadingTime*D)}get _seamlessTransitionEnabled(){return null!=this._overrideTransitionEnabled?this._overrideTransitionEnabled:k}get _tracingResolution(){const{extent:e}=this;if(!e)return[0,0];const t=N(e.xmin,e.xmax,this.spatialReferenceInfo?.valid)/(e.ymax-e.ymin),[i,s]=this.view.size;let r,l;i<s?(r=i,l=i/t):(r=s*t,l=s);const n=H,a=this.view.qualitySettings.flow.maxTracingResolution,o=Math.max(1,n/Math.min(r,l)),u=o*Math.min(1,a/Math.max(r*o,l*o));return[Math.round(r*u),Math.round(l*u)]}get visible(){const e=this._flowRenderer?.color;return this.visibleAtCurrentScale&&this.layer.effectiveVisible&&this._opacity>0&&(null==e||e.a>0)}get _estimatedStreamlines(){const{extent:e,_simulationSettings:t,renderedTiles:i,loadAllTiles:s}=this;if(null==t||null==i)return 0;const r=this._tracingResolution[0]*this._tracingResolution[1]/t.lineSpacing**2*t.density;if(s)return 2*r;const l=null==e?null:y(e);if(null==l)return 0;let n=0;for(const u of i)S(l,u.extent)&&(n+=b(u.extent));const a=b(l),o=0===a?0:n/a;return 2*Math.round(r*o)}get _effectiveDensity(){const{_estimatedStreamlines:e,_simulationSettings:t}=this,{qualitySettings:i,quality:s}=this.view;if(null==t)return 0;const r=i.flow.maxTotalNumberOfStreamlines,l=e>=r?r/e:1,n=t.density*l*s;return t.lineSpacing/Math.sqrt(n)<t.lineCollisionWidth?(t.lineSpacing/t.lineCollisionWidth)**2:n}get elevationInfo(){return this.layer.elevationInfo??ue}startPositions(e){if(!this._seamlessTransitionEnabled)return[];const{_flowRenderer:t,_resources:i}=this;return null==t||null==i?[]:j(i.streamlines,i.query,e,t.flowSpeed)}get needsMagnitude(){return this._flowRenderer?.hasVisualVariables()??!1}get spatialReferenceInfo(){return x(this.surface.spatialReference)}get layer(){return this.layerView.layer}get loadingState(){return this._loadingState}get loadRequirementsMet(){return null!=this.renderedTiles&&(this.renderedTiles.size>0||this.loadAllTiles)&&null!=this.extent}hasWork(){return null==this.extent||this.updatingHandles.updating||this.requireLoad||"before-transition"===this._loadingState}get updating(){return this._debugAllowAutoLoading&&this.visible&&!(this.destroyed||this.destroying)&&this.hasWork()}get visibleAtCurrentScale(){return!ne()||le(this.layer.effectiveScaleRange,this.view.scale)}get _simulationSettings(){const{_flowRenderer:e,_overrideSimulationSettings:t}=this;if(null==e)return null;let i=E(e);return i.segmentLength=i.lineCollisionWidth/2,i.onlyForwardTracing=!1,i.density*=q,this.loadAllTiles&&this.isDataGlobal&&(i.density*=V),null!=t&&(i={...i,...t}),i}getSimulationSettings(e){const{_simulationSettings:t,spatialReferenceInfo:i}=this;if(null==t)return null;const s="global"===this.view.viewingMode&&null!=i&&z(e.extent.xmin,e.extent.xmax,i);return{...t,wrapAround:s,density:this._effectiveDensity}}get surface(){return this.view.basemapTerrain}doRefresh(){}clear(){this._resources?.detach(),this._resources=null,this._lastResources?.detach(),this._lastResources=null,this._loadingState="ready-to-load"}_update(){const e=this._time;this._lastResources?.hasFadedOut(e)&&this._lastResources.detach();const t=this._nextStateForTransition(e);if(!this.requireLoad||this.updatingHandles.updating||"ready-to-load"!==t||!this.loadRequirementsMet)return void(this._loadingState=t);this._loadingState="loading";const i=async()=>{const t=this._time,i=this._seamlessTransitionEnabled&&null!=this._resources?c(e+this._seamlessTransitionWaitingTime):e;await this._load(i);const s=c((this._time-t)/1e3);this._updateAverageLoadingTime(s)};this.updatingHandles.addPromise(l(i())),this.requireLoad=!1}_updateAverageLoadingTime(e){const t=G;this._averageLoadingTime=c(t*e+(1-t)*this._averageLoadingTime)}triggerLoad(){this._debugAllowAutoLoading&&(this.visible?this.requireLoad=!0:this.clear())}get _time(){return p(this.layerView.view.stage.renderer.renderContext.time)}async _load(e){const{extent:t,view:i}=this;if(!this.visible)return void this.clear();if(null==t)return void(this._loadingState="ready-to-load");const s=new Q(t,this.layerView.timeExtent,this._tracingResolution,i.state.contentPixelRatio,e);null==this._abortController&&(this._abortController=new AbortController);const r=this._abortController,l=await this._loadStreamlines(s,r.signal);if(n(r.signal),null!=l){this._lastResources?.detach(),this._lastResources=this._resources,this._resources=l;const t=this._getStartTime(e);null!=this._lastResources&&(this._lastResources.endTime=t),this._resources.startTime=t,this.view.animationsEnabled||(this._lastResources?.detach(),this._lastResources=null),await l.attach(),this._loadingState=this._seamlessTransitionEnabled?"before-transition":"transitioning"}else this._loadingState="ready-to-load"}async _loadStreamlines(e,t){const i=await this.fetchDataAndGenerateStreamlines(e,t);if(null==i)return null;const{geometries:s,material:r}=await this._createGeometry(e,i);return this._draped?new Z(e,i,r,s,this.layerView):new $(e,i,r,s,this.view)}async fetchDataAndGenerateStreamlines(e,t){return null}async _createGeometry(e,t){const i=new re(this._materialParameters,this.view.state.isGlobal),s=new Array,{elevationInfo:r,_draped:l,view:n}=this;function*a(a){for(let o=0;o<t.length;++o)s.push(X(n,e,t[o],r,i,l)),a.madeProgress(),a.done&&(a=yield)}return await this.frameTask.scheduleGenerator(a),{geometries:s,material:i}}_triggerTilesUpdate(){if(this._tilesUpdateIsWaiting)return;this._tilesUpdateIsWaiting=!0;const e=async()=>{await d(()=>this.view.stationary),this._tilesUpdateIsWaiting=!1,await this._debouncedTileUpdate()};this.updatingHandles.addPromise(l(e()))}_getTileFilterFunction(){const{_dataBounds:e,view:i,_featureTilesBounds:s,loadAllTiles:r}=this;if(r){const{loadAllTilesLevel:t}=this;return i=>i.level===t&&de(e,i.extent)}const l=t=>t.rendered&&t.visible&&de(e,t.extent),{featureTiles:n}=i;if(!n)return l;const a=n.tiles.filter(e=>e.measures.visible);return e=>l(e)&&de(s,e.extent)&&a.some(({lij:i})=>t(i,e.lij)||ie(i,e.lij))}_nextStateForTransition(e){const{_resources:t}=this;if(null==this._flowRenderer||null==t||"ready-to-load"===this._loadingState||"loading"===this._loadingState)return this._loadingState;const i=t.startTime;return e<i?"before-transition":e<i+O?"transitioning":"ready-to-load"}_getStartTime(e){if(!this.view.animationsEnabled)return ce;const t=this._time;return c(t>e?t:e)}get usedMemory(){return(this._lastResources?.usedMemory??0)+(this._resources?.usedMemory??0)}get test(){}};e([m()],oe.prototype,"type",void 0),e([m()],oe.prototype,"renderedTiles",void 0),e([m()],oe.prototype,"_resources",void 0),e([m()],oe.prototype,"_lastResources",void 0),e([m()],oe.prototype,"requireLoad",void 0),e([m()],oe.prototype,"_averageLoadingTime",void 0),e([m()],oe.prototype,"_loadingState",void 0),e([m()],oe.prototype,"emissiveStrength",void 0),e([m()],oe.prototype,"_clippingArea",null),e([m()],oe.prototype,"_dataBounds",null),e([m()],oe.prototype,"_fullExtentSurfaceSpatialReference",null),e([m()],oe.prototype,"_draped",null),e([m()],oe.prototype,"extent",null),e([m()],oe.prototype,"loadAllTiles",null),e([m()],oe.prototype,"isDataGlobal",null),e([m()],oe.prototype,"loadAllTilesLevel",null),e([m()],oe.prototype,"targetTiles",null),e([m()],oe.prototype,"_featureTilesBounds",null),e([m()],oe.prototype,"_flowRenderer",null),e([m()],oe.prototype,"_materialParameters",null),e([m()],oe.prototype,"_opacity",null),e([m()],oe.prototype,"_seamlessTransitionWaitingTime",null),e([m()],oe.prototype,"_seamlessTransitionEnabled",null),e([m()],oe.prototype,"_tracingResolution",null),e([m()],oe.prototype,"visible",null),e([m()],oe.prototype,"_estimatedStreamlines",null),e([m()],oe.prototype,"_effectiveDensity",null),e([m()],oe.prototype,"elevationInfo",null),e([m()],oe.prototype,"needsMagnitude",null),e([m()],oe.prototype,"spatialReferenceInfo",null),e([m()],oe.prototype,"layer",null),e([m()],oe.prototype,"loadingState",null),e([m()],oe.prototype,"updating",null),e([m()],oe.prototype,"visibleAtCurrentScale",null),e([m()],oe.prototype,"_overrideMaterialParameters",void 0),e([m()],oe.prototype,"_overrideSimulationSettings",void 0),e([m()],oe.prototype,"_overrideTransitionEnabled",void 0),e([m()],oe.prototype,"_simulationSettings",null),e([m()],oe.prototype,"surface",null),oe=e([g("esri.views.3d.layers.FlowSubView3D")],oe);const ue=new A({mode:"on-the-ground"});function de(e,t){return null==e||null==t||R(e,t)}const he=T(ee,_.WebMercator),ce=c(-B);function pe(e){return null!=e&&e.spatialReference.isWebMercator?e?.intersection(he):e}export{oe as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{filterInPlace as r}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{equalsShallow as i}from"../../../core/lang.js";import{floatEqualUlp as o}from"../../../core/mathUtils.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{watch as a}from"../../../core/reactiveUtils.js";import{generateUID as n}from"../../../core/uid.js";import{property as p,subclass as c}from"../../../core/accessorSupport/decorators.js";import{diff as h}from"../../../core/accessorSupport/diffUtils.js";import{projectBuffer as l}from"../../../geometry/projection/projectBuffer.js";import{fromBuffer as d,create as u}from"../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as m}from"../../../geometry/support/DoubleArray.js";import{makeDehydratedPoint as f}from"../../../layers/graphics/dehydratedPoint.js";import{RenderingInfo as y}from"../../../renderers/support/RenderingInfo.js";import g from"../../../symbols/PointSymbol3D.js";import{Graphics3DCore as b}from"./graphics/Graphics3DCore.js";import{Graphics3DScaleVisibility as _}from"./graphics/Graphics3DScaleVisibility.js";import{boundingBoxCornersPointsStride as v,boundingBoxCornerPoints as I}from"./i3s/I3SGeometryUtil.js";import{LimitGraphicsMap as w}from"../support/LimitGraphicsMap.js";import{hasLayerBasedScaleVisibility as G}from"../../support/layerViewUtils.js";class j{constructor(e,t){this.meta=e,this.index=t}}class C{constructor(e,t){this.graphic=e,this.geometry=t,this.components=[],this.overridesDirty=!1}}let M=class extends t{get updating(){return this._graphicsCore?.updating??!1}constructor(e){super(e),this.loadedGraphics=new w(5e4),this.slicePlaneEnabled=!1,this._renderingInfo=new y(null,new g),this._featuresMap=new Map}initialize(){const e=this.view.basemapTerrain;this._graphicsCore=new b({owner:this,layer:this.layer,preferredUpdatePolicy:0,elevationFeatureExpressionEnabled:!1,graphicSymbolSupported:!1,getRenderingInfoWithoutRenderer:!0,hasZ:!0,hasM:!1,componentFactories:{deconflictor:e=>this.view.deconflictor.addGraphicsOwner(e),labeler:(e,t)=>this.view.labeler.addGraphicsOwner(e,t,{emptySymbolLabelSupported:!0,elevationInfoOverride:{mode:"absolute-height",offset:0},disablePlacement:{logEntityDescription:"3D Object Scene Layer features"}}),scaleVisibility:G()?null:(t,r)=>new _({graphicsCoreOwner:this,layer:this.layer,queryGraphicUIDsInExtent:r,graphicsCore:t,basemapTerrain:e,layerScaleEnabled:!1})}}),this._graphicsCore.initializePromise.then(()=>this._graphicsCore.startCreateGraphics()).catch(()=>{}),this.addHandles(a(()=>this.layer.labelingInfo,(e,t)=>{h(e,t)&&this._graphicsCore.updateLabelingInfo()}))}destroy(){this._graphicsCore=s(this._graphicsCore),this.loadedGraphics=s(this.loadedGraphics),this.view=null}addNodeMeta(e,t){let r=0;const i=e.filteredIds,o=this.view.spatialReference,s=[];for(let a=0;a<e.featureIds.length;a++){const p=e.featureIds[a];let c=null==i;if(i&&r<i.length&&p===i[r]&&(c=!0,r++),!this._enabledForFeatureInNode(e,a))continue;const h=this._featuresMap.get(p);if(h){h.components.push(new j(e,a)),this._updateLabelPosition(p);continue}const l=t(a,e),d=f(0,0,0,o),u={objectId:p,uid:n(),attributes:l,visible:c,geometry:d},m=new C(u,d);m.components.push(new j(e,a)),this._featuresMap.set(p,m),this._updateLabelGeometry(p),s.push(u)}this.loadedGraphics.addMany(s)}updateLabelPositions(e){const t=this.view.renderCoordsHelper;this._forEachGraphic(e,(r,i,o)=>{const s=this._graphicsCore.getGraphics3DGraphicById(i.uid);null!=s&&this._updateLabelGeometry(e.featureIds[r])&&s.alignWithAbsoluteElevation(o.z??0,t,!1)})}setNodeMetaAttributes(e,t){const r=new Array;this._forEachGraphic(e,(o,s)=>{const a=t(o,e);i(s.attributes,a)||(s.attributes=a,r.push(s.uid))}),this._graphicsCore.updateLabelingInfo(r)}applyFilterChange(e){this._forEachFeature(e,(t,r,i)=>{if(!this._enabledForFeatureInNode(e,t)){const i=e.featureIds[t];switch(this._removeFeature(r,e,t)){case 2:this.loadedGraphics.removeManyByObjectId([i]);break;case 1:this._updateLabelPosition(i)}return}const o=r.graphic,s=o.visible;s!==i&&(o.visible=i,E.graphic=o,E.property="visible",E.oldValue=s,E.newValue=i,this._graphicsCore.graphicUpdateHandler(E),E.graphic=null)})}removeNodeMeta(e){const t=[];this._forEachGraphic(e,r=>{const i=e.featureIds[r],o=this._featuresMap.get(i);if(!o)return;switch(this._removeFeature(o,e,r)){case 1:this._updateLabelPosition(i);break;case 2:t.push(i)}}),this.loadedGraphics.removeManyByObjectId(t)}_removeFeature(e,t,i){const o=e.components.length;return r(e.components,e=>!(e.meta===t&&e.index===i)),0===e.components.length?(this._featuresMap.delete(t.featureIds[i]),2):o!==e.components.length?1:0}getRenderingInfo(){return this._renderingInfo}notifyGraphicGeometryChanged(){}notifyGraphicVisibilityChanged(){}_updateLabelPosition(e){const t=this._featuresMap.get(e);t&&this._updateLabelGeometry(e)&&(this.loadedGraphics.removeManyByObjectId([e]),this.loadedGraphics.addMany([t.graphic]))}_updateLabelGeometry(e){const t=this._featuresMap.get(e);if(!t)return!1;const r=t.geometry,i=this.view.spatialReference,s=this.view.renderCoordsHelper,a=r.x,n=r.y,p=r.z??0,c=t.components.length,h=m(c*v);let u=0;for(const{meta:o,index:l}of t.components)I(l,this.collection,o.objectHandle,h,u),u+=v;return l(h,s.spatialReference,0,h,i,0),d(h,F),r.x=(F[0]+F[3])/2,r.y=(F[1]+F[4])/2,r.z=F[5],!o(r.x,a)||!o(r.y,n)||!o(r.z,p)}_forEachGraphic(e,t){this._forEachFeature(e,(r,{graphic:i,geometry:o},s)=>{this._enabledForFeatureInNode(e,r)&&t(r,i,o,s)})}_forEachFeature(e,t){let r=0;for(let i=0;i<e.featureIds.length;i++){const o=this._featuresMap.get(e.featureIds[i]);let s=null==e.filteredIds;e.filteredIds
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{filterInPlace as r}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{equalsShallow as i}from"../../../core/lang.js";import{floatEqualUlp as o}from"../../../core/mathUtils.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{watch as a}from"../../../core/reactiveUtils.js";import{generateUID as n}from"../../../core/uid.js";import{property as p,subclass as c}from"../../../core/accessorSupport/decorators.js";import{diff as h}from"../../../core/accessorSupport/diffUtils.js";import{projectBuffer as l}from"../../../geometry/projection/projectBuffer.js";import{fromBuffer as d,create as u}from"../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as m}from"../../../geometry/support/DoubleArray.js";import{makeDehydratedPoint as f}from"../../../layers/graphics/dehydratedPoint.js";import{RenderingInfo as y}from"../../../renderers/support/RenderingInfo.js";import g from"../../../symbols/PointSymbol3D.js";import{Graphics3DCore as b}from"./graphics/Graphics3DCore.js";import{Graphics3DScaleVisibility as _}from"./graphics/Graphics3DScaleVisibility.js";import{boundingBoxCornersPointsStride as v,boundingBoxCornerPoints as I}from"./i3s/I3SGeometryUtil.js";import{LimitGraphicsMap as w}from"../support/LimitGraphicsMap.js";import{hasLayerBasedScaleVisibility as G}from"../../support/layerViewUtils.js";class j{constructor(e,t){this.meta=e,this.index=t}}class C{constructor(e,t){this.graphic=e,this.geometry=t,this.components=[],this.overridesDirty=!1}}let M=class extends t{get updating(){return this._graphicsCore?.updating??!1}constructor(e){super(e),this.loadedGraphics=new w(5e4),this.slicePlaneEnabled=!1,this._renderingInfo=new y(null,new g),this._featuresMap=new Map}initialize(){const e=this.view.basemapTerrain;this._graphicsCore=new b({owner:this,layer:this.layer,preferredUpdatePolicy:0,elevationFeatureExpressionEnabled:!1,graphicSymbolSupported:!1,getRenderingInfoWithoutRenderer:!0,hasZ:!0,hasM:!1,componentFactories:{deconflictor:e=>this.view.deconflictor.addGraphicsOwner(e),labeler:(e,t)=>this.view.labeler.addGraphicsOwner(e,t,{emptySymbolLabelSupported:!0,elevationInfoOverride:{mode:"absolute-height",offset:0},disablePlacement:{logEntityDescription:"3D Object Scene Layer features"}}),scaleVisibility:G()?null:(t,r)=>new _({graphicsCoreOwner:this,layer:this.layer,queryGraphicUIDsInExtent:r,graphicsCore:t,basemapTerrain:e,layerScaleEnabled:!1})}}),this._graphicsCore.initializePromise.then(()=>this._graphicsCore.startCreateGraphics()).catch(()=>{}),this.addHandles(a(()=>this.layer.labelingInfo,(e,t)=>{h(e,t)&&this._graphicsCore.updateLabelingInfo()}))}destroy(){this._graphicsCore=s(this._graphicsCore),this.loadedGraphics=s(this.loadedGraphics),this.view=null}addNodeMeta(e,t){let r=0;const i=e.filteredIds,o=this.view.spatialReference,s=[];for(let a=0;a<e.featureIds.length;a++){const p=e.featureIds[a];let c=null==i;if(i&&r<i.length&&p===i[r]&&(c=!0,r++),!this._enabledForFeatureInNode(e,a))continue;const h=this._featuresMap.get(p);if(h){h.components.push(new j(e,a)),this._updateLabelPosition(p);continue}const l=t(a,e),d=f(0,0,0,o),u={objectId:p,uid:n(),attributes:l,visible:c,geometry:d},m=new C(u,d);m.components.push(new j(e,a)),this._featuresMap.set(p,m),this._updateLabelGeometry(p),s.push(u)}this.loadedGraphics.addMany(s)}updateLabelPositions(e){const t=this.view.renderCoordsHelper;this._forEachGraphic(e,(r,i,o)=>{const s=this._graphicsCore.getGraphics3DGraphicById(i.uid);null!=s&&this._updateLabelGeometry(e.featureIds[r])&&s.alignWithAbsoluteElevation(o.z??0,t,!1)})}setNodeMetaAttributes(e,t){const r=new Array;this._forEachGraphic(e,(o,s)=>{const a=t(o,e);i(s.attributes,a)||(s.attributes=a,r.push(s.uid))}),this._graphicsCore.updateLabelingInfo(r)}applyFilterChange(e){this._forEachFeature(e,(t,r,i)=>{if(!this._enabledForFeatureInNode(e,t)){const i=e.featureIds[t];switch(this._removeFeature(r,e,t)){case 2:this.loadedGraphics.removeManyByObjectId([i]);break;case 1:this._updateLabelPosition(i)}return}const o=r.graphic,s=o.visible;s!==i&&(o.visible=i,E.graphic=o,E.property="visible",E.oldValue=s,E.newValue=i,this._graphicsCore.graphicUpdateHandler(E),E.graphic=null)})}removeNodeMeta(e){const t=[];this._forEachGraphic(e,r=>{const i=e.featureIds[r],o=this._featuresMap.get(i);if(!o)return;switch(this._removeFeature(o,e,r)){case 1:this._updateLabelPosition(i);break;case 2:t.push(i)}}),this.loadedGraphics.removeManyByObjectId(t)}_removeFeature(e,t,i){const o=e.components.length;return r(e.components,e=>!(e.meta===t&&e.index===i)),0===e.components.length?(this._featuresMap.delete(t.featureIds[i]),2):o!==e.components.length?1:0}getRenderingInfo(){return this._renderingInfo}notifyGraphicGeometryChanged(){}notifyGraphicVisibilityChanged(){}_updateLabelPosition(e){const t=this._featuresMap.get(e);t&&this._updateLabelGeometry(e)&&(this.loadedGraphics.removeManyByObjectId([e]),this.loadedGraphics.addMany([t.graphic]))}_updateLabelGeometry(e){const t=this._featuresMap.get(e);if(!t)return!1;const r=t.geometry,i=this.view.spatialReference,s=this.view.renderCoordsHelper,a=r.x,n=r.y,p=r.z??0,c=t.components.length,h=m(c*v);let u=0;for(const{meta:o,index:l}of t.components)I(l,this.collection,o.objectHandle,h,u),u+=v;return l(h,s.spatialReference,0,h,i,0),d(h,F),r.x=(F[0]+F[3])/2,r.y=(F[1]+F[4])/2,r.z=F[5],!o(r.x,a)||!o(r.y,n)||!o(r.z,p)}_forEachGraphic(e,t){this._forEachFeature(e,(r,{graphic:i,geometry:o},s)=>{this._enabledForFeatureInNode(e,r)&&t(r,i,o,s)})}_forEachFeature(e,t){let r=0;for(let i=0;i<e.featureIds.length;i++){const o=this._featuresMap.get(e.featureIds[i]);let s=null==e.filteredIds;e.filteredIds?.[r]===e.featureIds[i]&&(s=!0,r++),o&&t(i,o,s)}}_enabledForFeatureInNode(e,t){return e.node.index<0||!this.overrides?.featureHasGeometryChanges(e.featureIds[t])}get updatePolicy(){return this._graphicsCore.effectiveUpdatePolicy}get usedMemory(){return this._graphicsCore.usedMemory}get unloadedMemoryEstimate(){return this._graphicsCore.unprocessedMemoryEstimate}get test(){}};e([p()],M.prototype,"view",void 0),e([p()],M.prototype,"layer",void 0),e([p()],M.prototype,"collection",void 0),e([p()],M.prototype,"loadedGraphics",void 0),e([p()],M.prototype,"overrides",void 0),e([p()],M.prototype,"layerViewUid",void 0),e([p()],M.prototype,"updating",null),e([p()],M.prototype,"slicePlaneEnabled",void 0),e([p()],M.prototype,"_graphicsCore",void 0),M=e([c("esri.views.3d.layers.I3SMeshViewLabeler")],M);const E={graphic:null,property:null,oldValue:null,newValue:null},F=u();export{M as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as s}from"../../../core/maybe.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{initial as o,watch as n,when as a}from"../../../core/reactiveUtils.js";import{schedule as l}from"../../../core/scheduling.js";import{property as d,subclass as c}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as h,invert as u}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as m,IDENTITY as p}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as f}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as y,sub as g,dot as _,add as v,length as w,transformMat3 as j,set as x}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as C,freeze as O,fromValues as M,clone as E,ZEROS as T}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as R,clone as U,fromValues as V}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as H,SphericalECEFSpatialReferenceLike as S}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as A}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as L}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as P}from"../../../geometry/projection/projectVectorToVector.js";import{create as k}from"../../../geometry/support/aaBoundingRect.js";import{getContinuousIndexArray as I}from"../../../geometry/support/Indices.js";import{isCGCS2000 as F,isMoon as D,isMars as G}from"../../../geometry/support/spatialReferenceUtils.js";import{BufferViewVec2f as B,BufferViewVec4f as z,BufferViewVec4u8 as N,BufferViewVec4u16 as W,BufferViewVec3f as $,BufferViewVec3u8 as q,BufferViewVec3u16 as Z,BufferViewInt16 as J,BufferViewUint32 as X,BufferViewUint16 as Y}from"../../../geometry/support/buffer/BufferView.js";import K from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as Q}from"../../../support/elevationInfoUtils.js";import{LayerView3D as ee}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as te}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as ie,removeLayerViewFromWasm as se,getLyr3DWasm as re}from"./Lyr3DWasm.js";import{toWasmModification as oe}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as ne}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as ae,alphaModeConversion as le,faceCullingConversion as de,wrapModeConversion as ce,lyr3DTypeToByteSize as he}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as ue}from"./support/Tiles3DIntersectionHandler.js";import{Frustum as me}from"../state/Frustum.js";import{ElevationRange as pe}from"../support/ElevationRange.js";import{toBoundingRect as be}from"../support/extentUtils.js";import{compute as fe,Obb as ye}from"../support/orientedBoundingBox.js";import{glLayout as ge}from"../support/buffer/glUtil.js";import{VertexBufferLayoutCreationParameters as _e,createVertexBufferLayout as ve,ComponentGeometryParameters as we,SourceGeometry as je}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as xe}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as Ce}from"../webgl-engine/core/material/RenderTexture.js";import{Attribute as Oe}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as Me}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as Ee}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as Te}from"../webgl-engine/materials/pbrUtils.js";import{writeAttribute as Re,writeBufferVec2 as Ue}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import Ve from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as He,isInEffectiveScaleRange as Se,validateScaleRange as Ae}from"../../support/layerViewUtils.js";import{TextureCompressionTracker as Le}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as Pe}from"../../../webscene/support/AlphaCutoff.js";class ke{constructor(e,t,i,s,r,o,n,a,l,d){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=s,this.vboMemoryUsage=r,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.nodeDepth=l,this.elevationRange=d,this.isLoaded=!1,this.isVisible=!1,this.usedMemory=this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage;const c=C();n?.getCenter(c),this._obbCenterX=c[0],this._obbCenterY=c[1],this._obbCenterZ=c[2];const h=n?.radius??-1;this._obbRadius=h,this._obbRadiusSquared=h*h;const u=n?.halfSize;this._obbShortestHalfsize=u?Math.min(u[0],u[1],u[2]):0}get mbsRadius(){return this._obbRadius}get mbsCenter(){return this.obb?.center??T}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const{_obbCenterX:i,_obbCenterY:s,_obbCenterZ:r}=this,o=i-e[0],n=s-e[1],a=r-e[2],l=o*t[0]+n*t[1]+a*t[2];return o*o+n*n+a*a-l*l<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){const t=this._obbRadius;if(t<0)return!0;const i=e.center,s=e.radius,r=t+s,o=this._obbCenterX-i[0];if(o>r)return!1;const n=this._obbCenterY-i[1];if(n>r)return!1;const a=this._obbCenterZ-i[2];if(a>r)return!1;const l=o*o+n*n+a*a;if(l>r*r)return!1;if(l<=(this._obbShortestHalfsize+s)**2)return!0;return Math.sqrt(l)+t<=s||(this.obb?.intersectSphere(e)??!0)}}function Ie(e){return Math.round(e/1048.576)/1e3}let Fe=class extends(ee(Ve)){get hasModifications(){return this._modifications&&this._modifications.length>0}constructor(e){super(e),this.type="integrated-mesh-3dtiles",this._compressionTracker=new Le,this._replacesTerrain=!1,this._isUsedAsGroundLayer=!1,this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._suspendedHandle=null,this._dbgFlags=new Set,this._memCache=e.view.resourceController.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._frustum=new me(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{r(t),this.layer=e}):null}canRecycleWith(e){return e.url===this.layer.url&&"integrated-mesh-3dtiles"===e.type&&e.replacesTerrain===this._replacesTerrain&&e.isUsedAsGroundLayer===this._isUsedAsGroundLayer}initialize(){this._dbgFlags.add(3),this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._replacesTerrain=this.layer.replacesTerrain,this._isUsedAsGroundLayer=this.layer.isUsedAsGroundLayer,this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o),!this._canProjectWithoutEngine())throw He("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=ie(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new ue(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),o),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),o),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),o),this._elevationProvider=new ne({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),e.elevationProvider.register(1,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([n(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),a(()=>this.fullOpacity,()=>this._opacityChange())]),this._suspendedHandle=n(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),o)});this.layer.queryElevationCallback=(e,t)=>this._wasm.queryElevation(this,e,t),this.addResolvingPromise(t)}get fullOpacity(){return this.layer.replacesTerrain&&has("enable-feature:oit-ground")?this.view.map.ground.opacity:1}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>this._collection.updateObjectOpacity(t,e))}_cameraChanged(){const e=this._frustum;e.update(this.view.state.contentCamera);const t=this._visibleObjects;let i=!1;this._loadedObjects.forEach(s=>{const r=s.obb?.intersectsFrustum(e)??!1;r!==s.isVisible&&(s.isVisible=r,r?t.add(s):t.delete(s),s.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,r)),i||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(r,s.elevationRange))}),i&&this._setVisibleElevationRangeDirty()}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}get ready(){return!this.layer.replacesTerrain||!!this._wasm?.isTerrainReady}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),se(this),this.layer.queryElevationCallback=null,this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._loadedObjects.clear(),this._usedMemory=0,this._cacheMemory=0,this._memCache.destroy(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=s(this._visibleGeometryChangedSchedulerHandle)}_modificationsChanged(){const e=this.layer.spatialReference,t=oe(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=k();this._layerClippingArea=be(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=l(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.layer.replacesTerrain),this.forEachComponentObject(t=>this._collection.updateMaterial(t,{slicePlaneEnabled:e}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,Q(e))}get _wasm(){return re(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return this.layer.isUsedAsGroundLayer||Se(this.layer.effectiveScaleRange,this.view.scale)}canResume(){const e=this.layer&&"effectiveScaleRange"in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&this.parent&&!this.parent.suspended&&this.view?.ready&&(this.layer.isUsedAsGroundLayer||Ae(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,i=0,s=0,r=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isLoaded?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,r++):(i+=n.textureMemoryUsage,s+=n.vboMemoryUsage,o++)}),new te(this.usedMemory,r,o,Ie(t),Ie(e),Ie(s),Ie(i))}_canProjectWithoutEngine(){if(this.view.state.isLocal){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return Q(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new pe(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new pe;0===this._visibleObjects.size?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this._forEachRelevantvisibleTile(t=>e.expandElevationRange(t.elevationRange)),e.minElevation===1/0&&e.setElevationRangeValues(0,0));const t=this._get("visibleElevationRange");return t&&t.minElevation===e.minElevation&&t.maxElevation===e.maxElevation?t:e}_setVisibleElevationRangeDirty(){this.notifyChange("visibleElevationRange")}_forEachRelevantvisibleTile(e){const{view:t}=this,{spatialReference:i}=t,s=i.isWGS84||i.isWebMercator||F(i)||D(i)||G(i);if(this.view.state.isGlobal||!s)return this.forEachVisibleTile(e);const r=H(i).radius,{eye:o,viewForward:n,near:a}=t.state.camera,l=y(C(),n),d=500,c=Math.max(o[2],d),h=c+r,u=Math.sqrt(h**2-r**2),m=Math.abs(Math.atan2(u,r))*r,p=c>.5*r?.5*Math.PI*r:m,b=C();this.forEachVisibleTile(t=>{const{mbsRadius:i,mbsCenter:s}=t;if(i<0)return;g(b,s,o);const r=_(b,l);Math.abs(r)<p&&r+i>a&&r-i<p&&e(t)})}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const i of e)for(const e of i.componentObjects)t(e)}isUpdating(){const e=this._wasm;return this._wasmLayerId>=0&&null!=e&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed){const e=`IntegratedMesh3DTilesLayerView3D[${this.layer?.title}]: createRenderable called on destroyed instance`;throw new Error(e)}const{meshData:t}=e;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const i=O(...t.desc.origin),s=this.view.basemapTerrain.spatialReference;let r=p;if(this.view.state.isGlobal){const e=b();A(S,i,e,s),r=h(m(),e)}const o=C(),n=ze(t.desc.obb);let a=0;const l={textureMemoryUsage:0},d=new Array,c=new Map,f=t.desc.prims.length,y=new Array,g=new pe;try{const e=this.view.state.isGlobal,h=e?H(this.view.spatialReference).radius:0;for(let b=0;b<f;b++){const f=t.desc.prims[b];this._dbg(2,JSON.stringify(f));if(null==ae[f.ptype]||null==t.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+f.ptype+"). Skipping primitive.");continue}const y=t.desc?.materials&&null!=f.materialId?t.desc.materials[f.materialId]:null,_=null!=y?y.lightingModel:"Unlit",{positionView:O,positionAttr:T,normalsView:H,normalsAttr:S,colorAttr:A,texCoord0Attr:k,indicesView:I}=this.getBufferViews(f,t.data.buffer,r);if(null==T||null==O||null==I)continue;const F=O.count,D=(e,t)=>!e||e.data.length/e.size===F||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!D(k,"numTexcoord")||!D(A,"numColors")||!D(S,"normals"))continue;const G=new _e(null!=A,null!=H,k?1:0),z=ve(G);for(let t=0;t<O.count;t++){O.getVec(t,o),v(o,o,i);const s=e?w(o)-h:o[2];g.expandElevationRangeValues(s,s)}const N=n?.clone()??Be(T,i);if(r!==p)for(let e=0;e<O.count;e++)O.getVec(e,o),j(o,o,r),O.setVec(e,o);const W=z.createBuffer(F);if(Re("position",T,null,null,W,0),null!=k){const e=W.getField("uv0",B);Ue(k,e,0)}null!=A&&Re("color",A,null,null,W,0),null!=S&&Re("normalCompressed",S,null,null,W,0);const $=new Uint32Array([0,I.typedBuffer.length]),q=new we(ge(z),this._shadeNormals||this.layer.replacesTerrain,G.textureCoordinateType),Z=new je({data:W.buffer,count:W.byteLength/z.stride},{positions:O.typedBuffer,indices:I.typedBuffer},I.typedBuffer,$,q),J=this.view.renderSpatialReference,X=C(),Y=[1,1,1];L(i,J,Y,s)||this._dbg(3,"Unsupported coordinate system for IM overlay"),P(i,J,X,s);let K=Promise.resolve(We),Q=R,ee=Pe,te=null,ie=null,se=null,re=null,oe=null,ne=1,ce=!1,he=2,ue=!1,me=M(0,0,0);const pe=E(Te),be="Pbr"===_;if(y){const e=e=>this._getTexture(e,t,c,l);te=e(y.baseColorTex),oe=be?e(y.metalTex):null,ie=be?e(y.emissiveTex):null,re=be?e(y.occlusionTex):null,se=be?e(y.normalTex):null;const i=[te,oe,ie,re,se].map(e=>e?.loadPromise??null);K=Promise.all(i),Q=U(y.baseColorFactor),ee=y.alphaCutoff??Pe,be&&(x(pe,y.metallicFactor,y.roughnessFactor,0),y.emissiveFactor&&(me=y.emissiveFactor)),ne=le[y.alphaMode],ce=y.isDoubleSided,he=de[y.faceCulling??"NotSet"],ue=this.layer.replacesTerrain}const fe=K.then(()=>()=>{if(this.destroyed){const e="Trying to add object to destroyed layer view";throw this._dbg(3,`${e} !== numPos. Skipping primitive.`),new Error(e)}te||console.error("No colour texture 1");const e=r===p?p:u(m(),r)??p,t=this._collection.createObject({toMapSpace:V(X[0],X[1],Y[0],Y[1]),transform:new xe(i,e),obb:N,geometry:Z,elevationAlignable:!1},{isIntegratedMesh:!0,baseColor:Q,textureAlphaCutoff:ee,mrrFactors:pe,baseColorTexture:te,metallicRoughnessTexture:oe,normalTexture:se,occlusionTexture:re,emissionTexture:ie,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:ne,doubleSided:ce,cullFace:he,isGround:ue,emissiveBaseColor:me,usePBR:be,slicePlaneEnabled:this.slicePlaneEnabled,objectOpacity:this.fullOpacity,polygonOffsetEnabled:!1,ellipsoidMode:1,applySSAO:this._applySSAO});return l.textureMemoryUsage+=te?.texture?.usedMemory??0,be&&(l.textureMemoryUsage+=(oe?.texture?.usedMemory??0)+(ie?.texture?.usedMemory??0)+(re?.texture?.usedMemory??0)+(se?.texture?.usedMemory??0)),a+=this._collection.getObjectGPUMemoryUsage(t),t});d.push(fe)}if(y.push(...await Promise.all(d)),this.destroyed){throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call")}}catch(G){throw c.forEach(e=>this._stage.removeTexture(e)),G}const _=y.map(e=>e()),T=new Array;c.forEach(e=>T.push(e));const{fullExtent:k}=this.layer;k?.hasZ&&k.zmax&&k.zmin&&(g.minElevation=Math.max(g.minElevation,k.zmin),g.maxElevation=Math.min(g.maxElevation,k.zmax));const I=_.reduceRight((e,t)=>e+t.intersectionGeometry.usedMemory,0),F=new ke(e.handle,_,T,I,a,l.textureMemoryUsage,n,e.stableNodeId,e.nodeDepth,g);this._lyrHandleToObjects.set(e.handle,F),this._memCache.put(Ne(F.handle),F);const{usedMemory:D}=F;return this._cacheMemory+=D,{memUsageBytes:D}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e)):this._dbg(3,`freeRendedrable on non-existent renderable ${e}`)}freeObject(e){const t=Ne(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){if(this.destroyed||this.destroying)return;const s=this._frustum,r=new Array;let o=!1,n=!1;for(let a=0;a<i;++a){if(!t[a])continue;const i=e[a],l=this._lyrHandleToObjects.get(i);if(l){if(l.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${l.stableNodeId}`);continue}o=!0,l.isLoaded=!0,this._loadedObjects.add(l),this._usedMemory+=l.usedMemory,this._cacheMemory-=l.usedMemory;const e=l.obb?.intersectsFrustum(s)??!0;l.isVisible=e,e&&(this._visibleObjects.add(l),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,l.elevationRange)),e&&l.obb&&r.push(l.obb),l.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(Ne(i))}else this._dbg(3,`Tried to mark Non existent object ${i} as loaded`)}for(let a=0;a<i;++a){const i=e[a];if(t[a])continue;const s=this._lyrHandleToObjects.get(i);if(s){if(!s.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${s.stableNodeId}`);continue}const e=this._visibleObjects.delete(s);s.isVisible=!1,s.isLoaded=!1,this._loadedObjects.delete(s),e&&(this._visibleGeometryChanged(),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,s.elevationRange)),this._usedMemory-=s.usedMemory,this._cacheMemory+=s.usedMemory,e&&s.obb&&r.push(s.obb),s.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(Ne(i),s)}else this._dbg(3,`Tried to mark Non existent object ${i} as not loaded`)}o&&this._visibleGeometryChanged(),this._elevationProvider.notifyObjectsChanged(r),n&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){const{visibleElevationRange:i}=this,{minElevation:s,maxElevation:r}=t;return e?s<i.minElevation||r>i.maxElevation:s===i.minElevation||r===i.maxElevation}_getTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=i.get(r)??this._createTexture(e,t,i,s);return o?new Ce(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!r.mipCount||a>1,d=ce[e.wrapMode??"None"];let c=r.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,r.data.byteOffset,r.data.byteCount);let u=null,m=null,p=null;switch(r.format){case"Raw":"R8"===r.pixelFormat?(u=h,c=6403,m=""):"Rgb8"===r.pixelFormat?(u=h,c=6407,m=""):"Rgba8"===r.pixelFormat&&(u=h,c=6408,m="");break;case"Dxt1":u=h,c=6407,m="image/vnd-ms.dds";break;case"Dxt5":u=h,c=6408,m="image/vnd-ms.dds";break;case"Basis":u=h,c=6407,m="image/ktx2";break;case"Png":m="image/png",p=document.createElement("img");break;case"Jpeg":m="image/jpeg",p=document.createElement("img");break;case"Etc2":m="image/ktx",p=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(p&&m){const e=new Blob([h],{type:m});p.src=URL.createObjectURL(e),u=p}if(u&&null!=m){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(s.textureMemoryUsage-=e)}}:void 0,t=new Me(u,{mipmap:l,maxAnisotropy:a,encoding:m,wrap:d,pixelFormat:c,compressionOptions:e,noUnpackFlip:!0,width:r.mip0Width,height:r.mip0Height});return this._stage.addTexture(t),i.set(r,t),t}return null}getBufferViews(e,t,i){let s,r,o,n,a,l,d,c=null;for(let u=0;u<e.atrbs.length;u++){const d=e.atrbs[u],{view:m}=d,p=void 0,b=m.byteOffset+m.byteCount,f=m.byteCount/he[m.type],y=I(f);try{switch(d.sem){case"Position":3!==m.ncomp||"F32"!==m.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+m+")"):(s=new $(t,m.byteOffset,p,b),r=new Oe(s.typedBuffer,y,3));break;case"Normal":if(3!==m.ncomp||"F32"!==m.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+m+")");else{const e=new $(t,m.byteOffset,p,b),s=Ee(e.typedBuffer,i);a=new J(s.buffer),l=new Oe(a.typedBuffer,y,2)}break;case"TexCoord":2!==m.ncomp||"F32"!==m.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+m+")"):void 0===n&&(n=new Oe(new B(t,m.byteOffset,p,b).typedBuffer,y,2));break;case"Color":4===m.ncomp?("F32"===m.type&&(c=new z(t,m.byteOffset,p,b)),"U8"===m.type&&(c=new N(t,m.byteOffset,p,b)),"U16"===m.type&&(c=new W(t,m.byteOffset,p,b))):3===m.ncomp&&("F32"===m.type&&(c=new $(t,m.byteOffset,p,b)),"U8"===m.type&&(c=new q(t,m.byteOffset,p,b)),"U16"===m.type&&(c=new Z(t,m.byteOffset,p,b))),null==c?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+m+")"):o=new Oe(c.typedBuffer,y,m.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+d.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,s=void 0,r=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":d=new Y(t,i.byteOffset,s,r);break;case"U32":d=new X(t,i.byteOffset,s,r);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==d&&null!=s){const e=s.count;d=d=e<65535?new Y(new Uint16Array(e).buffer):new X(new Uint32Array(e).buffer);for(let t=0;t<e;t++)d.set(t,t)}return{positionView:s,positionAttr:r,colorAttr:o,texCoord0Attr:n,indicesView:d,normalsView:a,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>!(this.layer.isUsedAsGroundLayer&&"replace"!==e.type)).toArray(),this._modifications.length<e.length&&t.getLogger(this).info("Ground layers only support replace modifications. Other modification types have been ignored.")},o),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([d()],Fe.prototype,"fullOpacity",null),e([d({readOnly:!0})],Fe.prototype,"ready",null),e([d({type:[K]})],Fe.prototype,"_modifications",void 0),e([d()],Fe.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([d()],Fe.prototype,"layer",void 0),e([d({readOnly:!0})],Fe.prototype,"visibleAtCurrentScale",null),e([d({readOnly:!0})],Fe.prototype,"_collection",null),e([d()],Fe.prototype,"elevationOffset",null),e([d({readOnly:!0})],Fe.prototype,"visibleElevationRange",null),Fe=e([c("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Fe);const De=Fe,Ge=C();function Be(e,t){const i=fe(e);return v(Ge,i.center,t),i.center=Ge,i}function ze(e){return e?new ye(e.center,e.halfSize,f(...e.quaternion)):null}function Ne(e){return`${e}`}const We=new Array;export{De as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as s}from"../../../core/maybe.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{initial as o,watch as n,when as a}from"../../../core/reactiveUtils.js";import{schedule as l}from"../../../core/scheduling.js";import{property as d,subclass as c}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as h,invert as u}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as m,IDENTITY as p}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as f}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as y,sub as g,dot as _,add as v,length as w,transformMat3 as j,set as x}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as C,freeze as O,fromValues as M,clone as E,ZEROS as T}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as R,clone as U,fromValues as V}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMoon as H,isMars as S,getReferenceEllipsoid as A,SphericalECEFSpatialReferenceLike as L}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as P}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as k}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as I}from"../../../geometry/projection/projectVectorToVector.js";import{create as F}from"../../../geometry/support/aaBoundingRect.js";import{getContinuousIndexArray as D}from"../../../geometry/support/Indices.js";import{isCGCS2000 as G}from"../../../geometry/support/spatialReferenceUtils.js";import{BufferViewVec2f as B,BufferViewVec4f as z,BufferViewVec4u8 as N,BufferViewVec4u16 as W,BufferViewVec3f as $,BufferViewVec3u8 as q,BufferViewVec3u16 as Z,BufferViewInt16 as J,BufferViewUint32 as X,BufferViewUint16 as Y}from"../../../geometry/support/buffer/BufferView.js";import K from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as Q}from"../../../support/elevationInfoUtils.js";import{LayerView3D as ee}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as te}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as ie,removeLayerViewFromWasm as se,getLyr3DWasm as re}from"./Lyr3DWasm.js";import{toWasmModification as oe}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as ne}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as ae,alphaModeConversion as le,faceCullingConversion as de,wrapModeConversion as ce,lyr3DTypeToByteSize as he}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as ue}from"./support/Tiles3DIntersectionHandler.js";import{Frustum as me}from"../state/Frustum.js";import{ElevationRange as pe}from"../support/ElevationRange.js";import{toBoundingRect as be}from"../support/extentUtils.js";import{compute as fe,Obb as ye}from"../support/orientedBoundingBox.js";import{glLayout as ge}from"../support/buffer/glUtil.js";import{VertexBufferLayoutCreationParameters as _e,createVertexBufferLayout as ve,ComponentGeometryParameters as we,SourceGeometry as je}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as xe}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as Ce}from"../webgl-engine/core/material/RenderTexture.js";import{Attribute as Oe}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as Me}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as Ee}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as Te}from"../webgl-engine/materials/pbrUtils.js";import{writeAttribute as Re,writeBufferVec2 as Ue}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import Ve from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as He,isInEffectiveScaleRange as Se,validateScaleRange as Ae}from"../../support/layerViewUtils.js";import{TextureCompressionTracker as Le}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as Pe}from"../../../webscene/support/AlphaCutoff.js";class ke{constructor(e,t,i,s,r,o,n,a,l,d){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=s,this.vboMemoryUsage=r,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.nodeDepth=l,this.elevationRange=d,this.isLoaded=!1,this.isVisible=!1,this.usedMemory=this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage;const c=C();n?.getCenter(c),this._obbCenterX=c[0],this._obbCenterY=c[1],this._obbCenterZ=c[2];const h=n?.radius??-1;this._obbRadius=h,this._obbRadiusSquared=h*h;const u=n?.halfSize;this._obbShortestHalfsize=u?Math.min(u[0],u[1],u[2]):0}get mbsRadius(){return this._obbRadius}get mbsCenter(){return this.obb?.center??T}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const{_obbCenterX:i,_obbCenterY:s,_obbCenterZ:r}=this,o=i-e[0],n=s-e[1],a=r-e[2],l=o*t[0]+n*t[1]+a*t[2];return o*o+n*n+a*a-l*l<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){const t=this._obbRadius;if(t<0)return!0;const i=e.center,s=e.radius,r=t+s,o=this._obbCenterX-i[0];if(o>r)return!1;const n=this._obbCenterY-i[1];if(n>r)return!1;const a=this._obbCenterZ-i[2];if(a>r)return!1;const l=o*o+n*n+a*a;if(l>r*r)return!1;if(l<=(this._obbShortestHalfsize+s)**2)return!0;return Math.sqrt(l)+t<=s||(this.obb?.intersectSphere(e)??!0)}}function Ie(e){return Math.round(e/1048.576)/1e3}let Fe=class extends(ee(Ve)){get hasModifications(){return this._modifications&&this._modifications.length>0}constructor(e){super(e),this.type="integrated-mesh-3dtiles",this._compressionTracker=new Le,this._replacesTerrain=!1,this._isUsedAsGroundLayer=!1,this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._suspendedHandle=null,this._dbgFlags=new Set,this._memCache=e.view.resourceController.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._frustum=new me(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{r(t),this.layer=e}):null}canRecycleWith(e){return e.url===this.layer.url&&"integrated-mesh-3dtiles"===e.type&&e.replacesTerrain===this._replacesTerrain&&e.isUsedAsGroundLayer===this._isUsedAsGroundLayer}initialize(){this._dbgFlags.add(3),this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._replacesTerrain=this.layer.replacesTerrain,this._isUsedAsGroundLayer=this.layer.isUsedAsGroundLayer,this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o),!this._canProjectWithoutEngine())throw He("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=ie(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new ue(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),o),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),o),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),o),this._elevationProvider=new ne({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),e.elevationProvider.register(1,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([n(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),a(()=>this.fullOpacity,()=>this._opacityChange())]),this._suspendedHandle=n(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),o)});this.layer.queryElevationCallback=(e,t)=>this._wasm.queryElevation(this,e,t),this.addResolvingPromise(t)}get fullOpacity(){return this.layer.replacesTerrain&&has("enable-feature:oit-ground")?this.view.map.ground.opacity:1}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>this._collection.updateObjectOpacity(t,e))}_cameraChanged(){const e=this._frustum;e.update(this.view.state.contentCamera);const t=this._visibleObjects;let i=!1;this._loadedObjects.forEach(s=>{const r=s.obb?.intersectsFrustum(e)??!1;r!==s.isVisible&&(s.isVisible=r,r?t.add(s):t.delete(s),s.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,r)),i||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(r,s.elevationRange))}),i&&this._setVisibleElevationRangeDirty()}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}get ready(){return!this.layer.replacesTerrain||!!this._wasm?.isTerrainReady}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),se(this),this.layer.queryElevationCallback=null,this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._loadedObjects.clear(),this._usedMemory=0,this._cacheMemory=0,this._memCache.destroy(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=s(this._visibleGeometryChangedSchedulerHandle)}_modificationsChanged(){const e=this.layer.spatialReference,t=oe(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=F();this._layerClippingArea=be(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=l(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.layer.replacesTerrain),this.forEachComponentObject(t=>this._collection.updateMaterial(t,{slicePlaneEnabled:e}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,Q(e))}get _wasm(){return re(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return this.layer.isUsedAsGroundLayer||Se(this.layer.effectiveScaleRange,this.view.scale)}canResume(){const e=this.layer&&"effectiveScaleRange"in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&this.parent&&!this.parent.suspended&&this.view?.ready&&(this.layer.isUsedAsGroundLayer||Ae(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,i=0,s=0,r=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isLoaded?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,r++):(i+=n.textureMemoryUsage,s+=n.vboMemoryUsage,o++)}),new te(this.usedMemory,r,o,Ie(t),Ie(e),Ie(s),Ie(i))}_canProjectWithoutEngine(){if(this.view.state.isLocal){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return Q(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new pe(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new pe;0===this._visibleObjects.size?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this._forEachRelevantvisibleTile(t=>e.expandElevationRange(t.elevationRange)),e.minElevation===1/0&&e.setElevationRangeValues(0,0));const t=this._get("visibleElevationRange");return t&&t.minElevation===e.minElevation&&t.maxElevation===e.maxElevation?t:e}_setVisibleElevationRangeDirty(){this.notifyChange("visibleElevationRange")}_forEachRelevantvisibleTile(e){const{view:t}=this,{spatialReference:i}=t,s=i.isWGS84||i.isWebMercator||G(i)||H(i)||S(i);if(this.view.state.isGlobal||!s)return this.forEachVisibleTile(e);const r=A(i).radius,{eye:o,viewForward:n,near:a}=t.state.camera,l=y(C(),n),d=500,c=Math.max(o[2],d),h=c+r,u=Math.sqrt(h**2-r**2),m=Math.abs(Math.atan2(u,r))*r,p=c>.5*r?.5*Math.PI*r:m,b=C();this.forEachVisibleTile(t=>{const{mbsRadius:i,mbsCenter:s}=t;if(i<0)return;g(b,s,o);const r=_(b,l);Math.abs(r)<p&&r+i>a&&r-i<p&&e(t)})}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const i of e)for(const e of i.componentObjects)t(e)}isUpdating(){const e=this._wasm;return this._wasmLayerId>=0&&null!=e&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed){const e=`IntegratedMesh3DTilesLayerView3D[${this.layer?.title}]: createRenderable called on destroyed instance`;throw new Error(e)}const{meshData:t}=e;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const i=O(...t.desc.origin),s=this.view.basemapTerrain.spatialReference;let r=p;if(this.view.state.isGlobal){const e=b();P(L,i,e,s),r=h(m(),e)}const o=C(),n=ze(t.desc.obb);let a=0;const l={textureMemoryUsage:0},d=new Array,c=new Map,f=t.desc.prims.length,y=new Array,g=new pe;try{const e=this.view.state.isGlobal,h=e?A(this.view.spatialReference).radius:0;for(let b=0;b<f;b++){const f=t.desc.prims[b];this._dbg(2,JSON.stringify(f));if(null==ae[f.ptype]||null==t.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+f.ptype+"). Skipping primitive.");continue}const y=t.desc?.materials&&null!=f.materialId?t.desc.materials[f.materialId]:null,_=null!=y?y.lightingModel:"Unlit",{positionView:O,positionAttr:T,normalsView:H,normalsAttr:S,colorAttr:A,texCoord0Attr:L,indicesView:P}=this.getBufferViews(f,t.data.buffer,r);if(null==T||null==O||null==P)continue;const F=O.count,D=(e,t)=>!e||e.data.length/e.size===F||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!D(L,"numTexcoord")||!D(A,"numColors")||!D(S,"normals"))continue;const G=new _e(null!=A,null!=H,L?1:0),z=ve(G);for(let t=0;t<O.count;t++){O.getVec(t,o),v(o,o,i);const s=e?w(o)-h:o[2];g.expandElevationRangeValues(s,s)}const N=n?.clone()??Be(T,i);if(r!==p)for(let e=0;e<O.count;e++)O.getVec(e,o),j(o,o,r),O.setVec(e,o);const W=z.createBuffer(F);if(Re("position",T,null,null,W,0),null!=L){const e=W.getField("uv0",B);Ue(L,e,0)}null!=A&&Re("color",A,null,null,W,0),null!=S&&Re("normalCompressed",S,null,null,W,0);const $=new Uint32Array([0,P.typedBuffer.length]),q=new we(ge(z),this._shadeNormals||this.layer.replacesTerrain,G.textureCoordinateType),Z=new je({data:W.buffer,count:W.byteLength/z.stride},{positions:O.typedBuffer,indices:P.typedBuffer},P.typedBuffer,$,q),J=this.view.renderSpatialReference,X=C(),Y=[1,1,1];k(i,J,Y,s)||this._dbg(3,"Unsupported coordinate system for IM overlay"),I(i,J,X,s);let K=Promise.resolve(We),Q=R,ee=Pe,te=null,ie=null,se=null,re=null,oe=null,ne=1,ce=!1,he=2,ue=!1,me=M(0,0,0);const pe=E(Te),be="Pbr"===_;if(y){const e=e=>this._getTexture(e,t,c,l);te=e(y.baseColorTex),oe=be?e(y.metalTex):null,ie=be?e(y.emissiveTex):null,re=be?e(y.occlusionTex):null,se=be?e(y.normalTex):null;const i=[te,oe,ie,re,se].map(e=>e?.loadPromise??null);K=Promise.all(i),Q=U(y.baseColorFactor),ee=y.alphaCutoff??Pe,be&&(x(pe,y.metallicFactor,y.roughnessFactor,0),y.emissiveFactor&&(me=y.emissiveFactor)),ne=le[y.alphaMode],ce=y.isDoubleSided,he=de[y.faceCulling??"NotSet"],ue=this.layer.replacesTerrain}const fe=K.then(()=>()=>{if(this.destroyed){const e="Trying to add object to destroyed layer view";throw this._dbg(3,`${e} !== numPos. Skipping primitive.`),new Error(e)}te||console.error("No colour texture 1");const e=r===p?p:u(m(),r)??p,t=this._collection.createObject({toMapSpace:V(X[0],X[1],Y[0],Y[1]),transform:new xe(i,e),obb:N,geometry:Z,elevationAlignable:!1},{isIntegratedMesh:!0,baseColor:Q,textureAlphaCutoff:ee,mrrFactors:pe,baseColorTexture:te,metallicRoughnessTexture:oe,normalTexture:se,occlusionTexture:re,emissionTexture:ie,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:ne,doubleSided:ce,cullFace:he,isGround:ue,emissiveBaseColor:me,usePBR:be,slicePlaneEnabled:this.slicePlaneEnabled,objectOpacity:this.fullOpacity,polygonOffsetEnabled:!1,ellipsoidMode:1,applySSAO:this._applySSAO});return l.textureMemoryUsage+=te?.texture?.usedMemory??0,be&&(l.textureMemoryUsage+=(oe?.texture?.usedMemory??0)+(ie?.texture?.usedMemory??0)+(re?.texture?.usedMemory??0)+(se?.texture?.usedMemory??0)),a+=this._collection.getObjectGPUMemoryUsage(t),t});d.push(fe)}if(y.push(...await Promise.all(d)),this.destroyed){throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call")}}catch(G){throw c.forEach(e=>this._stage.removeTexture(e)),G}const _=y.map(e=>e()),T=new Array;c.forEach(e=>T.push(e));const{fullExtent:H}=this.layer;H?.hasZ&&H.zmax&&H.zmin&&(g.minElevation=Math.max(g.minElevation,H.zmin),g.maxElevation=Math.min(g.maxElevation,H.zmax));const S=_.reduceRight((e,t)=>e+t.intersectionGeometry.usedMemory,0),F=new ke(e.handle,_,T,S,a,l.textureMemoryUsage,n,e.stableNodeId,e.nodeDepth,g);this._lyrHandleToObjects.set(e.handle,F),this._memCache.put(Ne(F.handle),F);const{usedMemory:D}=F;return this._cacheMemory+=D,{memUsageBytes:D}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e)):this._dbg(3,`freeRendedrable on non-existent renderable ${e}`)}freeObject(e){const t=Ne(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){if(this.destroyed||this.destroying)return;const s=this._frustum,r=new Array;let o=!1,n=!1;for(let a=0;a<i;++a){if(!t[a])continue;const i=e[a],l=this._lyrHandleToObjects.get(i);if(l){if(l.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${l.stableNodeId}`);continue}o=!0,l.isLoaded=!0,this._loadedObjects.add(l),this._usedMemory+=l.usedMemory,this._cacheMemory-=l.usedMemory;const e=l.obb?.intersectsFrustum(s)??!0;l.isVisible=e,e&&(this._visibleObjects.add(l),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,l.elevationRange)),e&&l.obb&&r.push(l.obb),l.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(Ne(i))}else this._dbg(3,`Tried to mark Non existent object ${i} as loaded`)}for(let a=0;a<i;++a){const i=e[a];if(t[a])continue;const s=this._lyrHandleToObjects.get(i);if(s){if(!s.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${s.stableNodeId}`);continue}const e=this._visibleObjects.delete(s);s.isVisible=!1,s.isLoaded=!1,this._loadedObjects.delete(s),e&&(this._visibleGeometryChanged(),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,s.elevationRange)),this._usedMemory-=s.usedMemory,this._cacheMemory+=s.usedMemory,e&&s.obb&&r.push(s.obb),s.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(Ne(i),s)}else this._dbg(3,`Tried to mark Non existent object ${i} as not loaded`)}o&&this._visibleGeometryChanged(),this._elevationProvider.notifyObjectsChanged(r),n&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){const{visibleElevationRange:i}=this,{minElevation:s,maxElevation:r}=t;return e?s<i.minElevation||r>i.maxElevation:s===i.minElevation||r===i.maxElevation}_getTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=i.get(r)??this._createTexture(e,t,i,s);return o?new Ce(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!r.mipCount||a>1,d=ce[e.wrapMode??"None"];let c=r.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,r.data.byteOffset,r.data.byteCount);let u=null,m=null,p=null;switch(r.format){case"Raw":"R8"===r.pixelFormat?(u=h,c=6403,m=""):"Rgb8"===r.pixelFormat?(u=h,c=6407,m=""):"Rgba8"===r.pixelFormat&&(u=h,c=6408,m="");break;case"Dxt1":u=h,c=6407,m="image/vnd-ms.dds";break;case"Dxt5":u=h,c=6408,m="image/vnd-ms.dds";break;case"Basis":u=h,c=6407,m="image/ktx2";break;case"Png":m="image/png",p=document.createElement("img");break;case"Jpeg":m="image/jpeg",p=document.createElement("img");break;case"Etc2":m="image/ktx",p=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(p&&m){const e=new Blob([h],{type:m});p.src=URL.createObjectURL(e),u=p}if(u&&null!=m){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(s.textureMemoryUsage-=e)}}:void 0,t=new Me(u,{mipmap:l,maxAnisotropy:a,encoding:m,wrap:d,pixelFormat:c,compressionOptions:e,noUnpackFlip:!0,width:r.mip0Width,height:r.mip0Height});return this._stage.addTexture(t),i.set(r,t),t}return null}getBufferViews(e,t,i){let s,r,o,n,a,l,d,c=null;for(let u=0;u<e.atrbs.length;u++){const d=e.atrbs[u],{view:m}=d,p=void 0,b=m.byteOffset+m.byteCount,f=m.byteCount/he[m.type],y=D(f);try{switch(d.sem){case"Position":3!==m.ncomp||"F32"!==m.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+m+")"):(s=new $(t,m.byteOffset,p,b),r=new Oe(s.typedBuffer,y,3));break;case"Normal":if(3!==m.ncomp||"F32"!==m.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+m+")");else{const e=new $(t,m.byteOffset,p,b),s=Ee(e.typedBuffer,i);a=new J(s.buffer),l=new Oe(a.typedBuffer,y,2)}break;case"TexCoord":2!==m.ncomp||"F32"!==m.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+m+")"):void 0===n&&(n=new Oe(new B(t,m.byteOffset,p,b).typedBuffer,y,2));break;case"Color":4===m.ncomp?("F32"===m.type&&(c=new z(t,m.byteOffset,p,b)),"U8"===m.type&&(c=new N(t,m.byteOffset,p,b)),"U16"===m.type&&(c=new W(t,m.byteOffset,p,b))):3===m.ncomp&&("F32"===m.type&&(c=new $(t,m.byteOffset,p,b)),"U8"===m.type&&(c=new q(t,m.byteOffset,p,b)),"U16"===m.type&&(c=new Z(t,m.byteOffset,p,b))),null==c?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+m+")"):o=new Oe(c.typedBuffer,y,m.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+d.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,s=void 0,r=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":d=new Y(t,i.byteOffset,s,r);break;case"U32":d=new X(t,i.byteOffset,s,r);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==d&&null!=s){const e=s.count;d=d=e<65535?new Y(new Uint16Array(e).buffer):new X(new Uint32Array(e).buffer);for(let t=0;t<e;t++)d.set(t,t)}return{positionView:s,positionAttr:r,colorAttr:o,texCoord0Attr:n,indicesView:d,normalsView:a,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>!(this.layer.isUsedAsGroundLayer&&"replace"!==e.type)).toArray(),this._modifications.length<e.length&&t.getLogger(this).info("Ground layers only support replace modifications. Other modification types have been ignored.")},o),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([d()],Fe.prototype,"fullOpacity",null),e([d({readOnly:!0})],Fe.prototype,"ready",null),e([d({type:[K]})],Fe.prototype,"_modifications",void 0),e([d()],Fe.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([d()],Fe.prototype,"layer",void 0),e([d({readOnly:!0})],Fe.prototype,"visibleAtCurrentScale",null),e([d({readOnly:!0})],Fe.prototype,"_collection",null),e([d()],Fe.prototype,"elevationOffset",null),e([d({readOnly:!0})],Fe.prototype,"visibleElevationRange",null),Fe=e([c("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Fe);const De=Fe,Ge=C();function Be(e,t){const i=fe(e);return v(Ge,i.center,t),i.center=Ge,i}function ze(e){return e?new ye(e.center,e.halfSize,f(...e.quaternion)):null}function Ne(e){return`${e}`}const We=new Array;export{De as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{hasScaling as e}from"../../../core/mathUtils.js";import r from"../../../geometry/SpatialReference.js";import{ensurePackedMat4f64 as t,ensurePackedArray as o}from"../../../geometry/support/DoubleArray.js";import n from"../../../geometry/support/MeshGeoreferencedVertexSpace.js";import s from"../../../geometry/support/MeshLocalVertexSpace.js";import{b as i,n as a}from"../../../chunks/vec3.js";import{get as f,cleanup as c}from"../../../libs/i3s/I3SModule.js";import{TransformedGeometry as l,TransformedData as u}from"./SceneLayerWorkerHandle.js";async function m(e){A=await v();const r=[e.geometryBuffer];return{result:x(A,e,r),transferList:r}}async function p(e){A=await v();const r=[e.geometryBuffer],{geometryBuffer:t}=e,o=t.byteLength,n=A._malloc(o),s=new Uint8Array(A.HEAPU8.buffer,n,o);s.set(new Uint8Array(t));const i=A.dracoDecompressPointCloudData(n,s.byteLength);if(A._free(n),i.error.length>0)throw new Error(`i3s.wasm: ${i.error}`);const a=i.featureIds?.length>0?i.featureIds.slice():null,f=i.positions.slice();return a&&r.push(a.buffer),r.push(f.buffer),{result:{positions:f,featureIds:a},transferList:r}}async function y(e){await v(),S(e);const r={buffer:e.buffer};return{result:r,transferList:[r.buffer]}}async function h(e){await v(),L(e)}async function d(e){A=await v(),A.setLegacySchema(e.context,e.jsonSchema)}async function g(e){const{localMatrix:i,origin:a,positions:f,vertexSpace:c}=e,l=r.fromJSON(e.inSpatialReference),u=r.fromJSON(e.outSpatialReference),m=i?t(i):void 0,p=o(a);let y;const[{projectBuffer:h},{initializeProjection:d}]=await Promise.all([import("../../../geometry/projection/projectBuffer.js"),import("../../../geometry/projectionUtils.js")]);await d(l,u);const g=[0,0,0];if(!h(p,l,0,g,u,0))throw new Error("Failed to project");if("georeferenced"===c.type&&null==c.origin){if(y=new Float64Array(f.length),!h(f,l,0,y,u,0,y.length/3))throw new Error("Failed to project")}else{const e="georeferenced"===c.type?n.fromJSON(c):s.fromJSON(c),{projectMeshVertexPositions:r}=await import("../../../geometry/support/meshUtils/projectMeshVertexPositions.js"),t=r({vertexAttributes:{position:f},transform:m?{localMatrix:m}:void 0,vertexSpace:e,spatialReference:l},u);if(!t)throw new Error("Failed to project");y=t}const b=y.length,[w,j,A]=g;for(let r=0;r<b;r+=3)y[r]-=w,y[r+1]-=j,y[r+2]-=A;return{result:{projected:y,original:f,projectedOrigin:g},transferList:[y.buffer,f.buffer]}}async function b({normalMatrix:r,normals:t}){const o=new Float32Array(t.length);return i(o,t,r),e(r)&&a(o,o),{result:{transformed:o,original:t},transferList:[o.buffer,t.buffer]}}function w(e){U(e)}let j,A;function L(e){if(!A)return;const r=e.modifications,t=A._malloc(8*r.length),o=new Float64Array(A.HEAPU8.buffer,t,r.length);for(let n=0;n<r.length;++n)o[n]=r[n];A.setModifications(e.context,t,r.length,e.isGeodetic),A._free(t)}function x(e,r,t){const{context:o,globalTrafo:n,mbs:s,obbData:i,layouts:a,needNormals:f,elevationOffset:c,geometryBuffer:m,geometryDescriptor:p,indexToVertexProjector:y,vertexToRenderProjector:h,normalReferenceFrame:d}=r,g=e._malloc(m.byteLength),b=33,w=e._malloc(b*Float64Array.BYTES_PER_ELEMENT),j=new Uint8Array(e.HEAPU8.buffer,g,m.byteLength);j.set(new Uint8Array(m));const A=new Float64Array(e.HEAPU8.buffer,w,b);P(A,[NaN,NaN,NaN],0);let L=3;P(A,n,L),L+=16,P(A,s.center,L),L+=3,A[L++]=s.radius,i&&P(A,i,L++);const x={isDraco:!1,isLegacy:!1,color:a.some(e=>e.some(e=>"color"===e.name)),normal:f&&a.some(e=>e.some(e=>"normalCompressed"===e.name)),uv0:a.some(e=>e.some(e=>"uv0"===e.name)),uvRegion:a.some(e=>e.some(e=>"uvRegion"===e.name)),featureIndex:p.featureIndex},E=e.process(o,!!i,g,j.byteLength,p,x,w,c,y,h,d);if(e._free(w),e._free(g),E.error.length>0)throw new Error(`i3s.wasm: ${E.error}`);if(E.discarded)return null;const S=E.componentOffsets.length>0?E.componentOffsets.slice():null,U=E.featureIds.length>0?E.featureIds.slice():null,_=E.anchorIds.length>0?Array.from(E.anchorIds):null,v=E.anchors.length>0?Array.from(E.anchors):null,N=E.interleavedVertedData.slice().buffer,F=1===E.indicesType?new Uint16Array(E.indices.buffer,E.indices.byteOffset,E.indices.byteLength/2).slice():new Uint32Array(E.indices.buffer,E.indices.byteOffset,E.indices.byteLength/4).slice(),I=E.positions.slice(),{buffer:M,byteOffset:O,byteLength:B}=E.positionIndices,R=1===E.positionIndicesType?new Uint16Array(M,O,B/2).slice():new Uint32Array(M,O,B/4).slice(),T=new l(r.layouts[0],N,F,E.hasColors,E.hasModifications,{data:I,indices:R});return U&&t.push(U.buffer),S&&t.push(S.buffer),t.push(N),t.push(F.buffer),t.push(I.buffer),t.push(R.buffer),new u(S,U,_,v,T,n,E.obb)}function E(e){return 0===e?0:1===e?1:2===e?2:3}function S(e){if(!A)return;const{context:r,buffer:t}=e,o=A._malloc(t.byteLength),n=t.byteLength/Float64Array.BYTES_PER_ELEMENT,s=new Float64Array(A.HEAPU8.buffer,o,n),i=new Float64Array(t);s.set(i),A.filterOBBs(r,o,n),i.set(s),A._free(o)}function U(e){
|
|
5
|
+
import{hasScaling as e}from"../../../core/mathUtils.js";import r from"../../../geometry/SpatialReference.js";import{ensurePackedMat4f64 as t,ensurePackedArray as o}from"../../../geometry/support/DoubleArray.js";import n from"../../../geometry/support/MeshGeoreferencedVertexSpace.js";import s from"../../../geometry/support/MeshLocalVertexSpace.js";import{b as i,n as a}from"../../../chunks/vec3.js";import{get as f,cleanup as c}from"../../../libs/i3s/I3SModule.js";import{TransformedGeometry as l,TransformedData as u}from"./SceneLayerWorkerHandle.js";async function m(e){A=await v();const r=[e.geometryBuffer];return{result:x(A,e,r),transferList:r}}async function p(e){A=await v();const r=[e.geometryBuffer],{geometryBuffer:t}=e,o=t.byteLength,n=A._malloc(o),s=new Uint8Array(A.HEAPU8.buffer,n,o);s.set(new Uint8Array(t));const i=A.dracoDecompressPointCloudData(n,s.byteLength);if(A._free(n),i.error.length>0)throw new Error(`i3s.wasm: ${i.error}`);const a=i.featureIds?.length>0?i.featureIds.slice():null,f=i.positions.slice();return a&&r.push(a.buffer),r.push(f.buffer),{result:{positions:f,featureIds:a},transferList:r}}async function y(e){await v(),S(e);const r={buffer:e.buffer};return{result:r,transferList:[r.buffer]}}async function h(e){await v(),L(e)}async function d(e){A=await v(),A.setLegacySchema(e.context,e.jsonSchema)}async function g(e){const{localMatrix:i,origin:a,positions:f,vertexSpace:c}=e,l=r.fromJSON(e.inSpatialReference),u=r.fromJSON(e.outSpatialReference),m=i?t(i):void 0,p=o(a);let y;const[{projectBuffer:h},{initializeProjection:d}]=await Promise.all([import("../../../geometry/projection/projectBuffer.js"),import("../../../geometry/projectionUtils.js")]);await d(l,u);const g=[0,0,0];if(!h(p,l,0,g,u,0))throw new Error("Failed to project");if("georeferenced"===c.type&&null==c.origin){if(y=new Float64Array(f.length),!h(f,l,0,y,u,0,y.length/3))throw new Error("Failed to project")}else{const e="georeferenced"===c.type?n.fromJSON(c):s.fromJSON(c),{projectMeshVertexPositions:r}=await import("../../../geometry/support/meshUtils/projectMeshVertexPositions.js"),t=r({vertexAttributes:{position:f},transform:m?{localMatrix:m}:void 0,vertexSpace:e,spatialReference:l},u);if(!t)throw new Error("Failed to project");y=t}const b=y.length,[w,j,A]=g;for(let r=0;r<b;r+=3)y[r]-=w,y[r+1]-=j,y[r+2]-=A;return{result:{projected:y,original:f,projectedOrigin:g},transferList:[y.buffer,f.buffer]}}async function b({normalMatrix:r,normals:t}){const o=new Float32Array(t.length);return i(o,t,r),e(r)&&a(o,o),{result:{transformed:o,original:t},transferList:[o.buffer,t.buffer]}}function w(e){U(e)}let j,A;function L(e){if(!A)return;const r=e.modifications,t=A._malloc(8*r.length),o=new Float64Array(A.HEAPU8.buffer,t,r.length);for(let n=0;n<r.length;++n)o[n]=r[n];A.setModifications(e.context,t,r.length,e.isGeodetic),A._free(t)}function x(e,r,t){const{context:o,globalTrafo:n,mbs:s,obbData:i,layouts:a,needNormals:f,elevationOffset:c,geometryBuffer:m,geometryDescriptor:p,indexToVertexProjector:y,vertexToRenderProjector:h,normalReferenceFrame:d}=r,g=e._malloc(m.byteLength),b=33,w=e._malloc(b*Float64Array.BYTES_PER_ELEMENT),j=new Uint8Array(e.HEAPU8.buffer,g,m.byteLength);j.set(new Uint8Array(m));const A=new Float64Array(e.HEAPU8.buffer,w,b);P(A,[NaN,NaN,NaN],0);let L=3;P(A,n,L),L+=16,P(A,s.center,L),L+=3,A[L++]=s.radius,i&&P(A,i,L++);const x={isDraco:!1,isLegacy:!1,color:a.some(e=>e.some(e=>"color"===e.name)),normal:f&&a.some(e=>e.some(e=>"normalCompressed"===e.name)),uv0:a.some(e=>e.some(e=>"uv0"===e.name)),uvRegion:a.some(e=>e.some(e=>"uvRegion"===e.name)),featureIndex:p.featureIndex},E=e.process(o,!!i,g,j.byteLength,p,x,w,c,y,h,d);if(e._free(w),e._free(g),E.error.length>0)throw new Error(`i3s.wasm: ${E.error}`);if(E.discarded)return null;const S=E.componentOffsets.length>0?E.componentOffsets.slice():null,U=E.featureIds.length>0?E.featureIds.slice():null,_=E.anchorIds.length>0?Array.from(E.anchorIds):null,v=E.anchors.length>0?Array.from(E.anchors):null,N=E.interleavedVertedData.slice().buffer,F=1===E.indicesType?new Uint16Array(E.indices.buffer,E.indices.byteOffset,E.indices.byteLength/2).slice():new Uint32Array(E.indices.buffer,E.indices.byteOffset,E.indices.byteLength/4).slice(),I=E.positions.slice(),{buffer:M,byteOffset:O,byteLength:B}=E.positionIndices,R=1===E.positionIndicesType?new Uint16Array(M,O,B/2).slice():new Uint32Array(M,O,B/4).slice(),T=new l(r.layouts[0],N,F,E.hasColors,E.hasModifications,{data:I,indices:R});return U&&t.push(U.buffer),S&&t.push(S.buffer),t.push(N),t.push(F.buffer),t.push(I.buffer),t.push(R.buffer),new u(S,U,_,v,T,n,E.obb)}function E(e){return 0===e?0:1===e?1:2===e?2:3}function S(e){if(!A)return;const{context:r,buffer:t}=e,o=A._malloc(t.byteLength),n=t.byteLength/Float64Array.BYTES_PER_ELEMENT,s=new Float64Array(A.HEAPU8.buffer,o,n),i=new Float64Array(t);s.set(i),A.filterOBBs(r,o,n),i.set(s),A._free(o)}function U(e){0===A?.destroy(e)&&(A=null,j=null,c())}function P(e,r,t){for(let o=0;o<r.length;++o)e[o+t]=r[o]}async function _(){A||await v()}async function v(){return A||(A=await(j??=f())),A}const N={transform:(e,r)=>A&&x(A,e,r),destroy:U};export{w as destroyContext,p as dracoDecompressPointCloudData,y as filterObbsForModifications,S as filterObbsForModificationsSync,_ as initialize,E as interpretObbModificationResults,m as process,g as project,d as setLegacySchema,h as setModifications,L as setModificationsSync,N as test,b as transformNormals};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{clone as
|
|
5
|
+
import{clone as e}from"../../../../core/lang.js";import{getMetersPerVerticalUnitForSR as t}from"../../../../core/units.js";import{e as r}from"../../../../chunks/earcut.js";import{normalFromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as o,invertOrIdentity as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as l,sub as c,cross as m,add as p,normalize as h,transformMat4 as d}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{ONES as u,create as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as f}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{create as y,fromBuffer as b,intersectsClippingArea as _}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as x}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as S,getZeroIndexArray as j}from"../../../../geometry/support/Indices.js";import{t as v}from"../../../../chunks/vec3.js";import{SnappingCandidateVertex as P,SnappingCandidateEdge as w}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as C}from"../../../../renderers/support/renderingInfoUtils.js";import{needsElevationUpdates3D as E,SampleElevationInfo as A}from"./elevationAlignmentUtils.js";import{preparePatchEmissiveStrength as D}from"./emissiveUtils.js";import{extrudePolygon as U}from"./extrudeUtils.js";import{Object3DEdgeState as I,Graphics3DObject3DGraphicLayer as z}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as M}from"./Graphics3DSymbolLayer.js";import{computeCentroid as O}from"./graphicUtils.js";import{geometryAsPolygon as L}from"./polygonUtils.js";import{createMaterial as V}from"../support/edgeUtils.js";import{encodeNaNUInt8 as B}from"../support/symbolColorUtils.js";import{debugFlags as G}from"../../support/debugFlags.js";import{SamplePosition as T}from"../../support/ElevationProvider.js";import{polygonToRenderInfo as F}from"../../support/renderInfoUtils/polygon.js";import{Attribute as R}from"../../webgl-engine/lib/Attribute.js";import{Geometry as H}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as N}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{compressNormals as W,compressNormal as k}from"../../webgl-engine/lib/Normals.js";import{Object3D as q}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as Z}from"../../webgl-engine/materials/DefaultMaterial.js";const J=["polygon","extent"];class K extends M{constructor(e,t,r,s){super(e,t,r,s,ee(t)),this.ensureDrapedStatus(!1)}async doLoad(){const e=this.symbolLayer,t=e?.material,r=this.symbolLayer.material?.color?.a,s=this.needsDrivenTransparentPass||null!=r&&1!==r,i=t?.emissive,o=!this._hasDrivenColorOrOpacity&&(null==r||0===r),n={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,ambient:u,diffuse:u,opacity:o?0:1,layerOpacity:this._getLayerOpacity(),drivenOpacity:s,hasSymbolColors:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:e.castShadows,emissiveStrengthFromSymbol:i?.strength??0,emissiveSource:1,offsetTransparentBackfaces:!0,normalType:1},a=new Z(n,this._context),l=new Z({...n,cullFace:2},this._context);this._materials[0]=a,this._materials[1]=l,this._updateTransparentDepedentMaterialParameters()}destroy(){super.destroy(),this._materials.length=0}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,J,this.symbolLayer.type))return null;const r=this._getDrivenUInt8ColorWithNaNSupport(e.renderingInfo,this._materialColor,!1);B(r,r);const s=this.createElevationContextForGraphic(t);return this._createAs3DShape(t,e.renderingInfo,r,s,t.uid)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._materials[0]?.setParameters({layerOpacity:r}),this._materials[1]?.setParameters({layerOpacity:r}),this._updateTransparentDepedentMaterialParameters(),e?.forEach(e=>t(e)?.layerOpacityChanged(r,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,E)}slicePlaneEnabledChanged(e,t){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[1]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),e?.forEach(e=>{const r=t(e);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)}),!0}physicalBasedRenderingChanged(){const e={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0};return this._materials[0]?.setParameters(e),this._materials[1]?.setParameters(e),!0}_getExtrusionSize(e){let t;return t=e.size&&this._drivenProperties.size?C(e.size,2)??0:this._getSymbolSize(),t/=this._context.renderCoordsHelper.unitInMeters,t}applyRendererDiff(e,t){return this._drivenPropertiesChanged(t)?0:1}async queryForSnapping(r,s,i,o){const n=this._getExtrusionSize(i)*this._context.renderCoordsHelper.unitInMeters/t(s),{objectId:a,target:l}=r,c=e(l);switch(c.z=(c.z??0)+n,r.type){case"edge":{const{start:t,end:s}=r,i=e(t),o=e(s);return i.z=(i.z??0)+n,o.z=(o.z??0)+n,[new w(a,c,1/0,i,o)]}case"vertex":return[new P(a,c,1/0),new w(a,l,1/0,l,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(e,t,n,l,c){const m=L(e.geometry);if(null==m)return null;if(0===m.rings.length||!m.rings.some(e=>e.length>0))return this._logGeometryValidationWarnings(m.rings,"rings","ExtrudeSymbol3DLayer"),null;const p=F(m,this._context.elevationProvider,this._context.renderCoordsHelper,l);this._logGeometryCreationWarnings(p,m.rings,"rings","ExtrudeSymbol3DLayer");const h=O(m);if(null==h)return null;const d=new Array,u=new Array,j=y(),P=a(),w=g(),C=1===this._context.renderCoordsHelper.viewingMode;C||this._context.renderCoordsHelper.worldUpAtPosition(null,w),f(m.spatialReference,[h.x,h.y,0],P,this._context.renderCoordsHelper.spatialReference);const A=a();o(A,P);const D=i();s(D,A);const{polygons:M,mapPositions:B,position:G}=p,T=new Map,R=this._materials[0];for(const s of M){const e=s.count;if(this._context.clippingExtent&&(b(s.mapPositions,j),!_(j,this._context.clippingExtent)))continue;const i=r(s.mapPositions,s.holeIndices,3);if(0===i.length)continue;const o=i.length,a=6*e,l=S(a+o),m=S(o),p=x(3*a),h=x(3*a),g=x(3*a),f=x(a),y=this._getExtrusionSize(t);U(G,B,i,s,p,g,h,f,l,m,y,w,C),v(p,p,A);const E=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerViewUid:this._context.layerViewUid}),D=new le(p,g,W(h),f),I=Q(R,l,l.length-m.length,D,n,E),z=e,M=e,O=2*s.count,L=new ce(z,M,O,o/3);$(I,L,P),T.set(I,L),d.push(I,Q(this._materials[1],m,0,D,n,E)),u.push(D.heights)}if(0===d.length)return null;const H=new q({geometries:d,layerViewUid:this._context.layerViewUid,graphicUid:c,isElevationSource:!0});H.transformation=P;const N=V(this.symbolLayer,{opacity:this._getLayerOpacity()}),k=N?new I(this._materials[0],N,this._context.slicePlaneEnabled):null,Z=new z(this,H,null,(e,t,r,s,i)=>Y(e,t,r,s,i,u,T),l,k);return Z.alignedSampledElevation=p.sampledElevation,Z.needsElevationUpdates=E(l.mode),Z}get _materialColor(){return this.symbolLayer.material?.color}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchEmissive(e,t)}_preparePatchEmissive(e,t){return D(e,t,e=>{this._materials.forEach(t=>t?.setParameters({emissiveStrengthFromSymbol:e??0}))},this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result)}_updateTransparentDepedentMaterialParameters(){const e=this._materials[0];e&&e.setParameters({cullFace:e.transparent?0:2})}}function Q(e,t,r,s,i,o){const n=j(t.length),a=[["position",new R(s.positions,t,3,!0)],["normalCompressed",new R(s.normals,t,2,!0)],["symbolColor",new R(i,n,4,!0)]];return new H(e,a,s.elevation,0,o,r)}const X=g();function Y(e,t,r,s,i,o,c){const m=e.stageObject,p=m.geometries,h=p.length,u="absolute-height"!==t.mode;let g=0;const f=m.transformation,y=n(a(),f);for(let n=0;n<h;n+=2){const e=p[n];if(!N(e))continue;const t=e.getMutableAttribute("position").data,a=o[n/2],h=new T(e.mapPositions),b=t.length/3;let _=!1,x=0;{let e=0;for(let o=0;o<b;o++){X[0]=t[e],X[1]=t[e+1],X[2]=t[e+2],s(h,se),u&&(x+=se.sampledElevation),G.TESTS_DISABLE_OPTIMIZATIONS?(l(te,h.array[h.offset],h.array[h.offset+1],se.z+a[e/3]),null!=r&&i.toRenderCoords(te,r,te),d(te,te,y)):(l(te,t[e],t[e+1],t[e+2]),d(te,te,f),i.setAltitude(te,se.z+a[e/3]),d(te,te,y)),t[e]=te[0],t[e+1]=te[1],t[e+2]=te[2];const o=ie/i.unitInMeters;(Math.abs(X[0]-t[e])>=o||Math.abs(X[1]-t[e+1])>=o||Math.abs(X[2]-t[e+2])>=o)&&(_=!0),h.offset+=3,e+=3}}if(_){const t=c.get(e);t&&$(e,t,f),m.geometryVertexAttributeUpdated(p[n],"normalCompressed"),e.invalidateBoundingInfo(),m.geometryVertexAttributeUpdated(p[n],"position"),p[n+1].invalidateBoundingInfo(),m.geometryVertexAttributeUpdated(p[n+1],"position")}g+=x/b}return g/h}function $(e,t,r){const s=e.getMutableAttribute("position"),i=e.getMutableAttribute("normalCompressed").data,o=s.data,n=e.attributes.get("position").indices,{topVertexStart:a,topVertexCount:u,topFaceStart:g,topFaceCount:f}=t,y=g+f,b=a+u,_=oe,x=ne,S=ae,j=re,v=te;l(v,0,0,0);const P=(e,t)=>{const s=3*e;l(t,o[s+0],o[s+1],o[s+2]),d(t,t,r)};for(let l=g;l<y;++l){const e=3*l;P(n[e+0],_[0]),P(n[e+1],_[1]),P(n[e+2],_[2]),c(x,_[1],_[0]),c(S,_[2],_[0]),m(j,x,S),p(v,v,j)}h(v,v);for(let l=a;l<b;++l){const e=v[0],t=v[1],r=v[2];k(i,l,e,t,r)}}function ee(e){return 1===(e.material?.color?.a??0)}const te=g(),re=g(),se=new A,ie=.01,oe=[g(),g(),g()],ne=g(),ae=g();class le{constructor(e,t,r,s){this.positions=e,this.elevation=t,this.normals=r,this.heights=s}}class ce{constructor(e,t,r,s){this.topVertexStart=e,this.topVertexCount=t,this.topFaceStart=r,this.topFaceCount=s}}export{K as Graphics3DExtrudeSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import{linearize as t}from"../../../../colorUtils.js";import{deg2rad as r}from"../../../../core/mathUtils.js";import{releaseMaybe as o}from"../../../../core/maybe.js";import{isPromiseLike as n}from"../../../../core/promiseUtils.js";import{normalFromMat4 as a,fromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as l,multiply as c,invert as u,getTranslation as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f,IDENTITY as p,clone as h}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as d}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as g,add as x,scale as _,transformMat4 as y,transformMat3 as T,normalize as b,scaleAndAdd as v,subtract as w,cross as C,dot as M}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as j,fromValues as R,ONES as A,ZEROS as P}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as S}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as I}from"../../../../geometry/projectionUtils.js";import{computeTranslationToOriginAndRotation as B}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as U}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as E}from"../../../../geometry/projection/projectVectorToVector.js";import{fromBuffer as F,create as O,intersectsClippingArea as V}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as $}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as G,getContinuousIndexArray as D}from"../../../../geometry/support/Indices.js";import L from"../../../../geometry/support/MeshComponent.js";import N from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import H from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as k,isAbsoluteVertexSpace as z}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as q,isPlateCarree as W}from"../../../../geometry/support/spatialReferenceUtils.js";import{t as Y}from"../../../../chunks/vec3.js";import{transformNormal as K,transformVectorENUPlateCarree as J,transformVectorWMPlateCarree as Q,projectNormalToPCPF as X,transformTangent as Z,projectTangentToPCPF as ee}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as te}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{getEmissiveMode as re}from"../../../../symbols/support/materialUtils.js";import{isEncodedMeshTexture as oe}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as ne}from"../../glTF/internal/TextureTransformUtils.js";import{defaultSymbolLayerMemoryComplexity as ae}from"./defaultSymbolComplexity.js";import{perObjectElevationAligner as se}from"./ElevationAligners.js";import{needsElevationUpdates3D as ie,evaluateElevationInfoAtPoint as le}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as ce}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as ue}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as me,nanFallbackColor as fe}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as pe,MeshFastUpdateProcessor as he}from"./MeshFastUpdateProcessor.js";import{SymbolComplexity as de}from"./SymbolComplexity.js";import{hasEdges as ge,createMaterial as xe}from"../support/edgeUtils.js";import{debugFlags as _e}from"../../support/debugFlags.js";import{Attribute as ye}from"../../webgl-engine/lib/Attribute.js";import{Geometry as Te}from"../../webgl-engine/lib/Geometry.js";import{ManagedTexture as be}from"../../webgl-engine/lib/ManagedTexture.js";import{Object3D as ve}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as we}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as Ce}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as Me,advancedMRRFactors as je,schematicMRRFactors as Re}from"../../webgl-engine/materials/pbrUtils.js";const Ae=["mesh"];class Pe extends me{constructor(e,t,r,o){super(e,t,r,o,We(t)),this._materialInfoCache=new pe,this._fastUpdateProcessor=new he,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){_e.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new Ce({color:[1,0,1,1]}),this._debugTangentNormalMaterial=new Ce({color:[1,.5,0,1]}),this._debugFaceNormalMaterial=new Ce({color:[0,1,1,1]})),this.updateComplexity()}destroy(){super.destroy(),this._textures.forEach(e=>e.unload()),this._context.stage.removeTextures(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy()}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Ae,"fill on mesh-3d"))return null;const r=this.createElevationContextForGraphic(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters(e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTextureAlphaMode(t,e)}),e?.forEach(e=>t(e)?.layerOpacityChanged(r,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,ie)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters(({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),e?.forEach(e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters(({material:t})=>t.setParameters({usePBR:e})),!0}updateTransform(e,t,r,o){if(!e.fastTransformUpdatesAllowed)return!1;const n=e.fastTransformUpdatesEnabled;switch(o){case 0:if(n)return!0;break;case 1:if(!n)return!0;break;default:if(!n)return!!this.updateTransform(e,t,r,0)&&(e.autoDisableFastTransformUpdates(()=>this.updateTransform(e,t,r,1)),!0)}const a=this._context.renderCoordsHelper.spatialReference,s=tt,{origin:i,transform:l}=r;if(!B(t,g(Je,i.x,i.y,i.z??0),s,a))return!1;switch(o){case 0:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case 1:this._fastUpdateProcessor.disable(e,this._materialInfoCache);break;case 2:e.updateFastLocalOrigin(s,l,this._context.localOriginFactory)}const{elevationContext:c}=e;c.centerInElevationSR=this._getCenterInElevationSR(s);const{elevationProvider:u,renderCoordsHelper:m}=this._context,f=(e,t)=>le(e,u,c,m,t);return e.alignedSampledElevation=se(e,c,u.spatialReference,f,m,s),e.updateTransform(s,l,this._context.isAsync),e.updateAutoDisableFastTransformUpdates(()=>this.updateTransform(e,t,r,1)),!0}computeComplexity(){if(!this._textures||0===this._textures.size)return super.computeComplexity();let e=0;for(const o of this._textures.values())e+=o.usedMemory;const t={...ae(this.symbol,this.symbolLayer),resourceBytes:e},r=ge(this.symbolLayer)?2:0;return new de({drawCallsPerFeature:r,memory:t})}_requiresSymbolVertexColors(){return this._hasDrivenColorOrOpacity}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,n=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:n,uid:`vc:${o},vt:${n},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:n,colorTexture:a,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,f=ke(n),p=ke(a),h=ze(s),d=ke(i),g=ze(l);if(o.color=n,o.colorTexture=a,o.normalTexture=i,o.uid=`${o.uid},cmuid:${f},ctmuid:${p},cttuid:${h},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof N){const{metallic:e,roughness:r,metallicRoughnessTexture:n,metallicRoughnessTextureTransform:a,emissiveColor:i,emissiveStrength:c,emissiveTexture:u,emissiveTextureTransform:m,occlusionTexture:f,occlusionTextureTransform:p}=t.material,h=ke(n),d=ze(a),g=ke(i),x=ke(u),_=ze(m),y=ke(f),T=ze(p);o.uid=[o.uid,`mrm:${e}`,`mrr:${r}`,`mrt:${h}`,`mrtt:${d}`,`emuid:${g}`,`ems:${c}`,`etmuid:${x}`,`ett:${_}`,`otmuid:${y}`,`ott:${T}`].join(","),o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=n,o.emissiveColor=i,o.emissiveStrength=c,o.emissiveTexture=u,o.occlusionTexture=f,o.colorTextureTransform=$e(s),o.normalTextureTransform=$e(l),o.emissiveTextureTransform=$e(m),o.occlusionTextureTransform=$e(p),o.metallicRoughnessTextureTransform=$e(a)}return o}_getInternalTexture(e,t=!1,r=1){const a=He(e);if(!a)return null;const s=`${e.contentHash}/${r}`;let i=this._textures.get(s);if(i){const e=this._context.stage.renderView.textures;let t=null;const r=e.acquire(i.id);return null==r||n(r)||(i.events.on("unloaded",()=>t=o(t)),t=r),i}let l=null;const c=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,u={wrap:Ge(e.wrap),noUnpackFlip:!0,maxAnisotropy:c,mipmap:c>1};return oe(a)?(l=a.data,u.preMultiplyAlpha=!1,u.encoding=a.encoding):(l=a,u.preMultiplyAlpha=1!==r,u.compressionOptions=t?{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}:void 0),i=new be(l,u),this._textures.set(s,i),i.events.on("loaded",()=>this.updateComplexity()),i.load(this._context.stage.renderView.renderingContext),this._context.stage.addTexture(i),i.events.on("unloaded",()=>{this._textures.delete(s)}),i}_setInternalMaterialTextureParameters(e,r){if(null!=e.colorTexture){const t=1!==r.textureAlphaMode,o=this._getInternalTexture(e.colorTexture,t,r.textureAlphaMode);o?(r.textureId=o.id,r.textureAlphaPremultiplied=!!o.parameters.preMultiplyAlpha):r.textureId=void 0}if(e.normalTexture&&(r.normalTextureId=this._getInternalTexture(e.normalTexture)?.id),e.emissiveColor){const o=e.emissiveColor?.toUnitRGB();r.emissiveBaseColor=R(t(o[0]),t(o[1]),t(o[2]))}e.emissiveStrength&&(r.emissiveStrengthKHR=e.emissiveStrength),e.emissiveTexture&&(r.emissiveTextureId=this._getInternalTexture(e.emissiveTexture)?.id),e.occlusionTexture&&(r.occlusionTextureId=this._getInternalTexture(e.occlusionTexture,!0)?.id),e.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTexture(e.metallicRoughnessTexture,!0)?.id)}_setInternalMaterialParameters(e,t,r){null!=e.color&&Ne(e.color,t,r),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=ne(e.colorTextureTransform),t.normalTextureTransformMatrix=ne(e.normalTextureTransform);const o=null!=e.normalTextureTransform?.scale?e.normalTextureTransform?.scale:d;t.scale=[o[0],o[1]],t.occlusionTextureTransformMatrix=ne(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=ne(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=ne(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(e,t=this._materialColor){const r=this._drivenProperties.color,o=this._drivenProperties.opacity;if(r)e.externalColor=S;else{const r=t??null;if(r){const t=r.toUnitRGBA();o&&(t[3]=1),e.externalColor=t}else e.externalColor=fe}e.colorMixMode=this.symbolLayer.material?.colorMixMode??"multiply",e.castShadows=!!this.symbolLayer.castShadows,e.emissiveStrengthFromSymbol=this.symbolLayer?.material?.emissive?.strength??1,e.emissiveSource=re(this.symbolLayer?.material?.emissive?.source??"emissive")}_getOrCreateMaterial(e,t){const r=t.material?.color,o=t.material?.colorTexture,n=t.material?.alphaMode,a="blend"===n,s=!("opaque"===n)&&(Le(e)||null!=r&&r.a<1||o?.transparent||a),i=this._materialProperties(e,t,s),l=this._materialInfoCache.byUid(i.uid);if(l)return this._setInternalMaterialTextureParameters(i,l.material.parameters),l.material;const c={uid:i.uid,material:null,isComponentTransparent:s,alphaMode:t.material?t.material.alphaMode:"opaque"},u=Me({normalTexture:i.normalTexture,metallicRoughnessTexture:i.metallicRoughnessTexture,metallicFactor:i.metallic,roughnessFactor:i.roughness,emissiveTexture:i.emissiveTexture,emissiveFactor:i.emissiveColor?.toUnitRGB(),occlusionTexture:i.occlusionTexture}),m={usePBR:this._usePBR(),isSchematic:u,hasVertexColors:i.hasVertexColors,hasSymbolColors:i.hasSymbolVertexColors,hasVertexTangents:i.hasVertexTangents,ambient:P,diffuse:A,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:0,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||c.isComponentTransparent};m.mrrFactors=u?Re:[i.metallic,i.roughness,je[2]],t.material&&(m.doubleSided=t.material.doubleSided,m.cullFace=t.material.doubleSided?0:2,m.textureAlphaCutoff=t.material.alphaCutoff),this._setExternalMaterialParameters(m),this._setMaterialTextureAlphaMode(m,c),this._setInternalMaterialParameters(i,m,c);const f=new we(m,this._context);return c.material=f,this._materialInfoCache.set(i.uid,c),f}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchColor(e,t)}_preparePatchColor(e,t){if(!t.material||"partial"!==t.material.type)return;const r=t.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const o=r.color.newValue;delete r.color,e.symbolLayerStatePatches.push(()=>{this._updateMaterialParameters(e=>{const t=e.material.parameters;this._setExternalMaterialParameters(t,o),this._setMaterialTextureAlphaMode(t,e),e.material.setParameters({externalColor:t.externalColor})})})}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTextureAlphaMode(e,t){if("auto"===t.alphaMode){const r=this.needsDrivenTransparentPass||t.isComponentTransparent||(e.layerOpacity??1)<1||(e.opacity??1)<1||(e.externalColor?.[3]??1)<1;e.textureAlphaMode=r?3:1}else e.textureAlphaMode="opaque"===t.alphaMode?1:"mask"===t.alphaMode?2:0}_createFaceDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,n=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),s=[],l=[],c=t[0].transformation,u=a(i(),c);for(let a=0;a<r;a++){const e=t[a].attributes.get("position");if(!e)continue;const r=e.data,o=e.indices;for(let t=0;t<o.length;t+=3)Ve(r,o,t,Ze),Oe(r,o,t,Je,Qe,Xe),x(Je,Je,Qe),x(Je,Je,Xe),_(Je,Je,1/3),y(Je,Je,c),s.push(...Je),T(Ze,Ze,u),b(Ze,Ze),v(Je,Je,Ze,n),s.push(...Je),l.push(l.length),l.push(l.length)}return s.length?new Te(this._debugFaceNormalMaterial,[["position",new ye(s,l,3,!0)]],null,2):null}_createPerVertexDebugVectors(e,t,r,o,n){const l=t.length,c=e.spatialReference.isGeographic?20015077/180:1,u=.1*n*Math.max(e.extent.width*c,e.extent.height*c,e.extent.zmax-e.extent.zmin),m=[],f=[],p=t[0].transformation,h=a(i(),p);"tangent"===r&&s(h,p);for(let a=0;a<l;a++){const e=t[a],o=e.attributes.get("position"),n=e.attributes.get(r);if(!o||!n)continue;const s=o.data,i=o.indices,l=n.data,c=n.indices;for(let t=0;t<i.length;t++){const e=3*i[t],r=c[t]*n.stride;g(Je,s[e+0],s[e+1],s[e+2]),y(Je,Je,p),m.push(...Je),g(Qe,l[r+0],l[r+1],l[r+2]),T(Qe,Qe,h),b(Qe,Qe),v(Je,Je,Qe,u),m.push(...Je),f.push(f.length),f.push(f.length)}}return m.length?new Te(o,[["position",new ye(m,f,3,!0)]],null,2):null}_createAs3DShape(e,t,r,o){const n=e.geometry;if("mesh"!==n.type)return null;const a=this._createGeometryInfo(n,t,o);if(null==a)return null;const{geometries:s,objectTransformation:i}=a;if(_e.DRAW_MESH_GEOMETRY_NORMALS){const e=this._createPerVertexDebugVectors(n,s,"normal",this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(n,s,"tangent",this._debugTangentNormalMaterial,.5),r=this._createFaceDebugNormals(n,s);e&&s.push(e),t&&s.push(t),r&&s.push(r)}const l=this._context.layerViewUid,c=new ve({geometries:s,layerViewUid:l,graphicUid:o,isElevationSource:!0});c.transformation=i;const u=xe(this.symbolLayer,{opacity:this._getLayerOpacity()}),m=u?new ue(s[0].material,u,this._context.slicePlaneEnabled):null,f=new ce(this,c,null,se,r,m);this._fastUpdateProcessor.onAddGraphic(),f.needsElevationUpdates=ie(r.mode),f.useObjectOriginAsAttachmentOrigin=!0,f.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(n),r.centerInElevationSR=this._getCenterInElevationSR(c.transformation);const{elevationProvider:p,renderCoordsHelper:h}=this._context,d=(e,t)=>le(e,p,r,h,t);return f.alignedSampledElevation=se(f,r,p.spatialReference,d,h),f}_fastTransformUpdatesAllowed(e){const{vertexSpace:t,spatialReference:r}=e;if(!k(t))return!1;const{type:o}=t,{view:n}=this._context.graphicsCoreOwner,{viewingMode:a}=n.state,s=n.spatialReference;return 1===a&&"local"===o||2===a&&q(s,r)&&"georeferenced"===o&&!r.isGeographic}_getElevationSR(){return this._context.elevationProvider.spatialReference??null}_getCenterInElevationSR(e){const t=j(),r=g(nt,e[12],e[13],e[14]);return E(r,this._context.renderCoordsHelper.spatialReference,t,this._getElevationSR()),t}_passthroughReprojectionInfo(e){return 0===e.reprojection&&!!e.objectTransformation}_createPositionBuffer(e,t){const r=e.vertexAttributes.position;let o,n=r;if(0===t.reprojection)return{position:n,georeferencedPositionBuffer:o};const a=1===t.reprojection?t.transformBeforeProject:null;a&&(n=Y(new Float64Array(n.length),n,a));const{normal:s,tangent:i}=e.vertexAttributes;this._passthroughReprojectionInfo(t)||!s&&!i||(o=n);const l=n===r||n===o?new Float64Array(n.length):n;return U(n,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:o}}_createNormalBuffer(e,t,r,o){const n=e.vertexAttributes.normal;if(null==n)return null;let a=n;const s=1===o.reprojection?o.transformBeforeProject:null;s&&(a=K(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(0===o.reprojection)return a;if("local"===i){if(!W(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return J(a,0,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Q(a,0,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return X(a,r,e.spatialReference,t,c,l)}_createTangentBuffer(e,t,r,o){const n=e.vertexAttributes.tangent;if(null==n)return null;let a=n;const s=1===o.reprojection?o.transformBeforeProject:null;s&&(a=Z(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(0===o.reprojection)return a;if("local"===i){if(!W(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return J(a,1,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Q(a,1,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return ee(a,r,e.spatialReference,t,c,l)}_createSymbolColorBuffer(e){return this._requiresSymbolVertexColors()?new Uint8Array(this._getDrivenUInt8ColorWithNaNSupport(e,this._materialColor,!0)):null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,n=e.vertexAttributes.uv,a=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(n&&n.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),{position:i,georeferencedPositionBuffer:l}=this._createPositionBuffer(e,s),c=qe(e),u=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,l,s),p=this._createTangentBuffer(e,i,l,s),h=n,{transformation:d,position:g,normal:x,tangent:_}=this._passthroughReprojectionInfo(s)?{transformation:s.objectTransformation,position:i,normal:m,tangent:p}:this._transformOriginLocal(e,i,m,p);return{positionBuffer:g,normalBuffer:x,tangentBuffer:_,uvBuffer:h,colorBuffer:c,symbolColorBuffer:u,objectTransformation:d,geometryTransformation:0===s.reprojection&&s.geometryTransformation?s.geometryTransformation:f()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?q(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?0:1:0;if(z(t))return{reprojection:r};const o=t.origin,n=f(),a=e.transform?.localMatrix??p;if(0===r){B(e.spatialReference,o,n,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:n,geometryTransformation:h(a)}}const s=l(f(),o);return c(s,s,a),{reprojection:r,transformBeforeProject:s}}_transformOriginLocal(e,t,r,o){const n=this._context.renderCoordsHelper.spatialReference,a=e.origin;Ke[0]=a.x,Ke[1]=a.y,Ke[2]=a.z??0;const s=f();B(e.spatialReference,Ke,s,n),u(et,s);const{position:i,normal:l,tangent:c}=e.vertexAttributes,m=t===i?new Float64Array(t.length):t;Y(m,t,et);const p=r?r===l?new Float32Array(r.length):r:null,h=o?o===c?new Float32Array(o.length):o:null;return r&&p&&K(r,p,et),o&&h&&Z(o,h,et),{transformation:s,position:m,normal:p,tangent:h}}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=te(e,r??e.spatialReference);return!!o&&(F(o,rt),!V(rt,this._context.clippingExtent))}_createGeometryInfo(e,t,r){if(!I(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(!this._validateVertexSpace(e))return null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:n,uvBuffer:a,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:c,objectTransformation:u,geometryTransformation:f}=o,p=e.components??ot,h=new Array;let d=!1;const g=m(Je,u),x=this._context.localOriginFactory.getOrigin(g);for(const m of p){if(!this._validateFaces(e,m))return null;const t=Ie(e,m);if(0===t.length)continue;const o=Be(n,l,m,t);o.didFlipNormals&&(d=!0);const u=[["position",new ye(n,t,3,!0)],["normal",new ye(o.normals,o.indices,3,!0)]];s&&u.push(["color",new ye(s,t,4,!0)]),i&&u.push(["symbolColor",new ye(i,G(t.length),4,!0)]),a&&u.push(["uv0",new ye(a,t,2,!0)]),c&&u.push(["tangent",new ye(c,t,4,!0)]);const p=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerViewUid:this._context.layerViewUid}),g=this._getOrCreateMaterial(e,m),_=new Te(g,u,null,0,p);_.transformation=f,_.localOrigin=x,h.push(_)}return d&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:h,objectTransformation:u}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial((e,t)=>{t.setParameters(e.parameters)})}_validateVertexSpace(e){const{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:r}=e;return 2!==t||"local"!==r.type||(this.logger.warn("Displaying a mesh with a local vertex space in a view in local viewing mode is not supported."),!1)}test(){return{...super.test(),materials:this._materialInfoCache.materials}}get _materialColor(){return this.symbolLayer.material?.color}}class Se{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}function Ie(e,t){return t.faces??D(e.vertexAttributes.position.length/3)}function Be(e,t,r,o){switch(r.shading||"flat"){default:case"source":return Ee(e,t,r,o);case"flat":return Ue(e,o);case"smooth":return Fe(e,o)}}function Ue(e,t){const r=$(t.length),o=new Array(3*t.length);for(let n=0;n<t.length;n+=3){const a=Ve(e,t,n,Ze);for(let e=0;e<3;e++)r[n+e]=a[e],o[n+e]=n/3}return new Se(r,o,!1)}function Ee(e,t,r,o){if(null==t)return Ue(e,o);let n=!1;if(!r.trustSourceNormals)for(let a=0;a<o.length;a+=3){Ve(e,o,a,Ze);for(let e=0;e<3;e++){const r=3*o[a+e];Je[0]=t[r],Je[1]=t[r+1],Je[2]=t[r+2],M(Ze,Je)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],n=!0)}}return new Se(t,o,n)}function Fe(e,t){const r={};for(let a=0;a<t.length;a+=3){const o=Ve(e,t,a,Ze);for(let e=0;e<3;e++){const n=t[a+e];let s=r[n];s||(s={normal:j(),count:0},r[n]=s),x(s.normal,s.normal,o),s.count++}}const o=$(3*t.length),n=new Array(3*t.length);for(let a=0;a<t.length;a++){const e=r[t[a]];1!==e.count&&(b(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*a+t]=e.normal[t];n[a]=a}return new Se(o,n,!1)}function Oe(e,t,r,o,n,a){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],n[0]=e[i],n[1]=e[i+1],n[2]=e[i+2],a[0]=e[l],a[1]=e[l+1],a[2]=e[l+2]}function Ve(e,t,r,o){return Oe(e,t,r,Je,Qe,Xe),w(Qe,Qe,Je),w(Xe,Xe,Je),C(Je,Qe,Xe),b(o,Je),o}function $e(e){if(!e)return null;const{scale:t,offset:o,rotation:n}=e;return{scale:t,offset:o,rotation:r(n)}}function Ge(e="repeat"){if("string"==typeof e){const t=De(e);return{s:t,t}}return{s:De(e.horizontal),t:De(e.vertical)}}function De(e){switch(e){case"clamp":return 33071;case"mirror":return 33648;default:return 10497}}function Le(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}function Ne(e,t,r){t.diffuse=e.toUnitRGB(),t.opacity="opaque"===r.alphaMode?1:e.a}function He(e){return e.data??e.url}function ke(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}function ze(e){const{offset:t,scale:r,rotation:o}=e??Ye;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}function qe(e){return e.vertexAttributes.color}function We(e){return 1===(e.material?.color?.a??0)}const Ye=new H,Ke=j(),Je=j(),Qe=j(),Xe=j(),Ze=j(),et=f(),tt=f(),rt=O(),ot=[new L],nt=j();export{Pe as Graphics3DMeshFillSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import{linearize as t}from"../../../../colorUtils.js";import{deg2rad as r}from"../../../../core/mathUtils.js";import{releaseMaybe as o}from"../../../../core/maybe.js";import{isPromiseLike as n}from"../../../../core/promiseUtils.js";import{normalFromMat4 as a,fromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as l,multiply as c,invert as u,getTranslation as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f,IDENTITY as p,clone as h}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as d}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as g,add as x,scale as _,transformMat4 as y,transformMat3 as T,normalize as b,scaleAndAdd as v,subtract as w,cross as C,dot as M}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as j,fromValues as R,ONES as A,ZEROS as P}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as S}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as I}from"../../../../geometry/projectionUtils.js";import{computeTranslationToOriginAndRotation as B}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as U}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as E}from"../../../../geometry/projection/projectVectorToVector.js";import{fromBuffer as F,create as O,intersectsClippingArea as V}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as $}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as G,getContinuousIndexArray as D}from"../../../../geometry/support/Indices.js";import L from"../../../../geometry/support/MeshComponent.js";import N from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import H from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as k,isAbsoluteVertexSpace as z}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as q,isPlateCarree as W}from"../../../../geometry/support/spatialReferenceUtils.js";import{t as Y}from"../../../../chunks/vec3.js";import{transformNormal as K,transformVectorENUPlateCarree as J,transformVectorWMPlateCarree as Q,projectNormalToPCPF as X,transformTangent as Z,projectTangentToPCPF as ee}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as te}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{getEmissiveMode as re}from"../../../../symbols/support/materialUtils.js";import{isEncodedMeshTexture as oe}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as ne}from"../../glTF/internal/TextureTransformUtils.js";import{defaultSymbolLayerMemoryComplexity as ae}from"./defaultSymbolComplexity.js";import{perObjectElevationAligner as se}from"./ElevationAligners.js";import{needsElevationUpdates3D as ie,evaluateElevationInfoAtPoint as le}from"./elevationAlignmentUtils.js";import{preparePatchEmissiveStrength as ce}from"./emissiveUtils.js";import{Graphics3DMeshObject3DGraphicLayer as ue}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as me}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as fe,nanFallbackColor as pe}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as he,MeshFastUpdateProcessor as de}from"./MeshFastUpdateProcessor.js";import{SymbolComplexity as ge}from"./SymbolComplexity.js";import{hasEdges as xe,createMaterial as _e}from"../support/edgeUtils.js";import{debugFlags as ye}from"../../support/debugFlags.js";import{Attribute as Te}from"../../webgl-engine/lib/Attribute.js";import{Geometry as be}from"../../webgl-engine/lib/Geometry.js";import{ManagedTexture as ve}from"../../webgl-engine/lib/ManagedTexture.js";import{Object3D as we}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as Ce}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as Me}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as je,advancedMRRFactors as Re,schematicMRRFactors as Ae}from"../../webgl-engine/materials/pbrUtils.js";const Pe=["mesh"];class Se extends fe{constructor(e,t,r,o){super(e,t,r,o,Ye(t)),this._materialInfoCache=new he,this._fastUpdateProcessor=new de,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){ye.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new Me({color:[1,0,1,1]}),this._debugTangentNormalMaterial=new Me({color:[1,.5,0,1]}),this._debugFaceNormalMaterial=new Me({color:[0,1,1,1]})),this.updateComplexity()}destroy(){super.destroy(),this._textures.forEach(e=>e.unload()),this._context.stage.removeTextures(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy()}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Pe,"fill on mesh-3d"))return null;const r=this.createElevationContextForGraphic(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters(e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTextureAlphaMode(t,e)}),e?.forEach(e=>t(e)?.layerOpacityChanged(r,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,ie)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters(({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),e?.forEach(e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters(({material:t})=>t.setParameters({usePBR:e})),!0}updateTransform(e,t,r,o){if(!e.fastTransformUpdatesAllowed)return!1;const n=e.fastTransformUpdatesEnabled;switch(o){case 0:if(n)return!0;break;case 1:if(!n)return!0;break;default:if(!n)return!!this.updateTransform(e,t,r,0)&&(e.autoDisableFastTransformUpdates(()=>this.updateTransform(e,t,r,1)),!0)}const a=this._context.renderCoordsHelper.spatialReference,s=rt,{origin:i,transform:l}=r;if(!B(t,g(Qe,i.x,i.y,i.z??0),s,a))return!1;switch(o){case 0:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case 1:this._fastUpdateProcessor.disable(e,this._materialInfoCache);break;case 2:e.updateFastLocalOrigin(s,l,this._context.localOriginFactory)}const{elevationContext:c}=e;c.centerInElevationSR=this._getCenterInElevationSR(s);const{elevationProvider:u,renderCoordsHelper:m}=this._context,f=(e,t)=>le(e,u,c,m,t);return e.alignedSampledElevation=se(e,c,u.spatialReference,f,m,s),e.updateTransform(s,l,this._context.isAsync),e.updateAutoDisableFastTransformUpdates(()=>this.updateTransform(e,t,r,1)),!0}computeComplexity(){if(!this._textures||0===this._textures.size)return super.computeComplexity();let e=0;for(const o of this._textures.values())e+=o.usedMemory;const t={...ae(this.symbol,this.symbolLayer),resourceBytes:e},r=xe(this.symbolLayer)?2:0;return new ge({drawCallsPerFeature:r,memory:t})}_requiresSymbolVertexColors(){return this._hasDrivenColorOrOpacity}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,n=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:n,uid:`vc:${o},vt:${n},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:n,colorTexture:a,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,f=ze(n),p=ze(a),h=qe(s),d=ze(i),g=qe(l);if(o.color=n,o.colorTexture=a,o.normalTexture=i,o.uid=`${o.uid},cmuid:${f},ctmuid:${p},cttuid:${h},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof N){const{metallic:e,roughness:r,metallicRoughnessTexture:n,metallicRoughnessTextureTransform:a,emissiveColor:i,emissiveStrength:c,emissiveTexture:u,emissiveTextureTransform:m,occlusionTexture:f,occlusionTextureTransform:p}=t.material,h=ze(n),d=qe(a),g=ze(i),x=ze(u),_=qe(m),y=ze(f),T=qe(p);o.uid=[o.uid,`mrm:${e}`,`mrr:${r}`,`mrt:${h}`,`mrtt:${d}`,`emuid:${g}`,`ems:${c}`,`etmuid:${x}`,`ett:${_}`,`otmuid:${y}`,`ott:${T}`].join(","),o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=n,o.emissiveColor=i,o.emissiveStrength=c,o.emissiveTexture=u,o.occlusionTexture=f,o.colorTextureTransform=Ge(s),o.normalTextureTransform=Ge(l),o.emissiveTextureTransform=Ge(m),o.occlusionTextureTransform=Ge(p),o.metallicRoughnessTextureTransform=Ge(a)}return o}_getInternalTexture(e,t=!1,r=1){const a=ke(e);if(!a)return null;const s=`${e.contentHash}/${r}`;let i=this._textures.get(s);if(i){const e=this._context.stage.renderView.textures;let t=null;const r=e.acquire(i.id);return null==r||n(r)||(i.events.on("unloaded",()=>t=o(t)),t=r),i}let l=null;const c=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,u={wrap:De(e.wrap),noUnpackFlip:!0,maxAnisotropy:c,mipmap:c>1};return oe(a)?(l=a.data,u.preMultiplyAlpha=!1,u.encoding=a.encoding):(l=a,u.preMultiplyAlpha=1!==r,u.compressionOptions=t?{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}:void 0),i=new ve(l,u),this._textures.set(s,i),i.events.on("loaded",()=>this.updateComplexity()),i.load(this._context.stage.renderView.renderingContext),this._context.stage.addTexture(i),i.events.on("unloaded",()=>{this._textures.delete(s)}),i}_setInternalMaterialTextureParameters(e,r){if(null!=e.colorTexture){const t=1!==r.textureAlphaMode,o=this._getInternalTexture(e.colorTexture,t,r.textureAlphaMode);o?(r.textureId=o.id,r.textureAlphaPremultiplied=!!o.parameters.preMultiplyAlpha):r.textureId=void 0}if(e.normalTexture&&(r.normalTextureId=this._getInternalTexture(e.normalTexture)?.id),e.emissiveColor){const o=e.emissiveColor?.toUnitRGB();r.emissiveBaseColor=R(t(o[0]),t(o[1]),t(o[2]))}e.emissiveStrength&&(r.emissiveStrengthKHR=e.emissiveStrength),e.emissiveTexture&&(r.emissiveTextureId=this._getInternalTexture(e.emissiveTexture)?.id),e.occlusionTexture&&(r.occlusionTextureId=this._getInternalTexture(e.occlusionTexture,!0)?.id),e.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTexture(e.metallicRoughnessTexture,!0)?.id)}_setInternalMaterialParameters(e,t,r){null!=e.color&&He(e.color,t,r),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=ne(e.colorTextureTransform),t.normalTextureTransformMatrix=ne(e.normalTextureTransform);const o=null!=e.normalTextureTransform?.scale?e.normalTextureTransform?.scale:d;t.scale=[o[0],o[1]],t.occlusionTextureTransformMatrix=ne(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=ne(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=ne(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(e,t=this._materialColor){const r=this._drivenProperties.color,o=this._drivenProperties.opacity;if(r)e.externalColor=S;else{const r=t??null;if(r){const t=r.toUnitRGBA();o&&(t[3]=1),e.externalColor=t}else e.externalColor=pe}e.colorMixMode=this.symbolLayer.material?.colorMixMode??"multiply",e.castShadows=!!this.symbolLayer.castShadows,e.emissiveStrengthFromSymbol=this.symbolLayer?.material?.emissive?.strength??1,e.emissiveSource=re(this.symbolLayer?.material?.emissive?.source??"emissive")}_getOrCreateMaterial(e,t){const r=t.material?.color,o=t.material?.colorTexture,n=t.material?.alphaMode,a="blend"===n,s=!("opaque"===n)&&(Ne(e)||null!=r&&r.a<1||o?.transparent||a),i=this._materialProperties(e,t,s),l=this._materialInfoCache.byUid(i.uid);if(l)return this._setInternalMaterialTextureParameters(i,l.material.parameters),l.material;const c={uid:i.uid,material:null,isComponentTransparent:s,alphaMode:t.material?t.material.alphaMode:"opaque"},u=je({normalTexture:i.normalTexture,metallicRoughnessTexture:i.metallicRoughnessTexture,metallicFactor:i.metallic,roughnessFactor:i.roughness,emissiveTexture:i.emissiveTexture,emissiveFactor:i.emissiveColor?.toUnitRGB(),occlusionTexture:i.occlusionTexture}),m={usePBR:this._usePBR(),isSchematic:u,hasVertexColors:i.hasVertexColors,hasSymbolColors:i.hasSymbolVertexColors,hasVertexTangents:i.hasVertexTangents,ambient:P,diffuse:A,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:0,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||c.isComponentTransparent};m.mrrFactors=u?Ae:[i.metallic,i.roughness,Re[2]],t.material&&(m.doubleSided=t.material.doubleSided,m.cullFace=t.material.doubleSided?0:2,m.textureAlphaCutoff=t.material.alphaCutoff),this._setExternalMaterialParameters(m),this._setMaterialTextureAlphaMode(m,c),this._setInternalMaterialParameters(i,m,c);const f=new Ce(m,this._context);return c.material=f,this._materialInfoCache.set(i.uid,c),f}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchColor(e,t),this._preparePatchEmissive(e,t)}_preparePatchColor(e,t){if(!t.material||"partial"!==t.material.type)return;const r=t.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const o=r.color.newValue;delete r.color,e.symbolLayerStatePatches.push(()=>{this._updateMaterialParameters(e=>{const t=e.material.parameters;this._setExternalMaterialParameters(t,o),this._setMaterialTextureAlphaMode(t,e),e.material.setParameters({externalColor:t.externalColor})})})}_preparePatchEmissive(e,t){return ce(e,t,e=>{this._updateMaterialParameters(t=>{t.material.setParameters({emissiveStrengthFromSymbol:e??1})})},this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result)}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTextureAlphaMode(e,t){if("auto"===t.alphaMode){const r=this.needsDrivenTransparentPass||t.isComponentTransparent||(e.layerOpacity??1)<1||(e.opacity??1)<1||(e.externalColor?.[3]??1)<1;e.textureAlphaMode=r?3:1}else e.textureAlphaMode="opaque"===t.alphaMode?1:"mask"===t.alphaMode?2:0}_createFaceDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,n=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),s=[],l=[],c=t[0].transformation,u=a(i(),c);for(let a=0;a<r;a++){const e=t[a].attributes.get("position");if(!e)continue;const r=e.data,o=e.indices;for(let t=0;t<o.length;t+=3)$e(r,o,t,et),Ve(r,o,t,Qe,Xe,Ze),x(Qe,Qe,Xe),x(Qe,Qe,Ze),_(Qe,Qe,1/3),y(Qe,Qe,c),s.push(...Qe),T(et,et,u),b(et,et),v(Qe,Qe,et,n),s.push(...Qe),l.push(l.length),l.push(l.length)}return s.length?new be(this._debugFaceNormalMaterial,[["position",new Te(s,l,3,!0)]],null,2):null}_createPerVertexDebugVectors(e,t,r,o,n){const l=t.length,c=e.spatialReference.isGeographic?20015077/180:1,u=.1*n*Math.max(e.extent.width*c,e.extent.height*c,e.extent.zmax-e.extent.zmin),m=[],f=[],p=t[0].transformation,h=a(i(),p);"tangent"===r&&s(h,p);for(let a=0;a<l;a++){const e=t[a],o=e.attributes.get("position"),n=e.attributes.get(r);if(!o||!n)continue;const s=o.data,i=o.indices,l=n.data,c=n.indices;for(let t=0;t<i.length;t++){const e=3*i[t],r=c[t]*n.stride;g(Qe,s[e+0],s[e+1],s[e+2]),y(Qe,Qe,p),m.push(...Qe),g(Xe,l[r+0],l[r+1],l[r+2]),T(Xe,Xe,h),b(Xe,Xe),v(Qe,Qe,Xe,u),m.push(...Qe),f.push(f.length),f.push(f.length)}}return m.length?new be(o,[["position",new Te(m,f,3,!0)]],null,2):null}_createAs3DShape(e,t,r,o){const n=e.geometry;if("mesh"!==n.type)return null;const a=this._createGeometryInfo(n,t,o);if(null==a)return null;const{geometries:s,objectTransformation:i}=a;if(ye.DRAW_MESH_GEOMETRY_NORMALS){const e=this._createPerVertexDebugVectors(n,s,"normal",this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(n,s,"tangent",this._debugTangentNormalMaterial,.5),r=this._createFaceDebugNormals(n,s);e&&s.push(e),t&&s.push(t),r&&s.push(r)}const l=this._context.layerViewUid,c=new we({geometries:s,layerViewUid:l,graphicUid:o,isElevationSource:!0});c.transformation=i;const u=_e(this.symbolLayer,{opacity:this._getLayerOpacity()}),m=u?new me(s[0].material,u,this._context.slicePlaneEnabled):null,f=new ue(this,c,null,se,r,m);this._fastUpdateProcessor.onAddGraphic(),f.needsElevationUpdates=ie(r.mode),f.useObjectOriginAsAttachmentOrigin=!0,f.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(n),r.centerInElevationSR=this._getCenterInElevationSR(c.transformation);const{elevationProvider:p,renderCoordsHelper:h}=this._context,d=(e,t)=>le(e,p,r,h,t);return f.alignedSampledElevation=se(f,r,p.spatialReference,d,h),f}_fastTransformUpdatesAllowed(e){const{vertexSpace:t,spatialReference:r}=e;if(!k(t))return!1;const{type:o}=t,{view:n}=this._context.graphicsCoreOwner,{viewingMode:a}=n.state,s=n.spatialReference;return 1===a&&"local"===o||2===a&&q(s,r)&&"georeferenced"===o&&!r.isGeographic}_getElevationSR(){return this._context.elevationProvider.spatialReference??null}_getCenterInElevationSR(e){const t=j(),r=g(at,e[12],e[13],e[14]);return E(r,this._context.renderCoordsHelper.spatialReference,t,this._getElevationSR()),t}_passthroughReprojectionInfo(e){return 0===e.reprojection&&!!e.objectTransformation}_createPositionBuffer(e,t){const r=e.vertexAttributes.position;let o,n=r;if(0===t.reprojection)return{position:n,georeferencedPositionBuffer:o};const a=1===t.reprojection?t.transformBeforeProject:null;a&&(n=Y(new Float64Array(n.length),n,a));const{normal:s,tangent:i}=e.vertexAttributes;this._passthroughReprojectionInfo(t)||!s&&!i||(o=n);const l=n===r||n===o?new Float64Array(n.length):n;return U(n,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:o}}_createNormalBuffer(e,t,r,o){const n=e.vertexAttributes.normal;if(null==n)return null;let a=n;const s=1===o.reprojection?o.transformBeforeProject:null;s&&(a=K(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(0===o.reprojection)return a;if("local"===i){if(!W(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return J(a,0,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Q(a,0,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return X(a,r,e.spatialReference,t,c,l)}_createTangentBuffer(e,t,r,o){const n=e.vertexAttributes.tangent;if(null==n)return null;let a=n;const s=1===o.reprojection?o.transformBeforeProject:null;s&&(a=Z(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(0===o.reprojection)return a;if("local"===i){if(!W(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return J(a,1,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Q(a,1,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return ee(a,r,e.spatialReference,t,c,l)}_createSymbolColorBuffer(e){return this._requiresSymbolVertexColors()?new Uint8Array(this._getDrivenUInt8ColorWithNaNSupport(e,this._materialColor,!0)):null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,n=e.vertexAttributes.uv,a=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(n&&n.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),{position:i,georeferencedPositionBuffer:l}=this._createPositionBuffer(e,s),c=We(e),u=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,l,s),p=this._createTangentBuffer(e,i,l,s),h=n,{transformation:d,position:g,normal:x,tangent:_}=this._passthroughReprojectionInfo(s)?{transformation:s.objectTransformation,position:i,normal:m,tangent:p}:this._transformOriginLocal(e,i,m,p);return{positionBuffer:g,normalBuffer:x,tangentBuffer:_,uvBuffer:h,colorBuffer:c,symbolColorBuffer:u,objectTransformation:d,geometryTransformation:0===s.reprojection&&s.geometryTransformation?s.geometryTransformation:f()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?q(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?0:1:0;if(z(t))return{reprojection:r};const o=t.origin,n=f(),a=e.transform?.localMatrix??p;if(0===r){B(e.spatialReference,o,n,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:n,geometryTransformation:h(a)}}const s=l(f(),o);return c(s,s,a),{reprojection:r,transformBeforeProject:s}}_transformOriginLocal(e,t,r,o){const n=this._context.renderCoordsHelper.spatialReference,a=e.origin;Je[0]=a.x,Je[1]=a.y,Je[2]=a.z??0;const s=f();B(e.spatialReference,Je,s,n),u(tt,s);const{position:i,normal:l,tangent:c}=e.vertexAttributes,m=t===i?new Float64Array(t.length):t;Y(m,t,tt);const p=r?r===l?new Float32Array(r.length):r:null,h=o?o===c?new Float32Array(o.length):o:null;return r&&p&&K(r,p,tt),o&&h&&Z(o,h,tt),{transformation:s,position:m,normal:p,tangent:h}}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=te(e,r??e.spatialReference);return!!o&&(F(o,ot),!V(ot,this._context.clippingExtent))}_createGeometryInfo(e,t,r){if(!I(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(!this._validateVertexSpace(e))return null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:n,uvBuffer:a,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:c,objectTransformation:u,geometryTransformation:f}=o,p=e.components??nt,h=new Array;let d=!1;const g=m(Qe,u),x=this._context.localOriginFactory.getOrigin(g);for(const m of p){if(!this._validateFaces(e,m))return null;const t=Be(e,m);if(0===t.length)continue;const o=Ue(n,l,m,t);o.didFlipNormals&&(d=!0);const u=[["position",new Te(n,t,3,!0)],["normal",new Te(o.normals,o.indices,3,!0)]];s&&u.push(["color",new Te(s,t,4,!0)]),i&&u.push(["symbolColor",new Te(i,G(t.length),4,!0)]),a&&u.push(["uv0",new Te(a,t,2,!0)]),c&&u.push(["tangent",new Te(c,t,4,!0)]);const p=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerViewUid:this._context.layerViewUid}),g=this._getOrCreateMaterial(e,m),_=new be(g,u,null,0,p);_.transformation=f,_.localOrigin=x,h.push(_)}return d&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:h,objectTransformation:u}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial((e,t)=>{t.setParameters(e.parameters)})}_validateVertexSpace(e){const{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:r}=e;return 2!==t||"local"!==r.type||(this.logger.warn("Displaying a mesh with a local vertex space in a view in local viewing mode is not supported."),!1)}test(){return{...super.test(),materials:this._materialInfoCache.materials}}get _materialColor(){return this.symbolLayer.material?.color}}class Ie{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}function Be(e,t){return t.faces??D(e.vertexAttributes.position.length/3)}function Ue(e,t,r,o){switch(r.shading||"flat"){default:case"source":return Fe(e,t,r,o);case"flat":return Ee(e,o);case"smooth":return Oe(e,o)}}function Ee(e,t){const r=$(t.length),o=new Array(3*t.length);for(let n=0;n<t.length;n+=3){const a=$e(e,t,n,et);for(let e=0;e<3;e++)r[n+e]=a[e],o[n+e]=n/3}return new Ie(r,o,!1)}function Fe(e,t,r,o){if(null==t)return Ee(e,o);let n=!1;if(!r.trustSourceNormals)for(let a=0;a<o.length;a+=3){$e(e,o,a,et);for(let e=0;e<3;e++){const r=3*o[a+e];Qe[0]=t[r],Qe[1]=t[r+1],Qe[2]=t[r+2],M(et,Qe)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],n=!0)}}return new Ie(t,o,n)}function Oe(e,t){const r={};for(let a=0;a<t.length;a+=3){const o=$e(e,t,a,et);for(let e=0;e<3;e++){const n=t[a+e];let s=r[n];s||(s={normal:j(),count:0},r[n]=s),x(s.normal,s.normal,o),s.count++}}const o=$(3*t.length),n=new Array(3*t.length);for(let a=0;a<t.length;a++){const e=r[t[a]];1!==e.count&&(b(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*a+t]=e.normal[t];n[a]=a}return new Ie(o,n,!1)}function Ve(e,t,r,o,n,a){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],n[0]=e[i],n[1]=e[i+1],n[2]=e[i+2],a[0]=e[l],a[1]=e[l+1],a[2]=e[l+2]}function $e(e,t,r,o){return Ve(e,t,r,Qe,Xe,Ze),w(Xe,Xe,Qe),w(Ze,Ze,Qe),C(Qe,Xe,Ze),b(o,Qe),o}function Ge(e){if(!e)return null;const{scale:t,offset:o,rotation:n}=e;return{scale:t,offset:o,rotation:r(n)}}function De(e="repeat"){if("string"==typeof e){const t=Le(e);return{s:t,t}}return{s:Le(e.horizontal),t:Le(e.vertical)}}function Le(e){switch(e){case"clamp":return 33071;case"mirror":return 33648;default:return 10497}}function Ne(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}function He(e,t,r){t.diffuse=e.toUnitRGB(),t.opacity="opaque"===r.alphaMode?1:e.a}function ke(e){return e.data??e.url}function ze(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}function qe(e){const{offset:t,scale:r,rotation:o}=e??Ke;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}function We(e){return e.vertexAttributes.color}function Ye(e){return 1===(e.material?.color?.a??0)}const Ke=new H,Je=j(),Qe=j(),Xe=j(),Ze=j(),et=j(),tt=f(),rt=f(),ot=O(),nt=[new L],at=j();export{Se as Graphics3DMeshFillSymbolLayer};
|