@arcgis/core 4.26.0-next.20230111 → 4.26.0-next.20230113
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/arcade/ArcadeDate.js +5 -0
- package/arcade/Dictionary.js +1 -1
- package/arcade/Feature.js +1 -1
- package/arcade/arcadeAsyncRuntime.js +1 -1
- package/arcade/arcadeCompiler.js +1 -1
- package/arcade/arcadeRuntime.js +1 -1
- package/arcade/arcadeTimeUtils.js +5 -0
- package/arcade/executionError.js +1 -1
- package/arcade/featureset/actions/Adapted.js +1 -1
- package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
- package/arcade/featureset/sources/FeatureLayerMemory.js +1 -1
- package/arcade/featureset/sources/FeatureLayerRelated.js +1 -1
- package/arcade/featureset/support/FeatureSet.js +1 -1
- package/arcade/featureset/support/shared.js +1 -1
- package/arcade/featureset/support/sqlUtils.js +1 -1
- package/arcade/functions/date.js +1 -1
- package/arcade/functions/featuresetbase.js +1 -1
- package/arcade/functions/featuresetstring.js +1 -1
- package/arcade/functions/geomasync.js +1 -1
- package/arcade/functions/geometry.js +1 -1
- package/arcade/functions/geomsync.js +1 -1
- package/arcade/functions/maths.js +1 -1
- package/arcade/functions/string.js +1 -1
- package/arcade/languageUtils.js +1 -1
- package/arcade/treeAnalysis.js +1 -1
- package/arcade.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{c9477250a5d5ebdef00c.js → 01cd5a9cd4cb1f13691c.js} +1 -1
- package/assets/esri/core/workers/chunks/028f9a133104e78e60d2.js +1 -0
- package/assets/esri/core/workers/chunks/033e6ae5da6afebd993c.js +1 -0
- package/assets/esri/core/workers/chunks/05ab092987251d4a1242.js +1 -0
- package/assets/esri/core/workers/chunks/1186a56dacaf269d5271.js +1 -0
- package/assets/esri/core/workers/chunks/264e1c00936bcafb9a36.js +1 -0
- package/assets/esri/core/workers/chunks/2680392cef77d98ad097.js +1 -0
- package/assets/esri/core/workers/chunks/27ba1889fe9f1812389a.js +1165 -0
- package/assets/esri/core/workers/chunks/2dfb17fa5b6a5d239942.js +1 -0
- package/assets/esri/core/workers/chunks/2e3962506c353b562a88.js +1 -0
- package/assets/esri/core/workers/chunks/30ae4c22f6b8aab9f841.js +1 -0
- package/assets/esri/core/workers/chunks/329e512f210cb3e904f1.js +1 -0
- package/assets/esri/core/workers/chunks/3878efe67f43962b46f8.js +1 -0
- package/assets/esri/core/workers/chunks/3b6748f414437cc6cfde.js +1 -0
- package/assets/esri/core/workers/chunks/41d25407888326c91566.js +1 -0
- package/assets/esri/core/workers/chunks/493e2b00133682748e62.js +1 -0
- package/assets/esri/core/workers/chunks/4b2edcb8ef7fae4f7d28.js +1 -0
- package/assets/esri/core/workers/chunks/{c11d857dca43de2229fc.js → 4c085cee22ff64ce6d1f.js} +1 -1
- package/assets/esri/core/workers/chunks/4d8c53e961275b6a4ee1.js +1 -0
- package/assets/esri/core/workers/chunks/5049771eeffe208a9cb8.js +1 -0
- package/assets/esri/core/workers/chunks/{58d219ffd9dcc45bb0d1.js → 5191f80f2413ee92c875.js} +1 -1
- package/assets/esri/core/workers/chunks/5dfed65b615b33588488.js +1 -0
- package/assets/esri/core/workers/chunks/5e9869849d999aac5756.js +1 -0
- package/assets/esri/core/workers/chunks/6216cd8134703fd9d9b4.js +1 -0
- package/assets/esri/core/workers/chunks/62c8e43741f2d6141f00.js +1 -0
- package/assets/esri/core/workers/chunks/64f137358100a1c818f0.js +1 -0
- package/assets/esri/core/workers/chunks/6f5f81855985db7c1936.js +1 -0
- package/assets/esri/core/workers/chunks/6fba07833345b2d8d373.js +1 -0
- package/assets/esri/core/workers/chunks/{80c7726743baf9f54079.js → 7747ee359d357f6e5858.js} +1 -1
- package/assets/esri/core/workers/chunks/78fd609f334a29ef39dc.js +1 -0
- package/assets/esri/core/workers/chunks/798cd875d64182741364.js +1 -0
- package/assets/esri/core/workers/chunks/{9d247a46e0cfdad26273.js → 8176286f8dd055c8ae05.js} +1 -1
- package/assets/esri/core/workers/chunks/8530ac02c840c89cc1df.js +1 -0
- package/assets/esri/core/workers/chunks/8a69a9b5a04e7321740d.js +1 -0
- package/assets/esri/core/workers/chunks/8bd26c71e78698c16778.js +1 -0
- package/assets/esri/core/workers/chunks/8c12b82612f050492fef.js +1 -0
- package/assets/esri/core/workers/chunks/90653ef5e718bafd6960.js +1 -0
- package/assets/esri/core/workers/chunks/{418922fd99e733df023f.js → 9070aa0a94a9204ded1c.js} +1 -1
- package/assets/esri/core/workers/chunks/{2ac0d2164a1b49e6f057.js → 94633a9bb5fa4f4ba4de.js} +1 -1
- package/assets/esri/core/workers/chunks/969bb94d5bdc9da114e2.js +1 -0
- package/assets/esri/core/workers/chunks/9785dba81a6af339e35a.js +1 -0
- package/assets/esri/core/workers/chunks/99e16173584702577b80.js +1 -0
- package/assets/esri/core/workers/chunks/9aee6f171d4fbac941d9.js +1 -0
- package/assets/esri/core/workers/chunks/a194f90ffe13b3d448b0.js +1 -0
- package/assets/esri/core/workers/chunks/a53d194e3eede703a6df.js +1 -0
- package/assets/esri/core/workers/chunks/a605bf8bc29099ae1b1a.js +1 -0
- package/assets/esri/core/workers/chunks/ba7239089a04098e3619.js +1 -0
- package/assets/esri/core/workers/chunks/bd2fe663a2b090b134e9.js +1 -0
- package/assets/esri/core/workers/chunks/c16003307aad2f84ac51.js +1 -0
- package/assets/esri/core/workers/chunks/c6eb6a97ecc6ed9ce713.js +1 -0
- package/assets/esri/core/workers/chunks/c81d898f4aef6ecacdb5.js +1 -0
- package/assets/esri/core/workers/chunks/cb83480d7074f6185e21.js +1 -0
- package/assets/esri/core/workers/chunks/cd0fa942d57a278b0a44.js +1 -0
- package/assets/esri/core/workers/chunks/d55332e4d7b8184fd718.js +1 -0
- package/assets/esri/core/workers/chunks/d6842acbfa7a39f3ca30.js +1 -0
- package/assets/esri/core/workers/chunks/d798bd544433e932f772.js +1 -0
- package/assets/esri/core/workers/chunks/e18851e915cb69f53032.js +1 -0
- package/assets/esri/core/workers/chunks/{54899827baea77776fc7.js → ea1054116ec842a4f813.js} +1 -1
- package/assets/esri/core/workers/chunks/ed1312c2627c0d7e654d.js +1 -0
- package/assets/esri/core/workers/chunks/f2750a7b44e8bc8b1e4c.js +1 -0
- package/assets/esri/themes/base/widgets/_Editor.scss +1 -11
- package/assets/esri/themes/base/widgets/_ItemList.scss +0 -13
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ar.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_bg.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_bs.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ca.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_cs.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_da.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_de.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_el.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_es.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_et.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_fi.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_fr.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_he.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_hr.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_hu.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_id.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_it.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ja.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ko.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_lt.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_lv.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_nb.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_nl.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_pl.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_pt-BR.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_pt-PT.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ro.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_ru.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_sk.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_sl.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_sr.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_sv.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_th.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_tr.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_uk.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_vi.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_zh-CN.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_zh-HK.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_zh-TW.json +1 -1
- package/chunks/ComponentShader.glsl.js +1 -1
- package/chunks/Path.glsl.js +1 -1
- package/chunks/Terrain.glsl.js +1 -1
- package/chunks/languageUtils.js +1 -1
- package/geometry/support/MeshTexture.js +1 -1
- package/geometry/support/aaBoundingBox.js +1 -1
- package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
- package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
- package/interfaces.d.ts +1400 -1314
- package/layers/ImageryTileLayer.js +1 -1
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/layers/graphics/data/FeatureStore.js +1 -1
- package/layers/graphics/data/QueryEngine.js +1 -1
- package/layers/graphics/data/timeSupport.js +1 -1
- package/layers/graphics/featureConversionUtils.js +1 -1
- package/layers/graphics/sources/WFSSourceWorker.js +1 -1
- package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
- package/layers/graphics/sources/support/CSVSourceWorker.js +1 -1
- package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/mixins/ImageryTileMixin.js +1 -1
- package/layers/support/layerOriginUtils.js +1 -1
- package/layers/support/rasterFormats/JpgPlus.js +1 -1
- package/layers/support/rasterFormats/TiffDecoder.js +1 -1
- package/layers/support/rasterFunctions/ConvolutionFunction.js +1 -1
- package/layers/support/rasterFunctions/ConvolutionFunctionArguments.js +1 -1
- package/layers/support/rasterFunctions/ExtractBandFunction.js +1 -1
- package/layers/support/rasterFunctions/ExtractBandFunctionArguments.js +1 -1
- package/layers/support/rasterFunctions/NDVIFunction.js +1 -1
- package/layers/support/rasterFunctions/NDVIFunctionArguments.js +1 -1
- package/layers/support/rasterFunctions/SlopeFunctionArguments.js +1 -1
- package/layers/support/rasterFunctions/StatisticsHistogramFunction.js +5 -0
- package/layers/support/rasterFunctions/{StatisticsHistogramsFunctionArguments.js → StatisticsHistogramFunctionArguments.js} +1 -1
- package/layers/support/rasterFunctions/rasterFunctionHelper.js +1 -1
- package/package.json +1 -1
- package/rest/imageService.js +1 -1
- package/rest/support/BaseImageMeasureResult.d.ts +4 -0
- package/rest/support/ImageAreaParameters.d.ts +4 -0
- package/rest/support/{ImageMeasureAreaAndPerimeterParameters.js → ImageAreaParameters.js} +1 -1
- package/rest/support/ImageAreaResult.d.ts +4 -0
- package/rest/support/{ImageMeasureAreaAndPerimeterResult.js → ImageAreaResult.js} +1 -1
- package/rest/support/ImageDistanceParameters.d.ts +4 -0
- package/rest/support/{ImageMeasureDistanceAndAngleParameters.js → ImageDistanceParameters.js} +1 -1
- package/rest/support/ImageDistanceResult.d.ts +4 -0
- package/rest/support/ImageDistanceResult.js +5 -0
- package/rest/support/ImageHeightParameters.d.ts +4 -0
- package/rest/support/{ImageMeasureHeightParameters.js → ImageHeightParameters.js} +1 -1
- package/rest/support/ImageHeightResult.d.ts +4 -0
- package/rest/support/{ImageMeasureHeightResult.js → ImageHeightResult.js} +1 -1
- package/rest/support/ImagePointParameters.d.ts +4 -0
- package/rest/support/{ImageMeasurePointParameters.js → ImagePointParameters.js} +1 -1
- package/rest/support/ImagePointResult.d.ts +4 -0
- package/rest/support/{ImageMeasurePointResult.js → ImagePointResult.js} +1 -1
- package/support/arcadeUtils.js +1 -1
- package/support/revision.js +1 -1
- package/time/timeReferenceUtils.js +1 -1
- package/views/2d/engine/webgl/Overlay.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/features/FeatureStore2D.js +1 -1
- package/views/2d/layers/features/Pipeline.js +1 -1
- package/views/2d/layers/features/support/BinStore.js +1 -1
- package/views/2d/layers/features/support/ClusterStore.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
- package/views/3d/environment/EnvironmentRenderer.js +1 -1
- package/views/3d/glTF/internal/Resource.js +1 -1
- package/views/3d/glTF/internal/resourceUtils.js +5 -0
- package/views/3d/layers/VectorTileLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DFeatureStore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Labeler.js +1 -1
- package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
- package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
- package/views/3d/layers/i3s/I3SQueryFeatureStore.js +1 -1
- package/views/3d/state/ViewState.js +1 -1
- package/views/3d/state/ViewStateManager.js +1 -1
- package/views/3d/terrain/Overlay.js +1 -1
- package/views/3d/terrain/OverlayManager.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/TileRenderer.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/output/OutputDepth.glsl.js +1 -1
- package/views/3d/webgl-engine/lib/AnimationTimeStep.js +5 -0
- package/views/3d/webgl-engine/lib/AnimationTimer.js +1 -1
- package/views/3d/webgl-engine/lib/GLMaterial.js +1 -1
- package/views/3d/webgl-engine/lib/Material.js +1 -1
- package/views/3d/webgl-engine/lib/RenderFeature.js +5 -0
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/Texture.js +1 -1
- package/views/3d/webgl-engine/lib/basicInterfaces.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/draw/support/layerUtils.js +1 -1
- package/views/webgl/RenderingContext.js +1 -1
- package/views/webgl/Texture.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/FeatureTemplates/FeatureTemplatesViewModel.js +1 -1
- package/widgets/FeatureTemplates/ItemList.js +1 -1
- package/widgets/FeatureTemplates/TemplateItem.js +1 -1
- package/widgets/FeatureTemplates/TemplateItemGroup.js +1 -1
- package/widgets/FeatureTemplates.js +1 -1
- package/widgets/LineOfSight/LineOfSightViewModel.js +1 -1
- package/widgets/support/decorators/accessibleHandler.js +1 -1
- package/assets/esri/core/workers/chunks/038dc3f9ef06ef3c960c.js +0 -1
- package/assets/esri/core/workers/chunks/078a0b134210167b629d.js +0 -1
- package/assets/esri/core/workers/chunks/080a4be417be4943f6a0.js +0 -1
- package/assets/esri/core/workers/chunks/0877bab7c03a1de2e713.js +0 -1
- package/assets/esri/core/workers/chunks/0c9200ab19fd2f56f87f.js +0 -1
- package/assets/esri/core/workers/chunks/1cbffa96ea6683e5f3ec.js +0 -1
- package/assets/esri/core/workers/chunks/1f742c3b11c76814fa4d.js +0 -1
- package/assets/esri/core/workers/chunks/2eb2d49c549e53934b8b.js +0 -1
- package/assets/esri/core/workers/chunks/332494b96a47b378f4e0.js +0 -1
- package/assets/esri/core/workers/chunks/3326536d183a858a2a4d.js +0 -1
- package/assets/esri/core/workers/chunks/3f4fc8379fc11bc293cc.js +0 -1
- package/assets/esri/core/workers/chunks/43fecd621cd043f64828.js +0 -1165
- package/assets/esri/core/workers/chunks/47b0b660f5412097fe26.js +0 -1
- package/assets/esri/core/workers/chunks/4c0d7a074083aa9614bb.js +0 -1
- package/assets/esri/core/workers/chunks/594d7e871b648d5c9662.js +0 -1
- package/assets/esri/core/workers/chunks/680b90ac98e8d1ac0e33.js +0 -1
- package/assets/esri/core/workers/chunks/6b589f47cb4731df1639.js +0 -1
- package/assets/esri/core/workers/chunks/72557c4b1582aa18ad4d.js +0 -1
- package/assets/esri/core/workers/chunks/72b490ad371e0c2264f6.js +0 -1
- package/assets/esri/core/workers/chunks/75ce17cf13aab0440572.js +0 -1
- package/assets/esri/core/workers/chunks/75f4e884a1a0aedc0afd.js +0 -1
- package/assets/esri/core/workers/chunks/7b9ab3fb378172831c14.js +0 -1
- package/assets/esri/core/workers/chunks/7bef95b168303bdc4bf1.js +0 -1
- package/assets/esri/core/workers/chunks/803492088780e18de801.js +0 -1
- package/assets/esri/core/workers/chunks/89003e387684af5ebeac.js +0 -1
- package/assets/esri/core/workers/chunks/8f93026764a0cce0901b.js +0 -1
- package/assets/esri/core/workers/chunks/98350b6b95da62ef5f12.js +0 -1
- package/assets/esri/core/workers/chunks/a9cae0d386aa9c00f744.js +0 -1
- package/assets/esri/core/workers/chunks/ad65c24558098f21bbf3.js +0 -1
- package/assets/esri/core/workers/chunks/aef90ee3f0979a7acb38.js +0 -1
- package/assets/esri/core/workers/chunks/b68c7754b0220b194ecf.js +0 -1
- package/assets/esri/core/workers/chunks/c012317f045a74fdd79d.js +0 -1
- package/assets/esri/core/workers/chunks/cb42675e5b1c41634c63.js +0 -1
- package/assets/esri/core/workers/chunks/cb901033dd15b3b72025.js +0 -1
- package/assets/esri/core/workers/chunks/d398b6b8a6b0a95247de.js +0 -1
- package/assets/esri/core/workers/chunks/d447ebc944a9867f5a99.js +0 -1
- package/assets/esri/core/workers/chunks/daaabed988b6ea866350.js +0 -1
- package/assets/esri/core/workers/chunks/e048641971aef9dd4da9.js +0 -1
- package/assets/esri/core/workers/chunks/e3fd383aee378cbb0dae.js +0 -1
- package/assets/esri/core/workers/chunks/e967ffca641947212992.js +0 -1
- package/assets/esri/core/workers/chunks/e9c81eee503c1b112bad.js +0 -1
- package/assets/esri/core/workers/chunks/ea6cf948fe2de0242308.js +0 -1
- package/assets/esri/core/workers/chunks/ed5e71b45dfefcbb2da4.js +0 -1
- package/assets/esri/core/workers/chunks/ee50d5d0afe9bdccc84d.js +0 -1
- package/assets/esri/core/workers/chunks/ee91401507833875facc.js +0 -1
- package/assets/esri/core/workers/chunks/f7d40dd78ef116f5793b.js +0 -1
- package/assets/esri/core/workers/chunks/f8ab6e354834b9c0e857.js +0 -1
- package/assets/esri/core/workers/chunks/faea681c279486b7a5e7.js +0 -1
- package/layers/support/rasterFunctions/StatisticsHistogramsFunction.js +0 -5
- package/rest/support/ImageMeasureDistanceAndAngleResult.js +0 -5
- package/views/3d/support/animationUtils.js +0 -5
- package/views/3d/webgl-engine/lib/RenderStateFeature.js +0 -5
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../core/Accessor.js";import r from"../../../../core/Evented.js";import{isSome as o,isNone as s}from"../../../../core/maybe.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as a}from"../../../../core/accessorSupport/decorators/subclass.js";import{projectPoint as c}from"../../../../geometry/projection.js";import{
|
|
5
|
+
import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../core/Accessor.js";import r from"../../../../core/Evented.js";import{isSome as o,isNone as s}from"../../../../core/maybe.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as a}from"../../../../core/accessorSupport/decorators/subclass.js";import{projectPoint as c}from"../../../../geometry/projection.js";import{create as p}from"../../../../geometry/support/aaBoundingBox.js";import{getObjectId as n}from"../../../../layers/graphics/dehydratedFeatures.js";import{OptimizedFeature as h}from"../../../../layers/graphics/OptimizedFeature.js";import d from"../../../../layers/graphics/OptimizedGeometry.js";import{optimizedFeatureQueryEngineAdapter as u}from"../../../../layers/graphics/data/optimizedFeatureQueryEngineAdapter.js";const l=p();let m=class extends e{constructor(t){super(t),this.events=new r,this.hasZ=null,this.hasM=null,this.objectIdField=null,this.featureAdapter={getAttribute:(t,e)=>"graphic"in t?t.graphic.attributes[e]:u.getAttribute(t,e),getAttributes:t=>"graphic"in t?t.graphic.attributes:u.getAttributes(t),getObjectId:t=>"graphic"in t?n(t.graphic,this.objectIdField)??void 0:u.getObjectId(t),getGeometry:t=>"graphic"in t?t.getAsOptimizedGeometry(this.hasZ,this.hasM):u.getGeometry(t),getCentroid:(t,e)=>{if("graphic"in t){let r=null;o(t.centroid)?r=t.centroid:"point"===t.graphic.geometry.type&&c(t.graphic.geometry,g,this.viewSpatialReference)&&(r=g);const i=new Array(2+(e.hasZ?1:0)+(e.hasM?1:0));return s(r)?(i[0]=0,i[1]=0,i[2]=0,i[3]=0):(i[0]=r.x,i[1]=r.y,e.hasZ&&(i[2]=r.hasZ?r.z:0),e.hasM&&(i[e.hasZ?3:2]=r.hasM?r.m:0)),new d([],i)}return u.getCentroid(t,e)},cloneWithGeometry:(t,e)=>"graphic"in t?new h(e,this.featureAdapter.getAttributes(t),null,this.featureAdapter.getObjectId(t)):u.cloneWithGeometry(t,e)}}forEachInBounds(t,e){this.getSpatialIndex().forEachInBounds(t,e)}forEachBounds(t,e){const r=this.getSpatialIndex();for(const s of t){const t=this.featureAdapter.getObjectId(s);o(r.getBounds(t,l))&&e(l)}}};t([i({constructOnly:!0})],m.prototype,"getSpatialIndex",void 0),t([i({constructOnly:!0})],m.prototype,"forEach",void 0),t([i({constructOnly:!0})],m.prototype,"hasZ",void 0),t([i({constructOnly:!0})],m.prototype,"hasM",void 0),t([i({constructOnly:!0})],m.prototype,"objectIdField",void 0),t([i({constructOnly:!0})],m.prototype,"viewSpatialReference",void 0),t([i({constructOnly:!0})],m.prototype,"featureSpatialReference",void 0),m=t([a("esri.views.3d.layers.graphics.Graphics3DFeatureStore")],m);const g={type:"point",x:0,y:0,hasZ:!1,hasM:!1,spatialReference:null};export{m as Graphics3DFeatureStore};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import"../../../../symbols.js";import{result as t}from"../../../../core/asyncUtils.js";import i from"../../../../core/Error.js";import{isSome as r,get as s,isNone as a,unwrapOr as o,releaseMaybe as n,unwrap as l}from"../../../../core/maybe.js";import{throwIfAbortError as c,throwIfAborted as h}from"../../../../core/promiseUtils.js";import{pt2px as m,px2pt as u}from"../../../../core/screenUtils.js";import{dataComponents as d}from"../../../../core/urlUtils.js";import{c as _}from"../../../../chunks/mat4f64.js";import{f as p,a as f}from"../../../../chunks/vec2f64.js";import{Z as y,O as g,f as x}from"../../../../chunks/vec3f64.js";import{c as S}from"../../../../chunks/vec4.js";import{f as b,c as v}from"../../../../chunks/vec4f64.js";import{projectPointToVector as z}from"../../../../geometry/projection.js";import{containsPoint as P}from"../../../../geometry/support/aaBoundingBox.js";import{createRendererExpression as R}from"../../../../support/arcadeOnDemand.js";import{defaultPrimitive as C}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{getIconHref as M}from"../../../../symbols/support/utils.js";import j from"../../../2d/arcade/callExpressionWithFeature.js";import{TRANSPARENT_UNIT as I}from"./constants.js";import{perObjectElevationAligner as w}from"./ElevationAligners.js";import{SymbolUpdateType as O,elevationModeChangeUpdateType as T,needsElevationUpdates2D as E}from"./elevationAlignmentUtils.js";import{ElevationContext as U}from"./ElevationContext.js";import L from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as D}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as F}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as A}from"./graphicUtils.js";import{ApplyRendererDiffResult as G}from"./interfaces.js";import{namedAnchorToHUDMaterialAnchorPos as V}from"./placementUtils.js";import{placePointOnGeometry as B,createStageObject as N,extendPointGraphicElevationContext as k}from"./pointUtils.js";import{initFastSymbolUpdatesState as q,updateFastSymbolUpdatesState as H,evaluateModelTransform as W}from"../support/FastSymbolUpdates.js";import{createTexture as $,DEFAULT_SYMBOL_SIZE_RATIO as Z,DEFAULT_TEX_SIZE as J}from"../../support/engineContent/sdfPrimitives.js";import{DRAPED_Z as K}from"../../terrain/OverlayRenderer.js";import{PowerOfTwoResizeMode as Q}from"../../webgl-engine/lib/basicInterfaces.js";import{createPointGeometry as X}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as Y}from"../../webgl-engine/lib/RenderGeometry.js";import{Texture as ee}from"../../webgl-engine/lib/Texture.js";import{HUDMaterial as te}from"../../webgl-engine/materials/HUDMaterial.js";import ie from"../../../../symbols/CIMSymbol.js";const re=_(),se=x(0,0,1),ae=16,oe=1.5,ne=Z,le=[ne/2,ne/2,1-ne/2,1-ne/2],ce=[J*ne,J*ne];class he extends F{getCachedSize(){return{size:this._getIconSize()}}constructor(e,t,i,r){super(e,t,i,r),this._cimLayers=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimRequiredFields=null,this._cimScaleFactorOrFunction=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),i=this._getPrimitive();if(r(i))this._prepareResourcesPrimitive(t,i);else{const i=M(this.symbolLayer),r=d(i);r&&"application/json"===r.mediaType?await this._prepareResourcesCIM(t,JSON.parse(r.data),e):await this._prepareResourcesHref(t,i,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=A(this._getIconSize());if(e)throw new i("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?m(e.size):ae);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e){const t=this._getGraphicHash(e);let i=""===t?null:this._cimSymbolTextures.get(t);if(!i){const r={scaleFactor:this._cimScaleFactorOrFunction},s=this._context.sharedResources.cimSymbolRasterizer.rasterizeCIMSymbol3D(this._cimLayers,e,"esriGeometryPoint",r,void 0,void 0);this._cimMaterialParametersInfo.anchorPosition=this._getAnchorPos("relative",s.anchorPosition);const a={width:s.imageData.width,height:s.imageData.height,powerOfTwoResizeMode:Q.PAD};i=new ee(s.imageData,a),this._cimSymbolTextures.set(t,i),this._context.stage.add(i)}return i}_computeSize(e,t){const i=e.width/e.height;return i>1?[t,Math.round(t/i)]:[Math.round(t*i),t]}_prepareMaterialParameters(){const e={anchorPosition:this._getAnchorPos(this.symbolLayer.anchor,this.symbolLayer.anchorPosition)},t=this.symbol;if(me(t)){const{screenLength:i,minWorldLength:s,maxWorldLength:a}=t.verticalOffset;e.verticalOffset={screenLength:m(i),minWorldLength:s||0,maxWorldLength:r(a)?a:1/0}}return this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),e.occlusionTest=!0,e.hasSlicePlane=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const i=this._getOutlineSize();if(ue(t)&&0===i)throw new Error("Nothing to render");if(this._outlineSize=i,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,r(this._context.sharedResources.textures)){const i=this._context.sharedResources.textures.fromData(`${t}-icon`,(()=>$(t)));this._texture=i.texture,this._releaseTexture=i,e.textureId=this._texture.id}e.textureIsSignedDistanceField=!0,e.distanceFieldBoundingBox=le;const s=this._getIconSize();this._size=[s,s],this._symbolTextureRatio=1/ne,this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesHref(e,s,a){this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),n=o*this._context.graphicsCoreOwner.view.state.idlePixelRatio;if(r(this._context.sharedResources.textures)){const r=await t(this._context.sharedResources.textures.fromUrl(s,n,{signal:a}));if(!1===r.ok){c(r.error);throw new i("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${s})`)}this._releaseTexture=r.value;const l=r.value.texture,h=l.params;this._size=this._computeSize(h,o),e.textureId=l.id}this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesCIM(e,t,i){const r=new ie({data:t});if(!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;h(i),this._context.sharedResources.cimSymbolRasterizer||(this._context.sharedResources.cimSymbolRasterizer=new e(this._context.renderCoordsHelper.spatialReference,!0))}const s=this._context.layer.fields?this._context.layer.fields.map((e=>e.toJSON())):null;let a,o;if(this._cimLayers=await this._context.sharedResources.cimSymbolRasterizer.analyzeCIMSymbol(r,s,this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null,"esriGeometryPoint",{signal:i}),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(isNaN(e.scaleExpression)){const t=e.scaleExpression,i=await R(t,this._context.layer.spatialReference,s);o=(e,t,r)=>{const s=j(i,e,{$view:r},"esriGeometryPoint",t);return null!==s?s:1}}else a=Number(e.scaleExpression)}this._cimScaleFactorOrFunction=a||o||1;const n=this._context.renderer?await this._context.renderer.getRequiredFields(this._context.layer.fieldsIndex):[];h(i);const l=this._context.layer.fieldsIndex;this._cimRequiredFields=n.map((e=>l.get(e).name)),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return this.symbolLayer.resource&&this.symbolLayer.resource.href?null:this.symbolLayer.resource&&this.symbolLayer.resource.primitive||C}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(r(t.outline)&&null!=t.outline.size)return Math.max(m(t.outline.size),0);return e=ue(this._getPrimitive())?oe:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),i=this.symbolLayer,a=s(i,"outline","color");if(r(a)){const i=e.toUnitRGB(a),r=a.a*t;return[i[0],i[1],i[2],r]}return[0,0,0,0]}_getFillColor(){if(ue(this._getPrimitive()))return I;const e=a(this._getPrimitive()),t=s(this.symbolLayer,"material","color");return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}_getAnchorPos(e,t){return"relative"===e?p((t.x||0)+.5,.5-(t.y||0)):e in V?V[e]:V.center}_createMaterialAndAddToStage(e,t){if(this._cimLayers?this._fastUpdates={enabled:!1}:this._fastUpdates=q(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates.enabled&&Object.assign(e,this._fastUpdates.materialParameters),this._cimLayers){let i=r(e.textureId)?this._cimSymbolMaterials.get(e.textureId):null;return i||(i=new te(e),this._cimSymbolMaterials.set(o(e.textureId,0),i),t.add(i)),i}return this._material=new te(e),t.add(this._material),this._material}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial((e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,hasSlicePlane:!1,shaderPolygonOffset:0,isDraped:this.draped})})),this.layerOpacityChanged())}destroy(){super.destroy(),this._forEachMaterial((e=>this._context.stage.remove(e))),this._material=null,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach((e=>this._context.stage.remove(e))),this._cimSymbolTextures.clear(),this._releaseTexture=n(this._releaseTexture)}_getScaleFactor(e,t){if(this._drivenProperties.size&&e.size){for(let t=0;t<3;t++){const i=e.size[t];i&&"symbol-value"!==i&&"proportional"!==i&&(e.size[t]=m(i))}if("symbol-value"===e.size[0])return 1;if(isFinite(+e.size[0]))return+e.size[0]/t;if(isFinite(+e.size[2]))return+e.size[2]/t}return 1}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;let i,r=[0,0];if(this._cimLayers){if(!this._cimLayers.length)return null;const e=this._generateTextureCIM(t),s={textureId:e.id,...this._cimMaterialParametersInfo};i=this._createMaterialAndAddToStage(s,this._context.stage),r=[e.params.width,e.params.height]}else r=this._size,i=l(this._material);const s=B(t.geometry);if(a(s))return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const o=e.renderingInfo,n=this._getVertexOpacityAndColor(o);let c=1;if(!this._fastUpdates.enabled||!this._fastUpdates.visualVariables.size){const e=r[0]>r[1]?r[0]:r[1];c=this._getScaleFactor(o,e)}c*=this._symbolTextureRatio;const h=p(r[0]*c,r[1]*c),m=this.setGraphicElevationContext(t,new U);return this.ensureDrapedStatus("on-the-ground"===m.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,s,i,n,h,e.layer.uid):this._createAs3DShape(t,s,i,n,h,m,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial((i=>{i.setParameters({color:e}),i.setParameters({outlineColor:t})}))}layerElevationInfoChanged(e,t,i){const r=this._elevationContext.mode,s=T(he.elevationModeChangeTypes,i,r);if(s!==O.UPDATE)return s;const a=E(r)||"absolute-height"===r;return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>a))}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial((e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!!this._getPrimitive()}applyRendererDiff(e,t){for(const i in e.diff){if("visualVariables"!==i)return G.Recreate_Symbol;if(!H(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return G.Recreate_Symbol;r(this._material)&&this._material.setParameters(this._fastUpdates.materialParameters)}return G.Fast_Update}_defaultElevationInfoNoZ(){return de}_createAs3DShape(e,t,i,r,s,o,n){const l=this.getFastUpdateAttrValues(e),c=l?e=>W(this._fastUpdates.materialParameters,l,e):void 0,h=this._context.layer.uid,m=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerUid:h}),u=X(i,se,null,r,s,_e,null,l,m),d=N(this._context,t,u,o,n,c);if(a(d))return null;const _=new D(this,d.object,[u],null,null,w,o);return _.alignedSampledElevation=d.sampledElevation,_.needsElevationUpdates=E(o.mode)||"absolute-height"===o.mode,_.getScreenSize=this._createScreenSizeGetter(s,c),_.calculateRelativeScreenBounds=e=>i.calculateRelativeScreenBounds(_.getScreenSize(),1,e),k(_,t,this._context.elevationProvider),_}_createAsOverlay(e,t,i,s,a,o){i.renderPriority=this._renderPriority;const n=v();z(t,n,this._context.overlaySR),n[2]=K;const l=this._context.clippingExtent;if(r(l)&&!P(l,n))return null;const c=this.getFastUpdateAttrValues(e),h=c?e=>W(this._fastUpdates.materialParameters,c,e):void 0,m=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:e.uid,layerUid:this._context.layer.uid}),u=X(i,se,n,s,a,null,null,c,m),d=new Y(u,{layerUid:o,graphicUid:e.uid,shaderTransformer:h});n[3]=0,S(d.boundingSphere,n);const _=new L(this,[d],null,this._context.drapeSourceRenderer);return _.getScreenSize=this._createScreenSizeGetter(a,h),_.calculateRelativeScreenBounds=e=>i.calculateRelativeScreenBounds(_.getScreenSize(),1,e),_}_createScreenSizeGetter(e,t){const i=this._outlineSize+2;if(this._fastUpdates.enabled){const r=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=f())=>{const a=t(re);return e[0]=a[0]*r+i,e[1]=a[5]*s+i,e}}{const t=e[0]/this._symbolTextureRatio+i,r=e[1]/this._symbolTextureRatio+i;return(e=f())=>(e[0]=t,e[1]=r,e)}}_fastVisualVariableConvertOptions(){const e=this._size[0]>this._size[1]?this._size[0]:this._size[1],t=x(e,e,e),i=u(1),r=e*i;return{modelSize:t,symbolSize:x(r,r,r),unitInMeters:i,transformation:{anchor:y,scale:g,rotation:y}}}_getGraphicHash(e){let t="";for(const i of this._cimRequiredFields)t+=i+e.attributes[i];return t}_forEachMaterial(e){r(this._material)&&e(this._material),this._cimSymbolMaterials.forEach(e)}test(){return{...super.test(),material:this._material}}}function me(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function ue(e){return!a(e)&&("cross"===e||"x"===e)}he.PRIMITIVE_SIZE=ce,he.elevationModeChangeTypes={definedChanged:O.UPDATE,staysOnTheGround:O.NONE,onTheGroundChanged:O.RECREATE};const de={mode:"relative-to-ground",offset:0},_e=b(0,0,0,1);export{he as Graphics3DIconSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import"../../../../symbols.js";import{result as t}from"../../../../core/asyncUtils.js";import i from"../../../../core/Error.js";import{isSome as r,get as s,isNone as a,unwrapOr as o,releaseMaybe as n,unwrap as l}from"../../../../core/maybe.js";import{throwIfAbortError as c,throwIfAborted as h}from"../../../../core/promiseUtils.js";import{pt2px as m,px2pt as u}from"../../../../core/screenUtils.js";import{dataComponents as d}from"../../../../core/urlUtils.js";import{c as _}from"../../../../chunks/mat4f64.js";import{f as p,a as f}from"../../../../chunks/vec2f64.js";import{Z as y,O as g,f as x}from"../../../../chunks/vec3f64.js";import{c as S}from"../../../../chunks/vec4.js";import{f as b,c as v}from"../../../../chunks/vec4f64.js";import{projectPointToVector as z}from"../../../../geometry/projection.js";import{containsPoint as P}from"../../../../geometry/support/aaBoundingBox.js";import{createRendererExpression as R}from"../../../../support/arcadeOnDemand.js";import{defaultPrimitive as C}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{getIconHref as M}from"../../../../symbols/support/utils.js";import j from"../../../2d/arcade/callExpressionWithFeature.js";import{TRANSPARENT_UNIT as I}from"./constants.js";import{perObjectElevationAligner as w}from"./ElevationAligners.js";import{SymbolUpdateType as O,elevationModeChangeUpdateType as T,needsElevationUpdates2D as E}from"./elevationAlignmentUtils.js";import{ElevationContext as U}from"./ElevationContext.js";import L from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as D}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as F}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as A}from"./graphicUtils.js";import{ApplyRendererDiffResult as G}from"./interfaces.js";import{namedAnchorToHUDMaterialAnchorPos as V}from"./placementUtils.js";import{placePointOnGeometry as B,createStageObject as N,extendPointGraphicElevationContext as k}from"./pointUtils.js";import{initFastSymbolUpdatesState as q,updateFastSymbolUpdatesState as H,evaluateModelTransform as W}from"../support/FastSymbolUpdates.js";import{createTexture as $,DEFAULT_SYMBOL_SIZE_RATIO as Z,DEFAULT_TEX_SIZE as J}from"../../support/engineContent/sdfPrimitives.js";import{DRAPED_Z as K}from"../../terrain/OverlayRenderer.js";import{PowerOfTwoResizeMode as Q}from"../../webgl-engine/lib/basicInterfaces.js";import{createPointGeometry as X}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as Y}from"../../webgl-engine/lib/RenderGeometry.js";import{Texture as ee}from"../../webgl-engine/lib/Texture.js";import{HUDMaterial as te}from"../../webgl-engine/materials/HUDMaterial.js";import ie from"../../../../symbols/CIMSymbol.js";const re=_(),se=x(0,0,1),ae=16,oe=1.5,ne=Z,le=[ne/2,ne/2,1-ne/2,1-ne/2],ce=[J*ne,J*ne];class he extends F{getCachedSize(){return{size:this._getIconSize()}}constructor(e,t,i,r){super(e,t,i,r),this._cimLayers=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimRequiredFields=null,this._cimScaleFactorOrFunction=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),i=this._getPrimitive();if(r(i))this._prepareResourcesPrimitive(t,i);else{const i=M(this.symbolLayer),r=d(i);r&&"application/json"===r.mediaType?await this._prepareResourcesCIM(t,JSON.parse(r.data),e):await this._prepareResourcesHref(t,i,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=A(this._getIconSize());if(e)throw new i("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?m(e.size):ae);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e){const t=this._getGraphicHash(e);let i=""===t?null:this._cimSymbolTextures.get(t);if(!i){const r={scaleFactor:this._cimScaleFactorOrFunction},s=this._context.sharedResources.cimSymbolRasterizer.rasterizeCIMSymbol3D(this._cimLayers,e,"esriGeometryPoint",r,void 0,void 0);this._cimMaterialParametersInfo.anchorPosition=this._getAnchorPos("relative",s.anchorPosition);const a={width:s.imageData.width,height:s.imageData.height,powerOfTwoResizeMode:Q.PAD};i=new ee(s.imageData,a),this._cimSymbolTextures.set(t,i),this._context.stage.add(i)}return i}_computeSize(e,t){const i=e.width/e.height;return i>1?[t,Math.round(t/i)]:[Math.round(t*i),t]}_prepareMaterialParameters(){const e={anchorPosition:this._getAnchorPos(this.symbolLayer.anchor,this.symbolLayer.anchorPosition)},t=this.symbol;if(me(t)){const{screenLength:i,minWorldLength:s,maxWorldLength:a}=t.verticalOffset;e.verticalOffset={screenLength:m(i),minWorldLength:s||0,maxWorldLength:r(a)?a:1/0}}return this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),e.occlusionTest=!0,e.hasSlicePlane=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const i=this._getOutlineSize();if(ue(t)&&0===i)throw new Error("Nothing to render");if(this._outlineSize=i,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,r(this._context.sharedResources.textures)){const i=this._context.sharedResources.textures.fromData(`${t}-icon`,(()=>$(t)));this._texture=i.texture,this._releaseTexture=i,e.textureId=this._texture.id}e.textureIsSignedDistanceField=!0,e.distanceFieldBoundingBox=le;const s=this._getIconSize();this._size=[s,s],this._symbolTextureRatio=1/ne,this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesHref(e,s,a){this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),n=o*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(r(this._context.sharedResources.textures)){const r=await t(this._context.sharedResources.textures.fromUrl(s,n,{signal:a}));if(!1===r.ok){c(r.error);throw new i("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${s})`)}this._releaseTexture=r.value;const l=r.value.texture,h=l.params;this._size=this._computeSize(h,o),e.textureId=l.id}this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesCIM(e,t,i){const r=new ie({data:t});if(!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;h(i),this._context.sharedResources.cimSymbolRasterizer||(this._context.sharedResources.cimSymbolRasterizer=new e(this._context.renderCoordsHelper.spatialReference,!0))}const s=this._context.layer.fields?this._context.layer.fields.map((e=>e.toJSON())):null;let a,o;if(this._cimLayers=await this._context.sharedResources.cimSymbolRasterizer.analyzeCIMSymbol(r,s,this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null,"esriGeometryPoint",{signal:i}),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(isNaN(e.scaleExpression)){const t=e.scaleExpression,i=await R(t,this._context.layer.spatialReference,s);o=(e,t,r)=>{const s=j(i,e,{$view:r},"esriGeometryPoint",t);return null!==s?s:1}}else a=Number(e.scaleExpression)}this._cimScaleFactorOrFunction=a||o||1;const n=this._context.renderer?await this._context.renderer.getRequiredFields(this._context.layer.fieldsIndex):[];h(i);const l=this._context.layer.fieldsIndex;this._cimRequiredFields=n.map((e=>l.get(e).name)),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return this.symbolLayer.resource&&this.symbolLayer.resource.href?null:this.symbolLayer.resource&&this.symbolLayer.resource.primitive||C}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(r(t.outline)&&null!=t.outline.size)return Math.max(m(t.outline.size),0);return e=ue(this._getPrimitive())?oe:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),i=this.symbolLayer,a=s(i,"outline","color");if(r(a)){const i=e.toUnitRGB(a),r=a.a*t;return[i[0],i[1],i[2],r]}return[0,0,0,0]}_getFillColor(){if(ue(this._getPrimitive()))return I;const e=a(this._getPrimitive()),t=s(this.symbolLayer,"material","color");return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}_getAnchorPos(e,t){return"relative"===e?p((t.x||0)+.5,.5-(t.y||0)):e in V?V[e]:V.center}_createMaterialAndAddToStage(e,t){if(this._cimLayers?this._fastUpdates={enabled:!1}:this._fastUpdates=q(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates.enabled&&Object.assign(e,this._fastUpdates.materialParameters),this._cimLayers){let i=r(e.textureId)?this._cimSymbolMaterials.get(e.textureId):null;return i||(i=new te(e),this._cimSymbolMaterials.set(o(e.textureId,0),i),t.add(i)),i}return this._material=new te(e),t.add(this._material),this._material}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial((e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,hasSlicePlane:!1,shaderPolygonOffset:0,isDraped:this.draped})})),this.layerOpacityChanged())}destroy(){super.destroy(),this._forEachMaterial((e=>this._context.stage.remove(e))),this._material=null,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach((e=>this._context.stage.remove(e))),this._cimSymbolTextures.clear(),this._releaseTexture=n(this._releaseTexture)}_getScaleFactor(e,t){if(this._drivenProperties.size&&e.size){for(let t=0;t<3;t++){const i=e.size[t];i&&"symbol-value"!==i&&"proportional"!==i&&(e.size[t]=m(i))}if("symbol-value"===e.size[0])return 1;if(isFinite(+e.size[0]))return+e.size[0]/t;if(isFinite(+e.size[2]))return+e.size[2]/t}return 1}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;let i,r=[0,0];if(this._cimLayers){if(!this._cimLayers.length)return null;const e=this._generateTextureCIM(t),s={textureId:e.id,...this._cimMaterialParametersInfo};i=this._createMaterialAndAddToStage(s,this._context.stage),r=[e.params.width,e.params.height]}else r=this._size,i=l(this._material);const s=B(t.geometry);if(a(s))return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const o=e.renderingInfo,n=this._getVertexOpacityAndColor(o);let c=1;if(!this._fastUpdates.enabled||!this._fastUpdates.visualVariables.size){const e=r[0]>r[1]?r[0]:r[1];c=this._getScaleFactor(o,e)}c*=this._symbolTextureRatio;const h=p(r[0]*c,r[1]*c),m=this.setGraphicElevationContext(t,new U);return this.ensureDrapedStatus("on-the-ground"===m.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,s,i,n,h,e.layer.uid):this._createAs3DShape(t,s,i,n,h,m,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial((i=>{i.setParameters({color:e}),i.setParameters({outlineColor:t})}))}layerElevationInfoChanged(e,t,i){const r=this._elevationContext.mode,s=T(he.elevationModeChangeTypes,i,r);if(s!==O.UPDATE)return s;const a=E(r)||"absolute-height"===r;return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>a))}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial((e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!!this._getPrimitive()}applyRendererDiff(e,t){for(const i in e.diff){if("visualVariables"!==i)return G.Recreate_Symbol;if(!H(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return G.Recreate_Symbol;r(this._material)&&this._material.setParameters(this._fastUpdates.materialParameters)}return G.Fast_Update}_defaultElevationInfoNoZ(){return de}_createAs3DShape(e,t,i,r,s,o,n){const l=this.getFastUpdateAttrValues(e),c=l?e=>W(this._fastUpdates.materialParameters,l,e):void 0,h=this._context.layer.uid,m=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerUid:h}),u=X(i,se,null,r,s,_e,null,l,m),d=N(this._context,t,u,o,n,c);if(a(d))return null;const _=new D(this,d.object,[u],null,null,w,o);return _.alignedSampledElevation=d.sampledElevation,_.needsElevationUpdates=E(o.mode)||"absolute-height"===o.mode,_.getScreenSize=this._createScreenSizeGetter(s,c),_.calculateRelativeScreenBounds=e=>i.calculateRelativeScreenBounds(_.getScreenSize(),1,e),k(_,t,this._context.elevationProvider),_}_createAsOverlay(e,t,i,s,a,o){i.renderPriority=this._renderPriority;const n=v();z(t,n,this._context.overlaySR),n[2]=K;const l=this._context.clippingExtent;if(r(l)&&!P(l,n))return null;const c=this.getFastUpdateAttrValues(e),h=c?e=>W(this._fastUpdates.materialParameters,c,e):void 0,m=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:e.uid,layerUid:this._context.layer.uid}),u=X(i,se,n,s,a,null,null,c,m),d=new Y(u,{layerUid:o,graphicUid:e.uid,shaderTransformer:h});n[3]=0,S(d.boundingSphere,n);const _=new L(this,[d],null,this._context.drapeSourceRenderer);return _.getScreenSize=this._createScreenSizeGetter(a,h),_.calculateRelativeScreenBounds=e=>i.calculateRelativeScreenBounds(_.getScreenSize(),1,e),_}_createScreenSizeGetter(e,t){const i=this._outlineSize+2;if(this._fastUpdates.enabled){const r=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=f())=>{const a=t(re);return e[0]=a[0]*r+i,e[1]=a[5]*s+i,e}}{const t=e[0]/this._symbolTextureRatio+i,r=e[1]/this._symbolTextureRatio+i;return(e=f())=>(e[0]=t,e[1]=r,e)}}_fastVisualVariableConvertOptions(){const e=this._size[0]>this._size[1]?this._size[0]:this._size[1],t=x(e,e,e),i=u(1),r=e*i;return{modelSize:t,symbolSize:x(r,r,r),unitInMeters:i,transformation:{anchor:y,scale:g,rotation:y}}}_getGraphicHash(e){let t="";for(const i of this._cimRequiredFields)t+=i+e.attributes[i];return t}_forEachMaterial(e){r(this._material)&&e(this._material),this._cimSymbolMaterials.forEach(e)}test(){return{...super.test(),material:this._material}}}function me(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function ue(e){return!a(e)&&("cross"===e||"x"===e)}he.PRIMITIVE_SIZE=ce,he.elevationModeChangeTypes={definedChanged:O.UPDATE,staysOnTheGround:O.NONE,onTheGroundChanged:O.RECREATE};const de={mode:"relative-to-ground",offset:0},_e=b(0,0,0,1);export{he as Graphics3DIconSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import"../../../../core/has.js";import{isSome as t,isNone as r,unwrapOr as o,get as a}from"../../../../core/maybe.js";import{f as n,t as s}from"../../../../chunks/mat3.js";import{c as i}from"../../../../chunks/mat3f64.js";import{f as l,m as c,a as u}from"../../../../chunks/mat4.js";import{c as m,b as h}from"../../../../chunks/mat4f64.js";import{a as f,g as p,e as g,n as d,b as x,f as _}from"../../../../chunks/vec3.js";import{Z as T,O as y,c as b}from"../../../../chunks/vec3f64.js";import{O as v}from"../../../../chunks/vec4f64.js";import{projectVectorToDehydratedPoint as C,projectBuffer as O,computeTranslationToOriginAndRotation as w,canProjectWithoutEngine as A}from"../../../../geometry/projection.js";import{create as M,empty as j,expandWithBuffer as E,intersectsClippingArea as R}from"../../../../geometry/support/aaBoundingBox.js";import N from"../../../../geometry/support/MeshComponent.js";import P from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import{BufferViewVec3f64 as I,BufferViewVec3f as B}from"../../../../geometry/support/buffer/BufferView.js";import{t as S,a as F}from"../../../../chunks/vec32.js";import{transformPosition as L,transformNormal as V,projectNormalToPCPF as U,transformTangent as G,projectTangentToPCPF as $}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as D}from"../../../../layers/graphics/dehydratedFeatures.js";import{ViewingMode as k}from"../../../ViewingMode.js";import{getTransformMatrix as q}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as H}from"./ElevationAligners.js";import{needsElevationUpdates3D as W,evaluateElevationInfoAtPoint as Y}from"./elevationAlignmentUtils.js";import{ElevationContext as z}from"./ElevationContext.js";import{Object3DEdgeState as Z,Graphics3DObject3DGraphicLayer as J}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as K}from"./Graphics3DSymbolLayer.js";import{createMaterial as Q}from"../support/edgeUtils.js";import{parseColorMixMode as X,encodeSymbolColor as ee}from"../support/symbolColorUtils.js";import te from"../../support/debugFlags.js";import{Attribute as re}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as oe,CullFaceOptions as ae}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as ne}from"../../webgl-engine/lib/ContentObjectType.js";import{newFloatArray as se}from"../../webgl-engine/lib/FloatArray.js";import{Geometry as ie}from"../../webgl-engine/lib/Geometry.js";import{generateDefaultIndexArray as le}from"../../webgl-engine/lib/Indices.js";import{Object3D as ce}from"../../webgl-engine/lib/Object3D.js";import{Texture as ue}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as me}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as he}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as fe}from"../../webgl-engine/materials/NativeLineMaterial.js";import{TextureWrapMode as pe}from"../../../webgl/enums.js";const ge=["mesh"];class de extends K{constructor(e,t,r,o){super(e,t,r,o),this._materials=new Map,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){te.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new fe({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new fe({color:[0,1,1,1]}))}destroy(){super.destroy(),this._context.stage.removeMany(Array.from(this._materials.values(),(e=>e.material))),this._context.stage.removeMany(Array.from(this._textures.values())),this._materials.clear(),this._textures.clear()}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,ge,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t,new z),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}layerOpacityChanged(e,r){const o=this._getLayerOpacity();this._materials.forEach((e=>{e.material.setParameters({layerOpacity:o});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>{const a=r(e);t(a)&&a.layerOpacityChanged(o,this._context.isAsync)}))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,W)}slicePlaneEnabledChanged(e,r){return this._materials.forEach((e=>{e.material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>{const o=r(e);t(o)&&o.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._materials.forEach((t=>t.material.setParameters({usePBR:e}))),!0}pixelRatioChanged(){return!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return r(t)?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:n,normalTexture:s,doubleSided:i,alphaCutoff:l,alphaMode:c}=t.material,u=this._colorOrTextureUid(a),m=this._colorOrTextureUid(n),h=this._colorOrTextureUid(s);if(o.color=a,o.colorTexture=n,o.normalTexture=s,o.uid=`${o.uid},cmuid:${u},ctmuid:${m},ntmuid:${h},ds:${i},ac:${l},am:${c}`,t.material instanceof P){const{metallic:e,roughness:r,metallicRoughnessTexture:a,emissiveColor:n,emissiveTexture:s,occlusionTexture:i}=t.material,l=this._colorOrTextureUid(a),c=this._colorOrTextureUid(n),u=this._colorOrTextureUid(s),m=this._colorOrTextureUid(i);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=n,o.emissiveTexture=s,o.occlusionTexture=i,o.colorTextureTransform=t.material.colorTextureTransform,o.normalTextureTransform=t.material.normalTextureTransform,o.emissiveTextureTransform=t.material.emissiveTextureTransform,o.occlusionTextureTransform=t.material.occlusionTextureTransform,o.metallicRoughnessTextureTransform=t.material.metallicRoughnessTextureTransform,o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${l},emuid:${c},etmuid:${u},otmuid:${m}`}return o}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data?e.data:e.url}_getInternalTextureId(e){const r=this._getInternalTexture(e,oe.Opaque);return t(r)?r.id:null}_getInternalTexture(e,t){const r=this._getLoadableTextureResource(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let a=this._textures.get(o);return a||(a=new ue(r,{mipmap:!0,wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,preMultiplyAlpha:t!==oe.Opaque}),this._textures.set(o,a),this._context.stage.add(a),this._context.stage.loadImmediate(a)),a}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return pe.CLAMP_TO_EDGE;case"mirror":return pe.MIRRORED_REPEAT;default:return pe.REPEAT}}_setInternalMaterialParameters(r,o){if(t(r.color)&&this._setInternalColorValueParameters(r.color,o),t(r.colorTexture)){const e=this._getInternalTexture(r.colorTexture,o.textureAlphaMode);t(e)?(o.textureId=e.id,o.textureAlphaPremultiplied=!!e.params.preMultiplyAlpha):o.textureId=void 0}t(r.normalTexture)&&(o.normalTextureId=this._getInternalTextureId(r.normalTexture)),t(r.emissiveColor)&&(o.emissiveFactor=e.toUnitRGB(r.emissiveColor)),t(r.emissiveTexture)&&(o.emissiveTextureId=this._getInternalTextureId(r.emissiveTexture)),t(r.occlusionTexture)&&(o.occlusionTextureId=this._getInternalTextureId(r.occlusionTexture)),t(r.metallicRoughnessTexture)&&(o.metallicRoughnessTextureId=this._getInternalTextureId(r.metallicRoughnessTexture)),o.colorTextureTransformMatrix=q(r.colorTextureTransform),o.normalTextureTransformMatrix=q(r.normalTextureTransform),o.occlusionTextureTransformMatrix=q(r.occlusionTextureTransform),o.emissiveTextureTransformMatrix=q(r.emissiveTextureTransform),o.metallicRoughnessTextureTransformMatrix=q(r.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(r){const o=this._drivenProperties.color;let a=t(this.symbolLayer.material)?this.symbolLayer.material.colorMixMode:null;if(o)r.externalColor=v;else{const o=t(this.symbolLayer.material)?this.symbolLayer.material.color:null;t(o)?r.externalColor=e.toUnitRGBA(o):(a=null,r.externalColor=v)}a&&(r.colorMixMode=a),r.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(r(t))return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(e,r){const o=r.material?.color,a=r.material?.colorTexture,n=r.material?.alphaMode,s="blend"===n,i=!("opaque"===n)&&(this._hasTransparentVertexColors(e)||t(o)&&o.a<1||t(a)&&a.transparent||s),l=this._materialProperties(e,r,i),c=this._materials.get(l.uid);if(c)return c.material;const u={material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=null==l.metallicRoughnessTexture&&null==l.metallic&&null==l.roughness,h={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:T,diffuse:y,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:ae.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};m||(h.mrrFactors=[null!=l.metallic?l.metallic:1,null!=l.roughness?l.roughness:1,.5]),r.material&&(h.doubleSided=r.material.doubleSided,h.cullFace=r.material.doubleSided?ae.None:ae.Back,h.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(h),this._setMaterialTransparentParameter(h,u),this._setInternalMaterialParameters(l,h);const f=new he(h);return u.material=f,this._materials.set(l.uid,u),this._context.stage.add(f),f}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?oe.MaskBlend:oe.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?oe.Opaque:"mask"===t.alphaMode?oe.Mask:oe.Blend}_addDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,a=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),n=[],s=[],i=[],l=[];for(let h=0;h<r;h++){const e=t[h],r=e.vertexAttributes.get(me.POSITION),o=e.vertexAttributes.get(me.NORMAL),c=e.indices.get(me.POSITION),u=e.indices.get(me.NORMAL),m=r.data,g=o.data;for(let t=0;t<c.length;t++){const e=3*c[t],r=3*u[t];for(let t=0;t<3;t++)n.push(m[e+t]);for(let t=0;t<3;t++)n.push(m[e+t]+g[r+t]*a);if(s.push(s.length),s.push(s.length),t%3==0){this._calculateFaceNormal(m,c,t,ve),this._getFaceVertices(m,c,t,Te,ye,be),f(Te,Te,ye),f(Te,Te,be),p(Te,Te,1/3);for(let e=0;e<3;e++)i.push(Te[e]);for(let e=0;e<3;e++)i.push(Te[e]+ve[e]*a);l.push(l.length),l.push(l.length)}}}const c=t[0].transformation,u=new ie(this._debugVertexNormalMaterial,[[me.POSITION,new re(n,3,!0)]],[[me.POSITION,s]],null,ne.Line);t.push(u),u.transformation=c;const m=new ie(this._debugFaceNormalMaterial,[[me.POSITION,new re(i,3,!0)]],[[me.POSITION,l]],null,ne.Line);m.transformation=c,t.push(m)}_createAs3DShape(e,o,a,n){const s=e.geometry;if("mesh"!==s.type)return null;const i=this._createGeometryInfo(s,o,n);if(r(i))return null;const{geometries:l,objectTransformation:c}=i;te.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(s,l);const u=new ce({geometries:l,metadata:{layerUid:this._context.layer.uid,graphicUid:n}});u.transformation=c;const m=Q(this.symbolLayer,{opacity:this._getLayerOpacity()}),h=t(m)?new Z(l[0].material,[m],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,f=new J(this,u,l,null,null,H,a,h);f.needsElevationUpdates=W(a.mode),f.useObjectOriginAsAttachmentOrigin=!0,a.centerPointInElevationSR=this._getCenterPointInElevationSR(u);const{elevationProvider:p,renderCoordsHelper:g}=this._context,d=(e,t)=>Y(e,p,a,g,t);return f.alignedSampledElevation=H(f,a,p.spatialReference,d,g),f}_getCenterPointInElevationSR(e){const r=D(0,0,0,t(this._context.elevationProvider.spatialReference)?this._context.elevationProvider.spatialReference:null);return C([e.transformation[12],e.transformation[13],e.transformation[14]],this._context.renderCoordsHelper.spatialReference,r),r}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){default:case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o)}}_createComponentNormalsSource(e,t,o,a){if(r(t))return this._createComponentNormalsFlat(e,a);let n=!1;if(!o.trustSourceNormals)for(let r=0;r<a.length;r+=3){this._calculateFaceNormal(e,a,r,ve);for(let e=0;e<3;e++){const o=3*a[r+e];Te[0]=t[o+0],Te[1]=t[o+1],Te[2]=t[o+2],g(ve,Te)<0&&(t[o+0]=-t[o+0],t[o+1]=-t[o+1],t[o+2]=-t[o+2],n=!0)}}return new xe(t,a,n)}_createComponentNormalsFlat(e,t){const r=se(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const n=this._calculateFaceNormal(e,t,a,ve);for(let e=0;e<3;e++)r[a+e]=n[e],o[a+e]=a/3}return new xe(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let n=0;n<t.length;n+=3){const o=this._calculateFaceNormal(e,t,n,ve);for(let e=0;e<3;e++){const a=t[n+e];let s=r[a];s||(s={normal:b(),count:0},r[a]=s),f(s.normal,s.normal,o),s.count++}}const o=se(3*t.length),a=new Array(3*t.length);for(let n=0;n<t.length;n++){const e=r[t[n]];1!==e.count&&(d(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*n+t]=e.normal[t];a[n]=n}return new xe(o,a,!1)}_getFaceVertices(e,t,r,o,a,n){const s=3*t[r+0],i=3*t[r+1],l=3*t[r+2];o[0]=e[s+0],o[1]=e[s+1],o[2]=e[s+2],a[0]=e[i+0],a[1]=e[i+1],a[2]=e[i+2],n[0]=e[l+0],n[1]=e[l+1],n[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,Te,ye,be),x(ye,ye,Te),x(be,be,Te),_(Te,ye,be),d(o,Te),o}_getOrCreateComponents(e){return o(e.components,Ae)}_createPositionBuffer(e,r){let o=e.vertexAttributes.position;const a=r.reprojection===Me.ECEF?r.transformBeforeProject:null;if(t(a)&&(o=L(o,new Float64Array(o.length),a)),r.reprojection===Me.NONE)return r.needsBufferCopy?new Float64Array(o):o;const n=t(a)?o:new Float64Array(o.length);return O(o,e.spatialReference,0,n,this._context.renderCoordsHelper.spatialReference,0,o.length/3),n}_createNormalBuffer(e,o,a){let n=e.vertexAttributes.normal;if(r(n))return null;const s=a.reprojection===Me.ECEF?a.transformBeforeProject:null;t(s)&&(n=V(n,new Float32Array(n.length),s));if("local"===this._context.graphicsCoreOwner.view.viewingMode||a.reprojection===Me.NONE)return a.needsBufferCopy&&e.vertexAttributes.normal===n?new Float32Array(n):n;const i=e.vertexAttributes.position,l=t(s)?n:new Float32Array(n.length);return U(n,i,o,e.spatialReference,l)}_createTangentBuffer(e,o,a){let n=e.vertexAttributes.tangent;if(r(n))return null;const s=a.reprojection===Me.ECEF?a.transformBeforeProject:null;t(s)&&(n=G(n,new Float32Array(n.length),s));if("local"===this._context.graphicsCoreOwner.view.viewingMode||a.reprojection===Me.NONE)return a.needsBufferCopy&&e.vertexAttributes.normal===n?new Float32Array(n):n;const i=e.vertexAttributes.position,l=t(s)?n:new Float32Array(n.length);return $(n,i,o,e.spatialReference,l)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=X(a(this.symbolLayer,"material","colorMixMode")),o=new Uint8Array(4);return ee(t,r,o),o}return null}_createBuffers(e,r){const o=e.vertexAttributes&&e.vertexAttributes.position;if(!o)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const a=e.vertexAttributes.normal,n=e.vertexAttributes.uv,s=e.vertexAttributes.tangent;if(t(a)&&a.length!==o.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(t(s)&&s.length/4!=o.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(t(n)&&n.length/2!=o.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const i=this._computeReprojectionInfo(e),l=this._createPositionBuffer(e,i),c=this._createColorBuffer(e),u=this._createSymbolColorBuffer(r),h=this._createNormalBuffer(e,l,i),f=this._createTangentBuffer(e,l,i);return{positionBuffer:l,normalBuffer:h,tangentBuffer:f,uvBuffer:n,colorBuffer:c,symbolColorBuffer:u,objectTransformation:i.reprojection===Me.NONE&&t(i.objectTransformation)?i.objectTransformation:this._transformOriginLocal(e,l,h,f),geometryTransformation:i.reprojection===Me.NONE&&t(i.geometryTransformation)?i.geometryTransformation:m()}}_computeReprojectionInfo(e){const r=t(e.transform),o=r&&e.transform.geographic||this._context.renderCoordsHelper.viewingMode===k.Local?Me.NONE:Me.ECEF;if(r){if(o===Me.NONE){const t=m();w(e.spatialReference,e.transform.origin,t,this._context.renderCoordsHelper.spatialReference);return{reprojection:o,objectTransformation:t,geometryTransformation:h(e.transform.localMatrix),needsBufferCopy:!1}}const t=l(m(),e.transform.origin);return c(t,t,e.transform.localMatrix),{reprojection:o,transformBeforeProject:t,needsBufferCopy:!0}}return{reprojection:o,needsBufferCopy:!0}}_transformOriginLocal(e,r,o,a){const i=this._context.renderCoordsHelper.spatialReference,l=e.anchor;_e[0]=l.x,_e[1]=l.y,_e[2]=l.z;const c=m();w(e.spatialReference,_e,c,i);const h=I.fromTypedArray(r);if(u(Ce,c),S(h,h,Ce),t(o)||t(a)){if(n(Oe,c),s(Oe,Oe),t(o)){const e=B.fromTypedArray(o);F(e,e,Oe)}if(t(a)){const e=B.fromTypedArray(a,4*a.BYTES_PER_ELEMENT);F(e,e,Oe)}}return c}_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}_getOrCreateFaces(e,t){return t.faces?t.faces:le(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return!1;const o=this._context.elevationProvider.spatialReference;let a;const n=r.length/3;return t(o)&&!e.spatialReference.equals(o)?(a=new Float64Array(r.length),O(e.vertexAttributes.position,e.spatialReference,0,a,o,0,n)):a=r,j(we),E(we,a,0,n),!R(we,this._context.clippingExtent)}_createGeometryInfo(e,o,a){if(!A(e.spatialReference,this._context.graphicsCoreOwner.view.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const n=this._createBuffers(e,o);if(r(n))return null;const{positionBuffer:s,uvBuffer:i,colorBuffer:l,symbolColorBuffer:c,normalBuffer:u,tangentBuffer:m,objectTransformation:h,geometryTransformation:f}=n,p=this._getOrCreateComponents(e),g=new Array;let d=!1;for(const r of p){if(!this._validateFaces(e,r))return null;const o=this._getOrCreateFaces(e,r);if(0===o.length)continue;const n=this._createComponentNormals(s,u,r,o);n.didFlipNormals&&(d=!0);const h=[[me.POSITION,new re(s,3,!0)],[me.NORMAL,new re(n.normals,3,!0)]],p=[[me.POSITION,o],[me.NORMAL,n.indices]];t(l)&&(h.push([me.COLOR,new re(l,4,!0)]),p.push([me.COLOR,o])),t(c)&&(h.push([me.SYMBOLCOLOR,new re(c,4,!0)]),p.push([me.SYMBOLCOLOR,new Array(o.length).fill(0)])),t(i)&&(h.push([me.UV0,new re(i,2,!0)]),p.push([me.UV0,o])),t(m)&&(h.push([me.TANGENT,new re(m,4,!0)]),p.push([me.TANGENT,o]));const x=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:a,layerUid:this._context.layer.uid}),_=this._getOrCreateMaterial(e,r),T=new ie(_,h,p,null,ne.Mesh,x);T.transformation=f,g.push(T)}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:g,objectTransformation:h}}}class xe{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const _e=b(),Te=b(),ye=b(),be=b(),ve=b(),Ce=m(),Oe=i(),we=M(),Ae=[new N];var Me;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(Me||(Me={}));export{de as Graphics3DMeshFillSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import"../../../../core/has.js";import{isSome as t,isNone as r,unwrapOr as o,get as a}from"../../../../core/maybe.js";import{f as n,t as s}from"../../../../chunks/mat3.js";import{c as i}from"../../../../chunks/mat3f64.js";import{f as l,m as c,a as u}from"../../../../chunks/mat4.js";import{c as m,b as h}from"../../../../chunks/mat4f64.js";import{a as f,g as p,e as g,n as d,b as x,f as _}from"../../../../chunks/vec3.js";import{Z as T,O as y,c as b}from"../../../../chunks/vec3f64.js";import{O as v}from"../../../../chunks/vec4f64.js";import{projectVectorToDehydratedPoint as C,projectBuffer as O,computeTranslationToOriginAndRotation as w,canProjectWithoutEngine as A}from"../../../../geometry/projection.js";import{create as M,empty as j,expandWithBuffer as E,intersectsClippingArea as R}from"../../../../geometry/support/aaBoundingBox.js";import N from"../../../../geometry/support/MeshComponent.js";import P from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import{BufferViewVec3f64 as I,BufferViewVec3f as B}from"../../../../geometry/support/buffer/BufferView.js";import{t as S,a as F}from"../../../../chunks/vec32.js";import{transformPosition as L,transformNormal as V,projectNormalToPCPF as U,transformTangent as G,projectTangentToPCPF as $}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as D}from"../../../../layers/graphics/dehydratedFeatures.js";import{ViewingMode as k}from"../../../ViewingMode.js";import{isEncodedMeshTexture as q}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as H}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as W}from"./ElevationAligners.js";import{needsElevationUpdates3D as Y,evaluateElevationInfoAtPoint as z}from"./elevationAlignmentUtils.js";import{ElevationContext as Z}from"./ElevationContext.js";import{Object3DEdgeState as J,Graphics3DObject3DGraphicLayer as K}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as Q}from"./Graphics3DSymbolLayer.js";import{createMaterial as X}from"../support/edgeUtils.js";import{parseColorMixMode as ee,encodeSymbolColor as te}from"../support/symbolColorUtils.js";import re from"../../support/debugFlags.js";import{Attribute as oe}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as ae,CullFaceOptions as ne}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as se}from"../../webgl-engine/lib/ContentObjectType.js";import{newFloatArray as ie}from"../../webgl-engine/lib/FloatArray.js";import{Geometry as le}from"../../webgl-engine/lib/Geometry.js";import{generateDefaultIndexArray as ce}from"../../webgl-engine/lib/Indices.js";import{Object3D as ue}from"../../webgl-engine/lib/Object3D.js";import{Texture as me}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as he}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as fe}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as pe}from"../../webgl-engine/materials/NativeLineMaterial.js";import{TextureWrapMode as ge}from"../../../webgl/enums.js";const de=["mesh"];class xe extends Q{constructor(e,t,r,o){super(e,t,r,o),this._materials=new Map,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){re.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new pe({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new pe({color:[0,1,1,1]}))}destroy(){super.destroy(),this._context.stage.removeMany(Array.from(this._materials.values(),(e=>e.material))),this._context.stage.removeMany(Array.from(this._textures.values())),this._materials.clear(),this._textures.clear()}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,de,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t,new Z),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}layerOpacityChanged(e,r){const o=this._getLayerOpacity();this._materials.forEach((e=>{e.material.setParameters({layerOpacity:o});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>{const a=r(e);t(a)&&a.layerOpacityChanged(o,this._context.isAsync)}))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,Y)}slicePlaneEnabledChanged(e,r){return this._materials.forEach((e=>{e.material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>{const o=r(e);t(o)&&o.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._materials.forEach((t=>t.material.setParameters({usePBR:e}))),!0}pixelRatioChanged(){return!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return r(t)?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:n,normalTexture:s,doubleSided:i,alphaCutoff:l,alphaMode:c}=t.material,u=this._colorOrTextureUid(a),m=this._colorOrTextureUid(n),h=this._colorOrTextureUid(s);if(o.color=a,o.colorTexture=n,o.normalTexture=s,o.uid=`${o.uid},cmuid:${u},ctmuid:${m},ntmuid:${h},ds:${i},ac:${l},am:${c}`,t.material instanceof P){const{metallic:e,roughness:r,metallicRoughnessTexture:a,emissiveColor:n,emissiveTexture:s,occlusionTexture:i}=t.material,l=this._colorOrTextureUid(a),c=this._colorOrTextureUid(n),u=this._colorOrTextureUid(s),m=this._colorOrTextureUid(i);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=n,o.emissiveTexture=s,o.occlusionTexture=i,o.colorTextureTransform=t.material.colorTextureTransform,o.normalTextureTransform=t.material.normalTextureTransform,o.emissiveTextureTransform=t.material.emissiveTextureTransform,o.occlusionTextureTransform=t.material.occlusionTextureTransform,o.metallicRoughnessTextureTransform=t.material.metallicRoughnessTextureTransform,o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${l},emuid:${c},etmuid:${u},otmuid:${m}`}return o}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data?e.data:e.url}_getInternalTextureId(e){const r=this._getInternalTexture(e,ae.Opaque);return t(r)?r.id:null}_getInternalTexture(e,r){const o=this._getLoadableTextureResource(e);if(!o)return null;const a=`${e.contentHash}/${r}`;let n=this._textures.get(a);return n||(n=new me(q(o)?o.data:o,{mipmap:!0,wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,preMultiplyAlpha:!q(o)&&r!==ae.Opaque,encoding:q(o)&&t(o.encoding)?o.encoding:void 0}),this._textures.set(a,n),this._context.stage.add(n),this._context.stage.loadImmediate(n)),n}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return ge.CLAMP_TO_EDGE;case"mirror":return ge.MIRRORED_REPEAT;default:return ge.REPEAT}}_setInternalMaterialParameters(r,o){if(t(r.color)&&this._setInternalColorValueParameters(r.color,o),t(r.colorTexture)){const e=this._getInternalTexture(r.colorTexture,o.textureAlphaMode);t(e)?(o.textureId=e.id,o.textureAlphaPremultiplied=!!e.params.preMultiplyAlpha):o.textureId=void 0}t(r.normalTexture)&&(o.normalTextureId=this._getInternalTextureId(r.normalTexture)),t(r.emissiveColor)&&(o.emissiveFactor=e.toUnitRGB(r.emissiveColor)),t(r.emissiveTexture)&&(o.emissiveTextureId=this._getInternalTextureId(r.emissiveTexture)),t(r.occlusionTexture)&&(o.occlusionTextureId=this._getInternalTextureId(r.occlusionTexture)),t(r.metallicRoughnessTexture)&&(o.metallicRoughnessTextureId=this._getInternalTextureId(r.metallicRoughnessTexture)),o.colorTextureTransformMatrix=H(r.colorTextureTransform),o.normalTextureTransformMatrix=H(r.normalTextureTransform),o.occlusionTextureTransformMatrix=H(r.occlusionTextureTransform),o.emissiveTextureTransformMatrix=H(r.emissiveTextureTransform),o.metallicRoughnessTextureTransformMatrix=H(r.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(r){const o=this._drivenProperties.color;let a=t(this.symbolLayer.material)?this.symbolLayer.material.colorMixMode:null;if(o)r.externalColor=v;else{const o=t(this.symbolLayer.material)?this.symbolLayer.material.color:null;t(o)?r.externalColor=e.toUnitRGBA(o):(a=null,r.externalColor=v)}a&&(r.colorMixMode=a),r.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(r(t))return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(e,r){const o=r.material?.color,a=r.material?.colorTexture,n=r.material?.alphaMode,s="blend"===n,i=!("opaque"===n)&&(this._hasTransparentVertexColors(e)||t(o)&&o.a<1||t(a)&&a.transparent||s),l=this._materialProperties(e,r,i),c=this._materials.get(l.uid);if(c)return c.material;const u={material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=null==l.metallicRoughnessTexture&&null==l.metallic&&null==l.roughness,h={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:T,diffuse:y,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:ne.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};m||(h.mrrFactors=[null!=l.metallic?l.metallic:1,null!=l.roughness?l.roughness:1,.5]),r.material&&(h.doubleSided=r.material.doubleSided,h.cullFace=r.material.doubleSided?ne.None:ne.Back,h.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(h),this._setMaterialTransparentParameter(h,u),this._setInternalMaterialParameters(l,h);const f=new fe(h);return u.material=f,this._materials.set(l.uid,u),this._context.stage.add(f),f}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?ae.MaskBlend:ae.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?ae.Opaque:"mask"===t.alphaMode?ae.Mask:ae.Blend}_addDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,a=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),n=[],s=[],i=[],l=[];for(let h=0;h<r;h++){const e=t[h],r=e.vertexAttributes.get(he.POSITION),o=e.vertexAttributes.get(he.NORMAL),c=e.indices.get(he.POSITION),u=e.indices.get(he.NORMAL),m=r.data,g=o.data;for(let t=0;t<c.length;t++){const e=3*c[t],r=3*u[t];for(let t=0;t<3;t++)n.push(m[e+t]);for(let t=0;t<3;t++)n.push(m[e+t]+g[r+t]*a);if(s.push(s.length),s.push(s.length),t%3==0){this._calculateFaceNormal(m,c,t,Ce),this._getFaceVertices(m,c,t,ye,be,ve),f(ye,ye,be),f(ye,ye,ve),p(ye,ye,1/3);for(let e=0;e<3;e++)i.push(ye[e]);for(let e=0;e<3;e++)i.push(ye[e]+Ce[e]*a);l.push(l.length),l.push(l.length)}}}const c=t[0].transformation,u=new le(this._debugVertexNormalMaterial,[[he.POSITION,new oe(n,3,!0)]],[[he.POSITION,s]],null,se.Line);t.push(u),u.transformation=c;const m=new le(this._debugFaceNormalMaterial,[[he.POSITION,new oe(i,3,!0)]],[[he.POSITION,l]],null,se.Line);m.transformation=c,t.push(m)}_createAs3DShape(e,o,a,n){const s=e.geometry;if("mesh"!==s.type)return null;const i=this._createGeometryInfo(s,o,n);if(r(i))return null;const{geometries:l,objectTransformation:c}=i;re.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(s,l);const u=new ue({geometries:l,metadata:{layerUid:this._context.layer.uid,graphicUid:n}});u.transformation=c;const m=X(this.symbolLayer,{opacity:this._getLayerOpacity()}),h=t(m)?new J(l[0].material,[m],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,f=new K(this,u,l,null,null,W,a,h);f.needsElevationUpdates=Y(a.mode),f.useObjectOriginAsAttachmentOrigin=!0,a.centerPointInElevationSR=this._getCenterPointInElevationSR(u);const{elevationProvider:p,renderCoordsHelper:g}=this._context,d=(e,t)=>z(e,p,a,g,t);return f.alignedSampledElevation=W(f,a,p.spatialReference,d,g),f}_getCenterPointInElevationSR(e){const r=D(0,0,0,t(this._context.elevationProvider.spatialReference)?this._context.elevationProvider.spatialReference:null);return C([e.transformation[12],e.transformation[13],e.transformation[14]],this._context.renderCoordsHelper.spatialReference,r),r}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){default:case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o)}}_createComponentNormalsSource(e,t,o,a){if(r(t))return this._createComponentNormalsFlat(e,a);let n=!1;if(!o.trustSourceNormals)for(let r=0;r<a.length;r+=3){this._calculateFaceNormal(e,a,r,Ce);for(let e=0;e<3;e++){const o=3*a[r+e];ye[0]=t[o+0],ye[1]=t[o+1],ye[2]=t[o+2],g(Ce,ye)<0&&(t[o+0]=-t[o+0],t[o+1]=-t[o+1],t[o+2]=-t[o+2],n=!0)}}return new _e(t,a,n)}_createComponentNormalsFlat(e,t){const r=ie(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const n=this._calculateFaceNormal(e,t,a,Ce);for(let e=0;e<3;e++)r[a+e]=n[e],o[a+e]=a/3}return new _e(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let n=0;n<t.length;n+=3){const o=this._calculateFaceNormal(e,t,n,Ce);for(let e=0;e<3;e++){const a=t[n+e];let s=r[a];s||(s={normal:b(),count:0},r[a]=s),f(s.normal,s.normal,o),s.count++}}const o=ie(3*t.length),a=new Array(3*t.length);for(let n=0;n<t.length;n++){const e=r[t[n]];1!==e.count&&(d(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*n+t]=e.normal[t];a[n]=n}return new _e(o,a,!1)}_getFaceVertices(e,t,r,o,a,n){const s=3*t[r+0],i=3*t[r+1],l=3*t[r+2];o[0]=e[s+0],o[1]=e[s+1],o[2]=e[s+2],a[0]=e[i+0],a[1]=e[i+1],a[2]=e[i+2],n[0]=e[l+0],n[1]=e[l+1],n[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,ye,be,ve),x(be,be,ye),x(ve,ve,ye),_(ye,be,ve),d(o,ye),o}_getOrCreateComponents(e){return o(e.components,Me)}_createPositionBuffer(e,r){let o=e.vertexAttributes.position;const a=r.reprojection===je.ECEF?r.transformBeforeProject:null;if(t(a)&&(o=L(o,new Float64Array(o.length),a)),r.reprojection===je.NONE)return r.needsBufferCopy?new Float64Array(o):o;const n=t(a)?o:new Float64Array(o.length);return O(o,e.spatialReference,0,n,this._context.renderCoordsHelper.spatialReference,0,o.length/3),n}_createNormalBuffer(e,o,a){let n=e.vertexAttributes.normal;if(r(n))return null;const s=a.reprojection===je.ECEF?a.transformBeforeProject:null;t(s)&&(n=V(n,new Float32Array(n.length),s));if("local"===this._context.graphicsCoreOwner.view.viewingMode||a.reprojection===je.NONE)return a.needsBufferCopy&&e.vertexAttributes.normal===n?new Float32Array(n):n;const i=e.vertexAttributes.position,l=t(s)?n:new Float32Array(n.length);return U(n,i,o,e.spatialReference,l)}_createTangentBuffer(e,o,a){let n=e.vertexAttributes.tangent;if(r(n))return null;const s=a.reprojection===je.ECEF?a.transformBeforeProject:null;t(s)&&(n=G(n,new Float32Array(n.length),s));if("local"===this._context.graphicsCoreOwner.view.viewingMode||a.reprojection===je.NONE)return a.needsBufferCopy&&e.vertexAttributes.normal===n?new Float32Array(n):n;const i=e.vertexAttributes.position,l=t(s)?n:new Float32Array(n.length);return $(n,i,o,e.spatialReference,l)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=ee(a(this.symbolLayer,"material","colorMixMode")),o=new Uint8Array(4);return te(t,r,o),o}return null}_createBuffers(e,r){const o=e.vertexAttributes&&e.vertexAttributes.position;if(!o)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const a=e.vertexAttributes.normal,n=e.vertexAttributes.uv,s=e.vertexAttributes.tangent;if(t(a)&&a.length!==o.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(t(s)&&s.length/4!=o.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(t(n)&&n.length/2!=o.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const i=this._computeReprojectionInfo(e),l=this._createPositionBuffer(e,i),c=this._createColorBuffer(e),u=this._createSymbolColorBuffer(r),h=this._createNormalBuffer(e,l,i),f=this._createTangentBuffer(e,l,i);return{positionBuffer:l,normalBuffer:h,tangentBuffer:f,uvBuffer:n,colorBuffer:c,symbolColorBuffer:u,objectTransformation:i.reprojection===je.NONE&&t(i.objectTransformation)?i.objectTransformation:this._transformOriginLocal(e,l,h,f),geometryTransformation:i.reprojection===je.NONE&&t(i.geometryTransformation)?i.geometryTransformation:m()}}_computeReprojectionInfo(e){const r=t(e.transform),o=r&&e.transform.geographic||this._context.renderCoordsHelper.viewingMode===k.Local?je.NONE:je.ECEF;if(r){if(o===je.NONE){const t=m();w(e.spatialReference,e.transform.origin,t,this._context.renderCoordsHelper.spatialReference);return{reprojection:o,objectTransformation:t,geometryTransformation:h(e.transform.localMatrix),needsBufferCopy:!1}}const t=l(m(),e.transform.origin);return c(t,t,e.transform.localMatrix),{reprojection:o,transformBeforeProject:t,needsBufferCopy:!0}}return{reprojection:o,needsBufferCopy:!0}}_transformOriginLocal(e,r,o,a){const i=this._context.renderCoordsHelper.spatialReference,l=e.anchor;Te[0]=l.x,Te[1]=l.y,Te[2]=l.z;const c=m();w(e.spatialReference,Te,c,i);const h=I.fromTypedArray(r);if(u(Oe,c),S(h,h,Oe),t(o)||t(a)){if(n(we,c),s(we,we),t(o)){const e=B.fromTypedArray(o);F(e,e,we)}if(t(a)){const e=B.fromTypedArray(a,4*a.BYTES_PER_ELEMENT);F(e,e,we)}}return c}_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}_getOrCreateFaces(e,t){return t.faces?t.faces:ce(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return!1;const o=this._context.elevationProvider.spatialReference;let a;const n=r.length/3;return t(o)&&!e.spatialReference.equals(o)?(a=new Float64Array(r.length),O(e.vertexAttributes.position,e.spatialReference,0,a,o,0,n)):a=r,j(Ae),E(Ae,a,0,n),!R(Ae,this._context.clippingExtent)}_createGeometryInfo(e,o,a){if(!A(e.spatialReference,this._context.graphicsCoreOwner.view.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const n=this._createBuffers(e,o);if(r(n))return null;const{positionBuffer:s,uvBuffer:i,colorBuffer:l,symbolColorBuffer:c,normalBuffer:u,tangentBuffer:m,objectTransformation:h,geometryTransformation:f}=n,p=this._getOrCreateComponents(e),g=new Array;let d=!1;for(const r of p){if(!this._validateFaces(e,r))return null;const o=this._getOrCreateFaces(e,r);if(0===o.length)continue;const n=this._createComponentNormals(s,u,r,o);n.didFlipNormals&&(d=!0);const h=[[he.POSITION,new oe(s,3,!0)],[he.NORMAL,new oe(n.normals,3,!0)]],p=[[he.POSITION,o],[he.NORMAL,n.indices]];t(l)&&(h.push([he.COLOR,new oe(l,4,!0)]),p.push([he.COLOR,o])),t(c)&&(h.push([he.SYMBOLCOLOR,new oe(c,4,!0)]),p.push([he.SYMBOLCOLOR,new Array(o.length).fill(0)])),t(i)&&(h.push([he.UV0,new oe(i,2,!0)]),p.push([he.UV0,o])),t(m)&&(h.push([he.TANGENT,new oe(m,4,!0)]),p.push([he.TANGENT,o]));const x=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:a,layerUid:this._context.layer.uid}),_=this._getOrCreateMaterial(e,r),T=new le(_,h,p,null,se.Mesh,x);T.transformation=f,g.push(T)}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:g,objectTransformation:h}}}class _e{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const Te=b(),ye=b(),be=b(),ve=b(),Ce=b(),Oe=m(),we=i(),Ae=M(),Me=[new N];var je;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(je||(je={}));export{xe as Graphics3DMeshFillSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../core/Error.js";import{isNone as t,isSome as r,get as s,unwrap as n}from"../../../../core/maybe.js";import{isPromiseLike as i}from"../../../../core/promiseUtils.js";import{pt2px as o}from"../../../../core/screenUtils.js";import{f as a,Z as l,a as c}from"../../../../chunks/vec2f64.js";import{hasCalloutSupport as m,textSymbolLayerSupportsVerticalOffset as h}from"../../../../symbols/callouts/calloutUtils.js";import{CreateLabelParameters as
|
|
5
|
+
import e from"../../../../core/Error.js";import{isNone as t,isSome as r,get as s,unwrap as n}from"../../../../core/maybe.js";import{isPromiseLike as i}from"../../../../core/promiseUtils.js";import{pt2px as o}from"../../../../core/screenUtils.js";import{f as a,Z as l,a as c}from"../../../../chunks/vec2f64.js";import{hasCalloutSupport as m,textSymbolLayerSupportsVerticalOffset as h}from"../../../../symbols/callouts/calloutUtils.js";import{CreateLabelParameters as p}from"./CreateLabelParameters.js";import{perObjectElevationAligner as d}from"./ElevationAligners.js";import{SymbolUpdateType as f,needsElevationUpdates2D as u}from"./elevationAlignmentUtils.js";import{ElevationContext as g}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as y}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DObjectMetadata as x}from"./Graphics3DObjectMetadata.js";import{Graphics3DSymbolLayer as b}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as v}from"./graphicUtils.js";import{verticalPlacementFromAlignment as P,textRenderAlignmentFromHorizontalPlacement as O,horizontalPlacementToAnchorX as j,anchorFromPlacements as w,namedAnchorToHUDMaterialAnchorPos as S}from"./placementUtils.js";import{placePointOnGeometry as _,createStageObject as E,extendPointGraphicElevationContext as L}from"./pointUtils.js";import{createPointGeometry as z}from"../../webgl-engine/lib/GeometryUtil.js";import{TextRenderParameters as C}from"../../webgl-engine/lib/TextRenderParameters.js";import G from"../../webgl-engine/lib/TextTextureFactory.js";import{HUDMaterial as R}from"../../webgl-engine/materials/HUDMaterial.js";const U=[0,0,1];class D extends b{constructor(e,t,r,s){super(e,t,r,s),this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!1},this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const t=v(this.symbolLayer.size);if(t)throw new e("graphics3dtextsymbollayer:invalid-size",t)}await this._createTextRenderParameters()}async _createTextRenderParameters(){const e=this._context.graphicsCoreOwner.view.state.rasterPixelRatio;this._textRenderParameters=await C.fromSymbol(this.symbolLayer,e)}destroy(){super.destroy()}createGraphics3DGraphic(e){const s=e.graphic,n=_(s.geometry);if(t(n))return this.logger.warn(`unsupported geometry type for text symbol: ${s.geometry.type}`),null;const i=this.symbolLayer.text;if(t(i)||""===i)return null;const o=m(this.symbol)&&this.symbol.hasVisibleVerticalOffset()?this.symbol.verticalOffset:null;if(r(o)&&!h(this.symbolLayer))return this.logger.errorOncePerTick(`Callouts and vertical offset on text symbols are currently only supported with 'center' horizontal alignment (not with '${this.symbolLayer.horizontalAlignment}' alignment)`),null;const a=new p(o,this.symbolLayer.horizontalAlignment,P(this.symbolLayer.verticalAlignment));return this._createAs3DShape(s,n,i,a)}createLabel(e,r,s,n){const i=e.graphic,o=_(i.geometry);if(t(o))return this.logger.warn(`unsupported geometry type for label: ${i.geometry.type}`),null;const a=r.text;return!a||/^\s+$/.test(a)?null:this._createAs3DShape(i,o,a,r,s,n)}setGraphicElevationContext(e,t,r=0){const s=super.setGraphicElevationContext(e,t);return s.addOffsetRenderUnits(r),s}layerOpacityChanged(){return this.logger.warn("layer opacity change not yet implemented in Graphics3DTextSymbolLayer"),!1}layerElevationInfoChanged(e,t){return A(e,t,((e,t)=>{this.updateGraphicElevationContext(t,e)})),f.UPDATE}slicePlaneEnabledChanged(e,t){return A(e,t,(e=>{for(const t of e.stageObject.geometries)t.material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!1}updateGraphicElevationContext(e,t){const s=t.elevationContext;this.setGraphicElevationContext(e,s,r(t.metadata)?t.metadata.elevationOffset:0),t.needsElevationUpdates=u(s.mode)||"absolute-height"===s.mode}_defaultElevationInfoNoZ(){return W}_createAs3DShape(e,m,h,p,f,b){const v=this.setGraphicElevationContext(e,new g,p.elevationOffset),P="polyline"===s(e.geometry,"type"),j=e.uid;let w=null,S=null;if(t(b)){const e=O(p.horizontalPlacement);w=new G(h,e,this._textRenderParameters);let s=null;if(r(this._context.sharedResources.textures)){S=this._context.sharedResources.textures.fromData(w.key,(()=>n(w).create()),(()=>{r(s)&&s.release()}));const e=this._context.stage.renderView.textureRepository.acquire(S.texture.id);if(t(e)||i(e))return S.release(),null;s=e}}const _=T(w,p),C={occlusionTest:!0,screenOffset:p.screenOffset,anchorPosition:_,polygonOffset:!0,color:[1,1,1,1],centerOffsetUnits:p.centerOffsetUnits,drawInSecondSlot:!0};if(r(b)?C.textureId=b.id:r(S)&&(C.textureId=S.texture.id),r(p.verticalOffset)){const{screenLength:e,minWorldLength:t,maxWorldLength:s}=p.verticalOffset;C.verticalOffset={screenLength:o(e),minWorldLength:t||0,maxWorldLength:r(s)?s:1/0}}if(this._context.screenSizePerspectiveEnabled){const{screenSizePerspectiveSettings:e,screenSizePerspectiveSettingsLabels:t}=this._context.sharedResources;C.screenSizePerspective=t.overridePadding(this._textRenderParameters.haloSize+this._textRenderParameters.definition.background.padding[0]),C.screenSizePerspectiveAlignment=e}let D;if(P&&(C.shaderPolygonOffset=1e-4),C.hasSlicePlane=this._context.slicePlaneEnabled,r(f)){const e=JSON.stringify(C);D=f.get(e),t(D)&&(D=new R(C),f.add(e,D))}else D=new R(C);const A=p.translation,W=r(w)?a(w.displayWidth,w.displayHeight):l,I=p.centerOffset,k=z(D,U,A,null,W,I,[0,0],null),$=E(this._context,m,k,v,j);if(t($))return null;const H=new y(this,$.object,[k],t(f)?[D]:null,S,d,v);H.alignedSampledElevation=$.sampledElevation,H.needsElevationUpdates=u(v.mode)||"absolute-height"===v.mode;const{displayWidth:V,displayHeight:M}=r(w)?w:p;H.getScreenSize=(e=c())=>(e[0]=V,e[1]=M,e);const N=new x(p.elevationOffset,h);return H.metadata=N,L(H,m,this._context.elevationProvider),H}}function A(e,t,s){e&&e.forEach((e=>{const n=t(e);r(n)&&s(n,e.graphic)}))}function T(e,t){if("baseline"===t.verticalPlacement){const s=j[t.horizontalPlacement],n=r(e)?e.baselineAnchorY:0;return a(s,n)}const s=w(t.horizontalPlacement,t.verticalPlacement);return S[s]}const W={mode:"relative-to-ground",offset:0};export{D as Graphics3DTextSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{forEach as s,result as l}from"../../../../core/asyncUtils.js";import i from"../../../../core/Handles.js";import a from"../../../../core/Logger.js";import{someMap as r}from"../../../../core/MapUtils.js";import{destroyMaybe as o,disposeMaybe as n,isSome as c,isNone as h,abortMaybe as b,unwrap as d}from"../../../../core/maybe.js";import{throwIfAborted as p,isAbortError as u}from"../../../../core/promiseUtils.js";import{watch as g}from"../../../../core/reactiveUtils.js";import{property as y}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as f}from"../../../../core/accessorSupport/decorators/subclass.js";import{hydrateGraphic as m}from"../../../../layers/graphics/hydratedFeatures.js";import{createLabelFunction as _}from"../../../../layers/support/labelFormatUtils.js";import{hasCalloutSupport as C}from"../../../../symbols/callouts/calloutUtils.js";import{CreateLabelParameters as x}from"./CreateLabelParameters.js";import{VisibilityFlag as L,VisibilityGroup as v}from"./enums.js";import{make as T}from"./Graphics3DCalloutSymbolLayerFactory.js";import{LineCalloutSymbolLayerRenderingInfo as w,LineCalloutCreationContext as G}from"./Graphics3DLineCalloutSymbolLayer.js";import{getGraphics3DSymbol as A}from"./graphicSymbolUtils.js";import{get as D}from"./labelPlacement.js";import{horizontalPlacementFromAnchor as I,verticalPlacementFromAnchor as R,textRenderAlignmentFromHorizontalPlacement as S}from"./placementUtils.js";import{MaterialCollection as P}from"../../webgl-engine/lib/MaterialCollection.js";import{TextRenderer as j}from"../../webgl-engine/lib/TextRenderer.js";import{TextRenderParameters as E}from"../../webgl-engine/lib/TextRenderParameters.js";import{TextTextureAtlas as O}from"../../webgl-engine/lib/TextTextureAtlas.js";import{WebGLLayer as M}from"../../webgl-engine/lib/WebGLLayer.js";import{TaskPriority as V,Task as z}from"../../../support/Scheduler.js";class F{constructor(e,t){this.labelingContext=e,this.graphics3DGraphic=t,this.hasGraphics3DResources=!1,this.visible=!1,this.rendered=!1,this.textInitialized=!1,this.textRenderers=new Array,this.textLabelPlacements=new Array}}class U{constructor(e,t,s,l,i){this.labelClass=e,this.graphics3DSymbol=t,this.graphics3DCalloutSymbolLayer=s,this.textRenderParameters=l,this.labelFunction=i,this.calloutSymbolLayerIndex=0}}class k{constructor(e,t,s,l,i,a,r){this.layer=e,this.graphics3DCore=t,this.scaleVisibility=s,this.emptySymbolLabelSupported=l,this.elevationInfoOverride=i,this.disablePlacement=a,this.active=r,this.labelClassAbortController=new AbortController,this.labelClassContexts=new Array,this.graphics=new Map,this.labelsToInitialize=new Map,this.stageLayer=new M({pickable:!0,disableOctree:!0},e.uid)}}let B=class extends t{constructor(e){super(e),this._dirty=!1,this._labels=new Map,this._labelsToAdd=new Map,this._labelsToRemove=new Map,this._labelingContexts=new Array}setup(){this.dispose(),this._handles=new i,this._handles.add([g((()=>this.view.state?.camera),(()=>this.setDirty())),g((()=>this.view.state?.idlePixelRatio),(()=>this._resetAllLabels())),this.view.resourceController.scheduler.registerTask(V.LABELER,this)]),this._textTextureAtlas=new O({view:this.view}),this._hudMaterialCollection=new P(this.view._stage),this._calloutMaterialCollection=new P(this.view._stage)}dispose(){this._handles=o(this._handles),this._textTextureAtlas=n(this._textTextureAtlas),this._hudMaterialCollection=n(this._hudMaterialCollection),this._calloutMaterialCollection=n(this._calloutMaterialCollection),this._labelingContexts.length=0,this._labels.clear(),this._labelsToAdd.clear(),this._labelsToRemove.clear()}_activateLabelingContext(e){e.graphics.forEach(((t,s)=>{const l=new F(e,t);this._labels.set(s,l),e.labelsToInitialize.set(s,l),t.setVisibilityFlag(L.USER_SETTING,!0,v.LABEL)})),e.active=!0}_deactivateLabelingContext(e){e.graphics.forEach(((e,t)=>{e.setVisibilityFlag(L.USER_SETTING,!1,v.LABEL),this.setLabelGraphicVisibility(e,!1),this._labels.delete(t)})),e.active=!1}_addLabelTextureToAtlas(e){for(const t of e.graphics3DGraphic.labelLayers){if(!t._labelClass)continue;const s=e.textRenderers[t._labelIndex];c(s)&&this._textTextureAtlas.addTextTexture(s,t.stageObject)}e.rendered=!0}_removeLabelTextureFromAtlas(e){for(const t of e.graphics3DGraphic.labelLayers){if(!t._labelClass)continue;const s=e.textRenderers[t._labelIndex];c(s)&&this._textTextureAtlas.removeTextTexture(s,t.stageObject)}e.rendered=!1}get running(){return this.view.ready&&(this._dirty||this.deconflictor.running)}runTask(e){return this._updateLabels(e),!this._dirty&&this.deconflictor.running&&this.deconflictor.runTask(e),z.YIELD}_updateLabels(e){if(this._dirty){this._dirty=!1;for(const t of this._labelingContexts)if(t.active){if(!H(t)){if(W(t)){this._deactivateLabelingContext(t);continue}if(this._createLabelClassContext(t),N(t)){this._dirty=!0;continue}if(!H(t))continue}r(t.labelsToInitialize,((s,l)=>(this._ensureGraphics3DResources(s)&&(this._labels.set(l,s),this.deconflictor.setDirty(),e.madeProgress()),(s.visible&&s.textInitialized||!s.visible&&s.hasGraphics3DResources)&&(t.labelsToInitialize.delete(l),e.madeProgress()),e.done)))&&(this._dirty=!0)}this._labelsToRemove.forEach((e=>this._removeLabelTextureFromAtlas(e))),this._labelsToAdd.forEach((e=>this._addLabelTextureToAtlas(e))),this._labelsToRemove.clear(),this._labelsToAdd.clear(),this._dirty||this.notifyChange("updating")}}async _createLabelClassContextAsync(e){const t=e.labelClassAbortController?.signal;await(e.layer.when?.()),p(t),e.scaleVisibility&&e.scaleVisibility.updateScaleRangeActive();const i=e.graphics3DCore,r=i.layer,o=r.labelingInfo&&r.labelingInfo.filter((e=>!!e.symbol));if(!o||0===o.length)return;let n=!1;await s(o,(async(s,r)=>{const o=s.symbol,c=A(i.getOrCreateGraphics3DSymbol(o));if(h(c))return void a.getLogger(this.declaredClass).error("Failed to create Graphics3DSymbol for label");await c.load(),p(t);let b=null;C(o)&&o.hasVisibleCallout()&&(b=T(o,i.symbolCreationContext),await b.load(),p(t));const d=await l(_(s,e.layer.fieldsIndex,this.view.spatialReference));if(p(t),!0===d.ok){const l=await this._createTextRenderParameters(c.symbol);p(t),e.labelClassContexts[r]=new U(s,c,b,l,d.value)}else a.getLogger(this.declaredClass).error(`Label expression failed to evaluate: ${d.error}`),n=!0})),p(t)}async _createLabelClassContext(e){return h(e.labelClassPromise)&&(e.labelClassPromise=this._createLabelClassContextAsync(e).catch((t=>{if(u(t))throw t;e.labelClassContexts.length=0})).then((()=>{e.labelClassAbortController=null,this.notifyChange("updating")})).catch((()=>{})),this.notifyChange("updating")),e.labelClassPromise}async _createTextRenderParameters(e){const t=e.symbolLayers.getItemAt(0);return t&&"text"===t.type?E.fromSymbol(t,this.view.state.idlePixelRatio):null}_destroyLabelClassContext(e){for(const s of e.labelClassContexts)--s.graphics3DSymbol.referenced;const t=e.labelClassAbortController;e.labelClassAbortController=new AbortController,b(t),e.labelClassContexts.length=0,e.labelClassPromise=null,this.notifyChange("updating")}_createTextSymbolGraphic(e,t,s,l,i){const a=new x(s.verticalOffset,I(s.anchor),R(s.anchor),e.text,s.translation,s.elevationOffset,s.centerOffset,s.screenOffset,s.centerOffsetUnits,e.displayWidth,e.displayHeight);return Y.graphic=t,Y.renderingInfo=null,Y.layer=l,i.createLabel(Y,a,this._hudMaterialCollection,this._textTextureAtlas)}_createLineCalloutGraphic(e,t,s,l,i){return Y.graphic=e,Y.layer=i,Y.renderingInfo=new w(null,t,l.translation,l.centerOffset,l.screenOffset,l.centerOffsetUnits,l.elevationOffset,this._calloutMaterialCollection),s.createGraphics3DGraphic(Y)}_ensureGraphics3DResources(e){if(e.hasGraphics3DResources)return!1;const t=e.graphics3DGraphic;if(t.destroyed)return!1;this._ensureTextTextureResources(e);const s=e.labelingContext,l=s.labelClassContexts;if(!l||0===l.length||!s.emptySymbolLabelSupported&&0===t.layers.length)return!1;let i=!1;const a=t.graphic,r=s.layer,o=$(s.layer),n=this.view._stage;for(let b=0;b<l.length;b++){const d=e.textRenderers[b],p=e.textLabelPlacements[b];if(h(d)||h(p))continue;const u=l[b],g=u.graphics3DSymbol,y=g.symbol&&"label-3d"===g.symbol.type?g.symbol:null,f=g.symbolLayers[0];if(!f)continue;f.setElevationInfoOverride(s.elevationInfoOverride);const m=this._createTextSymbolGraphic(d,a,p,r,f);if(h(m))return!1;m._labelClass=u.labelClass,m._labelIndex=b,t.addLabelGraphic(m,n,s.stageLayer),t.setVisibilityFlag(L.USER_SETTING,o,v.LABEL),t.clearVisibilityFlag(L.SCALE_RANGE,v.LABEL),t.setVisibilityFlag(L.DECONFLICTION,!1,v.LABEL),i=!0;const _=u.graphics3DCalloutSymbolLayer;if(_&&p.hasLabelVerticalOffset){_.setElevationInfoOverride(s.elevationInfoOverride);const e=this._createLineCalloutGraphic(a,y,_,p,r);c(e)&&(u.calloutSymbolLayerIndex=t.labelLayers.length,t.addLabelGraphic(e,n,s.stageLayer))}break}return s.scaleVisibility&&i&&s.scaleVisibility.updateGraphicLabelScaleVisibility(t),e.hasGraphics3DResources=!0,!0}_destroyGraphics3DResources(e){const t=e.labelingContext.labelClassContexts;for(const s of e.graphics3DGraphic.labelLayers){if(null==s._labelClass)continue;const e=t[s._labelIndex].graphics3DSymbol.symbolLayers[0];null!=e&&e.onRemoveGraphic(s)}e.graphics3DGraphic.clearLabelGraphics(),e.hasGraphics3DResources=!1}_ensureTextTextureResources(e){if(e.textInitialized)return;const t=e.labelingContext,s=t.labelClassContexts;if(!s||0===s.length)return;const l=e.graphics3DGraphic.graphic;for(let a=0;a<s.length;a++){const r=s[a];if(e.textRenderers[a]=null,e.textLabelPlacements[a]=null,!r.textRenderParameters)continue;const o=r.labelFunction;let n;if("arcade"===o.type)try{const e=o.needsHydrationToEvaluate()?m(l,t.layer):l;n=o.evaluate(e)}catch(i){n=null}else n=o.evaluate(l);if(h(n)||""===n||/^\s+$/.test(n))continue;const c=r.graphics3DSymbol,b="label-3d"===c.symbol?.type?c.symbol:null;if(!c.symbolLayers[0])continue;const d=e.graphics3DGraphic,p=r.labelClass,u=t.disablePlacement,g=D({graphics3DGraphic:d,labelSymbol:b,labelClass:p,disablePlacement:u});if(h(g))continue;const y=I(g.anchor),f=S(y);e.textRenderers[a]=new j(n,f,r.textRenderParameters),e.textLabelPlacements[a]=g}e.textInitialized=!0}_destroyTextTextureResources(e){e.textInitialized=!1,e.textRenderers.length=0,e.textLabelPlacements.length=0}_addGraphic(e,t){const s=t.graphic.uid;if(e.graphics.set(s,t),e.active){const l=new F(e,t);this._labels.set(s,l),e.labelsToInitialize.set(s,l)}this.setDirty(),this.deconflictor.setDirty()}_removeGraphic(e,t){const s=t.graphic.uid,l=this._labels.get(s);e.graphics.delete(s),l&&(this._destroyGraphic(l,s),e.labelsToInitialize.delete(s),this.setDirty(),this.deconflictor.setDirty())}_destroyGraphic(e,t){this._labels.has(t)&&(this._labels.delete(t),this._labelsToAdd.delete(t),this._labelsToRemove.delete(t)),e.textInitialized&&(this._removeLabelTextureFromAtlas(e),this._destroyTextTextureResources(e)),e.hasGraphics3DResources&&this._destroyGraphics3DResources(e)}async _labelingInfoChange(e,t){if(!t)return this._visibilityInfoChange(e),this._resetLabels(e),this._createLabelClassContext(e);for(const s of t){const t=e.graphics.get(s);t&&(this._removeGraphic(e,t),this._addGraphic(e,t))}}_globalPropertyChanged(e,t){for(const s of t.labelClassContexts){const l=new Map;t.graphics.forEach((e=>l.set(e.graphic.uid,e)));const i=e=>e.labelLayers[0];if(d(s.graphics3DSymbol.symbolLayers[0]).globalPropertyChanged(e,l,i),s.graphics3DCalloutSymbolLayer){const t=e=>e.labelLayers[s.calloutSymbolLayerIndex];s.graphics3DCalloutSymbolLayer.globalPropertyChanged(e,l,t)}}}_visibilityInfoChange(e){const t=$(e.layer);t&&!e.active&&this._activateLabelingContext(e),!t&&e.active&&this._deactivateLabelingContext(e),this.setDirty()}_resetAllLabels(){for(const e of this._labelingContexts)this._resetLabels(e)}_resetLabels(e){e.graphics.forEach(((t,s)=>{const l=this._labels.get(s);l&&(this._destroyGraphic(l,s),l.visible=!1,l.rendered=!1,e.labelsToInitialize.set(s,l))})),this._destroyLabelClassContext(e),this.setDirty(),this.deconflictor.setDirty()}_findLabelingContext(e){for(const t of this._labelingContexts)if(t.graphics3DCore===e)return t;return null}addGraphicsOwner(e,t,s){const l=s&&s.emptySymbolLabelSupported||!1,i=s&&s.elevationInfoOverride||null,a=s&&s.disablePlacement||null;if(this._findLabelingContext(e))return;const r=e.layer,o=new k(r,e,t,l,i,a,$(r));return this.view._stage.add(o.stageLayer),this._labelingContexts.push(o),this.setDirty(),{addGraphic:e=>this._addGraphic(o,e),removeGraphic:e=>this._removeGraphic(o,e),featureReductionChange:()=>{},layerLabelsEnabled:()=>$(o.layer),labelingInfoChange:e=>this._labelingInfoChange(o,e),elevationInfoChange:()=>this._globalPropertyChanged("elevationInfo",o),slicePlaneEnabledChange:()=>this._globalPropertyChanged("slicePlaneEnabled",o),visibilityInfoChange:()=>this._visibilityInfoChange(o),reset:()=>this._resetLabels(o),clear:()=>{}}}removeGraphicsOwner(e){const t=this._findLabelingContext(e);if(!t)return;const s=this._labelingContexts.indexOf(t);this._labelingContexts.splice(s,1),t.graphics.forEach((e=>this._removeGraphic(t,e))),this.view._stage.remove(t.stageLayer),this.setDirty()}setLabelGraphicVisibility(e,t){const s=e.graphic.uid,l=this._labels.get(s);l&&l.visible!==t&&(t&&!l.rendered?(this._labelsToAdd.set(s,l),this._labelsToRemove.delete(s),l.textInitialized||l.labelingContext.labelsToInitialize.set(s,l)):!t&&l.rendered&&(this._labelsToRemove.set(s,l),this._labelsToAdd.delete(s)),l.visible=t,this.setDirty())}setDirty(){!this._dirty&&this._labelingContexts.length>0&&(this._dirty=!0,this.notifyChange("updating"))}get updating(){return this._dirty||this._textTextureAtlas?.updating||this.deconflictor.updating||this._labelingContexts.some((e=>N(e)))}get updatingProgress(){if(!this.updating||!this._textTextureAtlas)return 1;const e=this._labelingContexts.length>0?this._labelingContexts.reduce(((e,t)=>e+(N(t)?0:1)),0)/this._labelingContexts.length:1;return(this._dirty?0:.3)+(this._textTextureAtlas.updating?0:.1)+.1*e+.5*this.deconflictor.updatingProgress}get test(){return{textTextureAtlas:this._textTextureAtlas,resetAllLabels:()=>this._resetAllLabels()}}};function N(e){return!!e.labelClassPromise&&!!e.labelClassAbortController}function H(e){return e.labelClassContexts&&e.labelClassContexts.length}function W(e){return null===e.labelClassContexts}function $(e){return!0===e.labelsVisible&&!!e.labelingInfo?.some((e=>!!e.symbol))}e([y({constructOnly:!0})],B.prototype,"view",void 0),e([y({constructOnly:!0})],B.prototype,"deconflictor",void 0),e([y()],B.prototype,"_textTextureAtlas",void 0),e([y({type:Boolean,readOnly:!0})],B.prototype,"updating",null),B=e([f("esri.views.3d.layers.graphics.Labeler")],B);const Y=new G(null,null,null);export{B as Labeler,$ as areLabelsVisible};
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{forEach as s,result as l}from"../../../../core/asyncUtils.js";import i from"../../../../core/Handles.js";import a from"../../../../core/Logger.js";import{someMap as r}from"../../../../core/MapUtils.js";import{destroyMaybe as o,disposeMaybe as n,isSome as c,isNone as h,abortMaybe as b,unwrap as d}from"../../../../core/maybe.js";import{throwIfAborted as p,isAbortError as u}from"../../../../core/promiseUtils.js";import{watch as g}from"../../../../core/reactiveUtils.js";import{property as y}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as f}from"../../../../core/accessorSupport/decorators/subclass.js";import{hydrateGraphic as m}from"../../../../layers/graphics/hydratedFeatures.js";import{createLabelFunction as _}from"../../../../layers/support/labelFormatUtils.js";import{hasCalloutSupport as C}from"../../../../symbols/callouts/calloutUtils.js";import{CreateLabelParameters as x}from"./CreateLabelParameters.js";import{VisibilityFlag as L,VisibilityGroup as v}from"./enums.js";import{make as T}from"./Graphics3DCalloutSymbolLayerFactory.js";import{LineCalloutSymbolLayerRenderingInfo as w,LineCalloutCreationContext as G}from"./Graphics3DLineCalloutSymbolLayer.js";import{getGraphics3DSymbol as A}from"./graphicSymbolUtils.js";import{get as D}from"./labelPlacement.js";import{horizontalPlacementFromAnchor as I,verticalPlacementFromAnchor as R,textRenderAlignmentFromHorizontalPlacement as S}from"./placementUtils.js";import{MaterialCollection as P}from"../../webgl-engine/lib/MaterialCollection.js";import{TextRenderer as j}from"../../webgl-engine/lib/TextRenderer.js";import{TextRenderParameters as E}from"../../webgl-engine/lib/TextRenderParameters.js";import{TextTextureAtlas as O}from"../../webgl-engine/lib/TextTextureAtlas.js";import{WebGLLayer as M}from"../../webgl-engine/lib/WebGLLayer.js";import{TaskPriority as V,Task as z}from"../../../support/Scheduler.js";class F{constructor(e,t){this.labelingContext=e,this.graphics3DGraphic=t,this.hasGraphics3DResources=!1,this.visible=!1,this.rendered=!1,this.textInitialized=!1,this.textRenderers=new Array,this.textLabelPlacements=new Array}}class U{constructor(e,t,s,l,i){this.labelClass=e,this.graphics3DSymbol=t,this.graphics3DCalloutSymbolLayer=s,this.textRenderParameters=l,this.labelFunction=i,this.calloutSymbolLayerIndex=0}}class k{constructor(e,t,s,l,i,a,r){this.layer=e,this.graphics3DCore=t,this.scaleVisibility=s,this.emptySymbolLabelSupported=l,this.elevationInfoOverride=i,this.disablePlacement=a,this.active=r,this.labelClassAbortController=new AbortController,this.labelClassContexts=new Array,this.graphics=new Map,this.labelsToInitialize=new Map,this.stageLayer=new M({pickable:!0,disableOctree:!0},e.uid)}}let B=class extends t{constructor(e){super(e),this._dirty=!1,this._labels=new Map,this._labelsToAdd=new Map,this._labelsToRemove=new Map,this._labelingContexts=new Array}setup(){this.dispose(),this._handles=new i,this._handles.add([g((()=>this.view.state?.camera),(()=>this.setDirty())),g((()=>this.view.state?.rasterPixelRatio),(()=>this._resetAllLabels())),this.view.resourceController.scheduler.registerTask(V.LABELER,this)]),this._textTextureAtlas=new O({view:this.view}),this._hudMaterialCollection=new P(this.view._stage),this._calloutMaterialCollection=new P(this.view._stage)}dispose(){this._handles=o(this._handles),this._textTextureAtlas=n(this._textTextureAtlas),this._hudMaterialCollection=n(this._hudMaterialCollection),this._calloutMaterialCollection=n(this._calloutMaterialCollection),this._labelingContexts.length=0,this._labels.clear(),this._labelsToAdd.clear(),this._labelsToRemove.clear()}_activateLabelingContext(e){e.graphics.forEach(((t,s)=>{const l=new F(e,t);this._labels.set(s,l),e.labelsToInitialize.set(s,l),t.setVisibilityFlag(L.USER_SETTING,!0,v.LABEL)})),e.active=!0}_deactivateLabelingContext(e){e.graphics.forEach(((e,t)=>{e.setVisibilityFlag(L.USER_SETTING,!1,v.LABEL),this.setLabelGraphicVisibility(e,!1),this._labels.delete(t)})),e.active=!1}_addLabelTextureToAtlas(e){for(const t of e.graphics3DGraphic.labelLayers){if(!t._labelClass)continue;const s=e.textRenderers[t._labelIndex];c(s)&&this._textTextureAtlas.addTextTexture(s,t.stageObject)}e.rendered=!0}_removeLabelTextureFromAtlas(e){for(const t of e.graphics3DGraphic.labelLayers){if(!t._labelClass)continue;const s=e.textRenderers[t._labelIndex];c(s)&&this._textTextureAtlas.removeTextTexture(s,t.stageObject)}e.rendered=!1}get running(){return this.view.ready&&(this._dirty||this.deconflictor.running)}runTask(e){return this._updateLabels(e),!this._dirty&&this.deconflictor.running&&this.deconflictor.runTask(e),z.YIELD}_updateLabels(e){if(this._dirty){this._dirty=!1;for(const t of this._labelingContexts)if(t.active){if(!H(t)){if(W(t)){this._deactivateLabelingContext(t);continue}if(this._createLabelClassContext(t),N(t)){this._dirty=!0;continue}if(!H(t))continue}r(t.labelsToInitialize,((s,l)=>(this._ensureGraphics3DResources(s)&&(this._labels.set(l,s),this.deconflictor.setDirty(),e.madeProgress()),(s.visible&&s.textInitialized||!s.visible&&s.hasGraphics3DResources)&&(t.labelsToInitialize.delete(l),e.madeProgress()),e.done)))&&(this._dirty=!0)}this._labelsToRemove.forEach((e=>this._removeLabelTextureFromAtlas(e))),this._labelsToAdd.forEach((e=>this._addLabelTextureToAtlas(e))),this._labelsToRemove.clear(),this._labelsToAdd.clear(),this._dirty||this.notifyChange("updating")}}async _createLabelClassContextAsync(e){const t=e.labelClassAbortController?.signal;await(e.layer.when?.()),p(t),e.scaleVisibility&&e.scaleVisibility.updateScaleRangeActive();const i=e.graphics3DCore,r=i.layer,o=r.labelingInfo&&r.labelingInfo.filter((e=>!!e.symbol));if(!o||0===o.length)return;let n=!1;await s(o,(async(s,r)=>{const o=s.symbol,c=A(i.getOrCreateGraphics3DSymbol(o));if(h(c))return void a.getLogger(this.declaredClass).error("Failed to create Graphics3DSymbol for label");await c.load(),p(t);let b=null;C(o)&&o.hasVisibleCallout()&&(b=T(o,i.symbolCreationContext),await b.load(),p(t));const d=await l(_(s,e.layer.fieldsIndex,this.view.spatialReference));if(p(t),!0===d.ok){const l=await this._createTextRenderParameters(c.symbol);p(t),e.labelClassContexts[r]=new U(s,c,b,l,d.value)}else a.getLogger(this.declaredClass).error(`Label expression failed to evaluate: ${d.error}`),n=!0})),p(t)}async _createLabelClassContext(e){return h(e.labelClassPromise)&&(e.labelClassPromise=this._createLabelClassContextAsync(e).catch((t=>{if(u(t))throw t;e.labelClassContexts.length=0})).then((()=>{e.labelClassAbortController=null,this.notifyChange("updating")})).catch((()=>{})),this.notifyChange("updating")),e.labelClassPromise}async _createTextRenderParameters(e){const t=e.symbolLayers.getItemAt(0);return t&&"text"===t.type?E.fromSymbol(t,this.view.state.rasterPixelRatio):null}_destroyLabelClassContext(e){for(const s of e.labelClassContexts)--s.graphics3DSymbol.referenced;const t=e.labelClassAbortController;e.labelClassAbortController=new AbortController,b(t),e.labelClassContexts.length=0,e.labelClassPromise=null,this.notifyChange("updating")}_createTextSymbolGraphic(e,t,s,l,i){const a=new x(s.verticalOffset,I(s.anchor),R(s.anchor),e.text,s.translation,s.elevationOffset,s.centerOffset,s.screenOffset,s.centerOffsetUnits,e.displayWidth,e.displayHeight);return Y.graphic=t,Y.renderingInfo=null,Y.layer=l,i.createLabel(Y,a,this._hudMaterialCollection,this._textTextureAtlas)}_createLineCalloutGraphic(e,t,s,l,i){return Y.graphic=e,Y.layer=i,Y.renderingInfo=new w(null,t,l.translation,l.centerOffset,l.screenOffset,l.centerOffsetUnits,l.elevationOffset,this._calloutMaterialCollection),s.createGraphics3DGraphic(Y)}_ensureGraphics3DResources(e){if(e.hasGraphics3DResources)return!1;const t=e.graphics3DGraphic;if(t.destroyed)return!1;this._ensureTextTextureResources(e);const s=e.labelingContext,l=s.labelClassContexts;if(!l||0===l.length||!s.emptySymbolLabelSupported&&0===t.layers.length)return!1;let i=!1;const a=t.graphic,r=s.layer,o=$(s.layer),n=this.view._stage;for(let b=0;b<l.length;b++){const d=e.textRenderers[b],p=e.textLabelPlacements[b];if(h(d)||h(p))continue;const u=l[b],g=u.graphics3DSymbol,y=g.symbol&&"label-3d"===g.symbol.type?g.symbol:null,f=g.symbolLayers[0];if(!f)continue;f.setElevationInfoOverride(s.elevationInfoOverride);const m=this._createTextSymbolGraphic(d,a,p,r,f);if(h(m))return!1;m._labelClass=u.labelClass,m._labelIndex=b,t.addLabelGraphic(m,n,s.stageLayer),t.setVisibilityFlag(L.USER_SETTING,o,v.LABEL),t.clearVisibilityFlag(L.SCALE_RANGE,v.LABEL),t.setVisibilityFlag(L.DECONFLICTION,!1,v.LABEL),i=!0;const _=u.graphics3DCalloutSymbolLayer;if(_&&p.hasLabelVerticalOffset){_.setElevationInfoOverride(s.elevationInfoOverride);const e=this._createLineCalloutGraphic(a,y,_,p,r);c(e)&&(u.calloutSymbolLayerIndex=t.labelLayers.length,t.addLabelGraphic(e,n,s.stageLayer))}break}return s.scaleVisibility&&i&&s.scaleVisibility.updateGraphicLabelScaleVisibility(t),e.hasGraphics3DResources=!0,!0}_destroyGraphics3DResources(e){const t=e.labelingContext.labelClassContexts;for(const s of e.graphics3DGraphic.labelLayers){if(null==s._labelClass)continue;const e=t[s._labelIndex].graphics3DSymbol.symbolLayers[0];null!=e&&e.onRemoveGraphic(s)}e.graphics3DGraphic.clearLabelGraphics(),e.hasGraphics3DResources=!1}_ensureTextTextureResources(e){if(e.textInitialized)return;const t=e.labelingContext,s=t.labelClassContexts;if(!s||0===s.length)return;const l=e.graphics3DGraphic.graphic;for(let a=0;a<s.length;a++){const r=s[a];if(e.textRenderers[a]=null,e.textLabelPlacements[a]=null,!r.textRenderParameters)continue;const o=r.labelFunction;let n;if("arcade"===o.type)try{const e=o.needsHydrationToEvaluate()?m(l,t.layer):l;n=o.evaluate(e)}catch(i){n=null}else n=o.evaluate(l);if(h(n)||""===n||/^\s+$/.test(n))continue;const c=r.graphics3DSymbol,b="label-3d"===c.symbol?.type?c.symbol:null;if(!c.symbolLayers[0])continue;const d=e.graphics3DGraphic,p=r.labelClass,u=t.disablePlacement,g=D({graphics3DGraphic:d,labelSymbol:b,labelClass:p,disablePlacement:u});if(h(g))continue;const y=I(g.anchor),f=S(y);e.textRenderers[a]=new j(n,f,r.textRenderParameters),e.textLabelPlacements[a]=g}e.textInitialized=!0}_destroyTextTextureResources(e){e.textInitialized=!1,e.textRenderers.length=0,e.textLabelPlacements.length=0}_addGraphic(e,t){const s=t.graphic.uid;if(e.graphics.set(s,t),e.active){const l=new F(e,t);this._labels.set(s,l),e.labelsToInitialize.set(s,l)}this.setDirty(),this.deconflictor.setDirty()}_removeGraphic(e,t){const s=t.graphic.uid,l=this._labels.get(s);e.graphics.delete(s),l&&(this._destroyGraphic(l,s),e.labelsToInitialize.delete(s),this.setDirty(),this.deconflictor.setDirty())}_destroyGraphic(e,t){this._labels.has(t)&&(this._labels.delete(t),this._labelsToAdd.delete(t),this._labelsToRemove.delete(t)),e.textInitialized&&(this._removeLabelTextureFromAtlas(e),this._destroyTextTextureResources(e)),e.hasGraphics3DResources&&this._destroyGraphics3DResources(e)}async _labelingInfoChange(e,t){if(!t)return this._visibilityInfoChange(e),this._resetLabels(e),this._createLabelClassContext(e);for(const s of t){const t=e.graphics.get(s);t&&(this._removeGraphic(e,t),this._addGraphic(e,t))}}_globalPropertyChanged(e,t){for(const s of t.labelClassContexts){const l=new Map;t.graphics.forEach((e=>l.set(e.graphic.uid,e)));const i=e=>e.labelLayers[0];if(d(s.graphics3DSymbol.symbolLayers[0]).globalPropertyChanged(e,l,i),s.graphics3DCalloutSymbolLayer){const t=e=>e.labelLayers[s.calloutSymbolLayerIndex];s.graphics3DCalloutSymbolLayer.globalPropertyChanged(e,l,t)}}}_visibilityInfoChange(e){const t=$(e.layer);t&&!e.active&&this._activateLabelingContext(e),!t&&e.active&&this._deactivateLabelingContext(e),this.setDirty()}_resetAllLabels(){for(const e of this._labelingContexts)this._resetLabels(e)}_resetLabels(e){e.graphics.forEach(((t,s)=>{const l=this._labels.get(s);l&&(this._destroyGraphic(l,s),l.visible=!1,l.rendered=!1,e.labelsToInitialize.set(s,l))})),this._destroyLabelClassContext(e),this.setDirty(),this.deconflictor.setDirty()}_findLabelingContext(e){for(const t of this._labelingContexts)if(t.graphics3DCore===e)return t;return null}addGraphicsOwner(e,t,s){const l=s&&s.emptySymbolLabelSupported||!1,i=s&&s.elevationInfoOverride||null,a=s&&s.disablePlacement||null;if(this._findLabelingContext(e))return;const r=e.layer,o=new k(r,e,t,l,i,a,$(r));return this.view._stage.add(o.stageLayer),this._labelingContexts.push(o),this.setDirty(),{addGraphic:e=>this._addGraphic(o,e),removeGraphic:e=>this._removeGraphic(o,e),featureReductionChange:()=>{},layerLabelsEnabled:()=>$(o.layer),labelingInfoChange:e=>this._labelingInfoChange(o,e),elevationInfoChange:()=>this._globalPropertyChanged("elevationInfo",o),slicePlaneEnabledChange:()=>this._globalPropertyChanged("slicePlaneEnabled",o),visibilityInfoChange:()=>this._visibilityInfoChange(o),reset:()=>this._resetLabels(o),clear:()=>{}}}removeGraphicsOwner(e){const t=this._findLabelingContext(e);if(!t)return;const s=this._labelingContexts.indexOf(t);this._labelingContexts.splice(s,1),t.graphics.forEach((e=>this._removeGraphic(t,e))),this.view._stage.remove(t.stageLayer),this.setDirty()}setLabelGraphicVisibility(e,t){const s=e.graphic.uid,l=this._labels.get(s);l&&l.visible!==t&&(t&&!l.rendered?(this._labelsToAdd.set(s,l),this._labelsToRemove.delete(s),l.textInitialized||l.labelingContext.labelsToInitialize.set(s,l)):!t&&l.rendered&&(this._labelsToRemove.set(s,l),this._labelsToAdd.delete(s)),l.visible=t,this.setDirty())}setDirty(){!this._dirty&&this._labelingContexts.length>0&&(this._dirty=!0,this.notifyChange("updating"))}get updating(){return this._dirty||this._textTextureAtlas?.updating||this.deconflictor.updating||this._labelingContexts.some((e=>N(e)))}get updatingProgress(){if(!this.updating||!this._textTextureAtlas)return 1;const e=this._labelingContexts.length>0?this._labelingContexts.reduce(((e,t)=>e+(N(t)?0:1)),0)/this._labelingContexts.length:1;return(this._dirty?0:.3)+(this._textTextureAtlas.updating?0:.1)+.1*e+.5*this.deconflictor.updatingProgress}get test(){return{textTextureAtlas:this._textTextureAtlas,resetAllLabels:()=>this._resetAllLabels()}}};function N(e){return!!e.labelClassPromise&&!!e.labelClassAbortController}function H(e){return e.labelClassContexts&&e.labelClassContexts.length}function W(e){return null===e.labelClassContexts}function $(e){return!0===e.labelsVisible&&!!e.labelingInfo?.some((e=>!!e.symbol))}e([y({constructOnly:!0})],B.prototype,"view",void 0),e([y({constructOnly:!0})],B.prototype,"deconflictor",void 0),e([y()],B.prototype,"_textTextureAtlas",void 0),e([y({type:Boolean,readOnly:!0})],B.prototype,"updating",null),B=e([f("esri.views.3d.layers.graphics.Labeler")],B);const Y=new G(null,null,null);export{B as Labeler,$ as areLabelsVisible};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{adjustStaticAGOUrl as e}from"../../../../core/devEnvironmentUtils.js";import{get as t,isSome as r,isNone as o}from"../../../../core/maybe.js";import{b as s}from"../../../../chunks/mat3.js";import{c as i}from"../../../../chunks/mat3f64.js";import{a as n}from"../../../../chunks/mat4.js";import{c as a}from"../../../../chunks/mat4f64.js";import{m as u,b as l,C as c,l as m,n as f,h as d}from"../../../../chunks/vec3.js";import{c as p}from"../../../../chunks/vec3f64.js";import{empty as g,expandWithVec3 as b}from"../../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as x,BufferViewVec4f as h,BufferViewVec2f as T,BufferViewVec4u8 as R,BufferViewVec4u16 as w,BufferViewVec3u8 as j,BufferViewVec3u16 as M}from"../../../../geometry/support/buffer/BufferView.js";import{t as v,a as y,s as B}from"../../../../chunks/vec32.js";import{t as L,s as C}from"../../../../chunks/vec42.js";import{createBuffer as I}from"../../../../geometry/support/buffer/utils.js";import{DefaultLoadingContext as A}from"../../glTF/DefaultLoadingContext.js";import{loadGLTF as O}from"../../glTF/loader.js";import{triangleFanToTriangles as S,triangleStripToTriangles as E,trianglesToTriangles as N}from"../../glTF/internal/indexUtils.js";import{
|
|
5
|
+
import{adjustStaticAGOUrl as e}from"../../../../core/devEnvironmentUtils.js";import{get as t,isSome as r,isNone as o}from"../../../../core/maybe.js";import{b as s}from"../../../../chunks/mat3.js";import{c as i}from"../../../../chunks/mat3f64.js";import{a as n}from"../../../../chunks/mat4.js";import{c as a}from"../../../../chunks/mat4f64.js";import{m as u,b as l,C as c,l as m,n as f,h as d}from"../../../../chunks/vec3.js";import{c as p}from"../../../../chunks/vec3f64.js";import{empty as g,expandWithVec3 as b}from"../../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as x,BufferViewVec4f as h,BufferViewVec2f as T,BufferViewVec4u8 as R,BufferViewVec4u16 as w,BufferViewVec3u8 as j,BufferViewVec3u16 as M}from"../../../../geometry/support/buffer/BufferView.js";import{t as v,a as y,s as B}from"../../../../chunks/vec32.js";import{t as L,s as C}from"../../../../chunks/vec42.js";import{createBuffer as I}from"../../../../geometry/support/buffer/utils.js";import{DefaultLoadingContext as A}from"../../glTF/DefaultLoadingContext.js";import{loadGLTF as O}from"../../glTF/loader.js";import{triangleFanToTriangles as S,triangleStripToTriangles as E,trianglesToTriangles as N}from"../../glTF/internal/indexUtils.js";import{isEncodedMeshTexture as k}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as F}from"../../glTF/internal/TextureTransformUtils.js";import{ProcessedObjectResource as P}from"./ProcessedObjectResource.js";import{load as V,processLoadResult as _}from"./wosrLoader.js";import{NormalAttributeType as G}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{Attribute as D}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as U,DepthTestFunction as H,CullFaceOptions as q}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as W}from"../../webgl-engine/lib/Geometry.js";import{Texture as $}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as z}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as K}from"../../webgl-engine/materials/DefaultMaterial.js";import{COLOR_GAMMA as Q}from"../../webgl-engine/materials/DefaultMaterial_COLOR_GAMMA.js";import{PrimitiveType as J}from"../../../webgl/enums.js";import{n as X}from"../../../../chunks/vec22.js";import{c as Y,f as Z}from"../../../../chunks/vec43.js";import{c as ee}from"../../../../chunks/vec33.js";async function te(o,s){const i=re(e(o));if("wosr"===i.fileType){const e=await(s.cache?s.cache.loadWOSR(i.url,s):V(i.url,s)),{engineResources:t,referenceBoundingBox:r}=_(e,s);return{lods:t,referenceBoundingBox:r,isEsriSymbolResource:!1,isWosr:!0}}const n=await(s.cache?s.cache.loadGLTF(i.url,s,!!s.usePBR):O(new A(s.streamDataRequester),i.url,s,s.usePBR)),a=t(n.model.meta,"ESRI_proxyEllipsoid"),u=n.meta.isEsriSymbolResource&&r(a)&&n.meta.uri.includes("/RealisticTrees/");u&&!n.customMeta.esriTreeRendering&&(n.customMeta.esriTreeRendering=!0,le(n,a));const l=!!s.usePBR,c=n.meta.isEsriSymbolResource?{usePBR:l,isSchematic:!1,treeRendering:u,mrrFactors:[0,1,.2]}:{usePBR:l,isSchematic:!1,treeRendering:!1,mrrFactors:[0,1,.5]},m={...s.materialParamsMixin,treeRendering:u},{engineResources:f,referenceBoundingBox:d}=oe(n,c,m,s.skipHighLods&&null==i.specifiedLodIndex?{skipHighLods:!0}:{skipHighLods:!1,singleLodIndex:i.specifiedLodIndex});return{lods:f,referenceBoundingBox:d,isEsriSymbolResource:n.meta.isEsriSymbolResource,isWosr:!1}}function re(e){const t=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);if(t)return{fileType:"gltf",url:t[1],specifiedLodIndex:null!=t[4]?Number(t[4]):null};return e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}function oe(e,t,o,s){const i=e.model,n=new Array,a=new Map,u=new Map,l=i.lods.length,c=g();return i.lods.forEach(((e,m)=>{const f=!0===s.skipHighLods&&(l>1&&0===m||l>3&&1===m)||!1===s.skipHighLods&&null!=s.singleLodIndex&&m!==s.singleLodIndex;if(f&&0!==m)return;const d=new P(e.name,e.lodThreshold,[0,0,0]);e.parts.forEach((e=>{const s=f?new K({}):se(i,e,d,t,o,a,u),{geometry:n,vertexCount:l}=ie(e,r(s)?s:new K({})),p=n.boundingInfo;r(p)&&0===m&&(b(c,p.bbMin),b(c,p.bbMax)),r(s)&&(d.stageResources.geometries.push(n),d.numberOfVertices+=l)})),f||n.push(d)})),{engineResources:n,referenceBoundingBox:c}}function se(e,t,s,i,n,a,u){const l=t.material+(t.attributes.normal?"_normal":"")+(t.attributes.color?"_color":"")+(t.attributes.texCoord0?"_texCoord0":"")+(t.attributes.tangent?"_tangent":""),c=e.materials.get(t.material),m=r(t.attributes.texCoord0),f=r(t.attributes.normal);if(o(c))return null;const d=ae(c.alphaMode);if(!a.has(l)){if(m){const t=(t,o=!1)=>{if(r(t)&&!u.has(t)){const s=e.textures.get(t);if(r(s)){const e=s.data;u.set(t,new $(k(e)?e.data:e,{...s.parameters,preMultiplyAlpha:!k(e)&&o,encoding:k(e)&&r(e.encoding)?e.encoding:void 0}))}}};t(c.textureColor,d!==U.Opaque),t(c.textureNormal),t(c.textureOcclusion),t(c.textureEmissive),t(c.textureMetallicRoughness)}const o=c.color[0]**(1/Q),s=c.color[1]**(1/Q),p=c.color[2]**(1/Q),g=c.emissiveFactor[0]**(1/Q),b=c.emissiveFactor[1]**(1/Q),x=c.emissiveFactor[2]**(1/Q),h=r(c.textureColor)&&m?u.get(c.textureColor):null;a.set(l,new K({...i,transparent:d===U.Blend,customDepthTest:H.Lequal,textureAlphaMode:d,textureAlphaCutoff:c.alphaCutoff,diffuse:[o,s,p],ambient:[o,s,p],opacity:c.opacity,doubleSided:c.doubleSided,doubleSidedType:"winding-order",cullFace:c.doubleSided?q.None:q.Back,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:f?G.Attribute:G.ScreenDerivative,castShadows:!0,receiveSSAO:!0,textureId:r(h)?h.id:void 0,colorMixMode:c.colorMixMode,normalTextureId:r(c.textureNormal)&&m?u.get(c.textureNormal).id:void 0,textureAlphaPremultiplied:r(h)&&!!h.params.preMultiplyAlpha,occlusionTextureId:r(c.textureOcclusion)&&m?u.get(c.textureOcclusion).id:void 0,emissiveTextureId:r(c.textureEmissive)&&m?u.get(c.textureEmissive).id:void 0,metallicRoughnessTextureId:r(c.textureMetallicRoughness)&&m?u.get(c.textureMetallicRoughness).id:void 0,emissiveFactor:[g,b,x],mrrFactors:[c.metallicFactor,c.roughnessFactor,i.mrrFactors[2]],isSchematic:!1,colorTextureTransformMatrix:F(c.colorTextureTransform),normalTextureTransformMatrix:F(c.normalTextureTransform),occlusionTextureTransformMatrix:F(c.occlusionTextureTransform),emissiveTextureTransformMatrix:F(c.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:F(c.metallicRoughnessTextureTransform),...n}))}const p=a.get(l);if(s.stageResources.materials.push(p),m){const e=e=>{r(e)&&s.stageResources.textures.push(u.get(e))};e(c.textureColor),e(c.textureNormal),e(c.textureOcclusion),e(c.textureEmissive),e(c.textureMetallicRoughness)}return p}function ie(e,t){const o=e.attributes.position.count,i=ue(e.indices||o,e.primitiveType),n=I(x,o);v(n,e.attributes.position,e.transform);const a=[[z.POSITION,new D(n.typedBuffer,n.elementCount,!0)]],u=[[z.POSITION,i]];if(r(e.attributes.normal)){const t=I(x,o);s(ne,e.transform),y(t,e.attributes.normal,ne),a.push([z.NORMAL,new D(t.typedBuffer,t.elementCount,!0)]),u.push([z.NORMAL,i])}if(r(e.attributes.tangent)){const t=I(h,o);s(ne,e.transform),L(t,e.attributes.tangent,ne),a.push([z.TANGENT,new D(t.typedBuffer,t.elementCount,!0)]),u.push([z.TANGENT,i])}if(r(e.attributes.texCoord0)){const t=I(T,o);X(t,e.attributes.texCoord0),a.push([z.UV0,new D(t.typedBuffer,t.elementCount,!0)]),u.push([z.UV0,i])}if(r(e.attributes.color)){const t=I(R,o);if(4===e.attributes.color.elementCount)e.attributes.color instanceof h?C(t,e.attributes.color,255):e.attributes.color instanceof R?Y(t,e.attributes.color):e.attributes.color instanceof w&&C(t,e.attributes.color,1/256);else{Z(t,255,255,255,255);const r=new j(t.buffer,0,4);e.attributes.color instanceof x?B(r,e.attributes.color,255):e.attributes.color instanceof j?ee(r,e.attributes.color):e.attributes.color instanceof M&&B(r,e.attributes.color,1/256)}a.push([z.COLOR,new D(t.typedBuffer,t.elementCount,!0)]),u.push([z.COLOR,i])}return{geometry:new W(t,a,u),vertexCount:o}}const ne=i();function ae(e){switch(e){case"BLEND":return U.Blend;case"MASK":return U.Mask;case"OPAQUE":case null:case void 0:return U.Opaque}}function ue(e,t){switch(t){case J.TRIANGLES:return N(e);case J.TRIANGLE_STRIP:return E(e);case J.TRIANGLE_FAN:return S(e)}}function le(e,t){for(let r=0;r<e.model.lods.length;++r){const s=e.model.lods[r];for(const i of s.parts){const s=i.attributes.normal;if(o(s))return;const g=i.attributes.position,b=g.count,h=p(),T=p(),w=p(),j=I(R,b),M=I(x,b),v=n(a(),i.transform);for(let o=0;o<b;o++){g.getVec(o,T),s.getVec(o,h),u(T,T,i.transform),l(w,T,t.center),c(w,w,t.radius);const n=w[2],a=m(w),p=Math.min(.45+.55*a*a,1);c(w,w,t.radius),null!==v&&u(w,w,v),f(w,w),r+1!==e.model.lods.length&&e.model.lods.length>1&&d(w,w,h,n>-1?.2:Math.min(-4*n-3.8,1)),M.setVec(o,w),j.set(o,0,255*p),j.set(o,1,255*p),j.set(o,2,255*p),j.set(o,3,255)}i.attributes.normal=M,i.attributes.color=j}}}export{te as fetch,oe as gltfToEngineResources,re as parseUrl};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"../../../../core/has.js";import{clamp as e,isPowerOfTwo as a}from"../../../../core/mathUtils.js";import{isSome as o,isNone as r}from"../../../../core/maybe.js";import{TextureEncoding as s,TextureUsage as t}from"./enums.js";import{RenderTexture as n}from"../../webgl-engine/core/material/RenderTexture.js";import{PBRSchematicMRRValues as l}from"../../webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{defaultMaskAlphaCutoff as i}from"../../webgl-engine/core/shaderLibrary/util/AlphaCutoff.js";import{getEllipsoidMode as u}from"../../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{
|
|
5
|
+
import has from"../../../../core/has.js";import{clamp as e,isPowerOfTwo as a}from"../../../../core/mathUtils.js";import{isSome as o,isNone as r}from"../../../../core/maybe.js";import{TextureEncoding as s,TextureUsage as t}from"./enums.js";import{RenderTexture as n}from"../../webgl-engine/core/material/RenderTexture.js";import{PBRSchematicMRRValues as l}from"../../webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{defaultMaskAlphaCutoff as i}from"../../webgl-engine/core/shaderLibrary/util/AlphaCutoff.js";import{getEllipsoidMode as u}from"../../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{TextureEncodingMimeType as c,CullFaceOptions as m,AlphaDiscardMode as d}from"../../webgl-engine/lib/basicInterfaces.js";import{Texture as g}from"../../webgl-engine/lib/Texture.js";import{TextureWrapMode as p}from"../../../webgl/enums.js";function h(e,a){const s=new Map,n=(e,a)=>{if(r(e))return-1;if(s.has(e.id)){const o=s.get(e.id);return o.usage|=a,o.id}const o=s.size;return s.set(e.id,{id:o,usage:a}),o},i=a.pbrMetallicRoughness,u=i&&i.baseColorFactor,c=a.emissiveFactor,d=null==a.normalTexture&&null==a.emissiveTexture&&null==a.occlusionTexture&&(!i||null==i.metallicRoughnessTexture&&1===i.roughnessFactor&&(1===i.metallicFactor||0===i.metallicFactor)),g=d?l[0]:i?i.metallicFactor:1,p=d?l[1]:i?i.roughnessFactor:1,h="mask"===a.alphaMode?t.Color|t.AlphaMask:t.Color,x={baseColorFactor:u?[u[0],u[1],u[2],u[3]]:[1,1,1,1],baseColorTextureId:n(i&&i.baseColorTexture,h),metallicRoughnessTextureId:n(i&&i.metallicRoughnessTexture,t.MetallicRoughness),metallicFactor:g,roughnessFactor:p},b={alphaMode:a.alphaMode,alphaCutoff:a.alphaCutoff,doubleSided:a.doubleSided,cullFace:"none"===a.cullFace?m.None:"back"===a.cullFace?m.Back:"front"===a.cullFace?m.Front:void 0,normalTextureId:n(a.normalTexture,t.Normal),emissiveTextureId:n(a.emissiveTexture,t.Emissive),occlusionTextureId:n(a.occlusionTexture,t.Occlusion),emissiveFactor:c?[c[0],c[1],c[2]]:[0,0,0],metallicRoughness:x,wrapTextures:!1,hasParametersFromSource:d},F=[];return s.forEach((({usage:a},r)=>{const s=o(e)&&e[r]&&e[r].formats,t=s?f(s.map((({name:e,format:a})=>({name:e,encoding:T[a]})))):[];F.push({id:r,usage:a,encodings:t})})),{material:b,textures:F}}function f(e){return e.sort(((e,a)=>e.encoding-a.encoding))}const T={ktx2:s.KTX2,basis:s.Basis,dds:s.DDS_S3TC,png:s.PNG,jpg:s.JPG,"ktx-etc2":s.KTX_ETC2},x={[c.KTX2_ENCODING]:s.Basis,[c.BASIS_ENCODING]:s.Basis,[c.DDS_ENCODING]:s.DDS_S3TC,"image/png":s.PNG,"image/jpg":s.JPG,"image/jpeg":s.JPG,"image/ktx":s.KTX_ETC2};function b(a){const o=a&&a.materialDefinitions?Object.keys(a.materialDefinitions)[0]:null,r=a&&a.textureDefinitions?Object.keys(a.textureDefinitions)[0]:null,s=o&&a.materialDefinitions[o],n=r&&a.textureDefinitions[r],l=F();if(null!=s){const a=s.params;a.diffuse&&(l.metallicRoughness.baseColorFactor=[a.diffuse[0],a.diffuse[1],a.diffuse[2],1]),null!=a.doubleSided&&(l.doubleSided=a.doubleSided,l.cullFace=a.doubleSided?m.None:m.Back),"none"!==a.cullFace&&"front"!==a.cullFace&&"back"!==a.cullFace||(l.cullFace="none"===a.cullFace?m.None:"back"===a.cullFace?m.Back:m.Front),a.transparency&&(l.metallicRoughness.baseColorFactor[3]=e(1-a.transparency,0,1)),(a.useVertexColorAlpha||l.metallicRoughness.baseColorFactor[3]<1)&&(l.alphaMode="blend")}const i=[];if(null!=n){const e=0;!n.wrap||"repeat"!==n.wrap[0]&&"repeat"!==n.wrap[1]||(l.wrapTextures=!0);let a=t.Color;"rgba"===n.channels&&(l.alphaMode="blend",a|=t.AlphaMask);const o=n.images.length-1,r=n.images[o],s=e=>e&&e.split("/").pop(),u=Array.isArray(n.encoding)?f(n.encoding.map(((e,a)=>({name:s(r.href[a]),encoding:x[e]||0})))):[{name:s(r.href),encoding:x[n.encoding]||0}];i.push({id:e,usage:a,encodings:u}),l.metallicRoughness.baseColorTextureId=e}return{material:l,textures:i}}const F=()=>({alphaMode:"opaque",alphaCutoff:i,doubleSided:!0,cullFace:m.None,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[.8,.8,.8,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6},wrapTextures:!1,hasParametersFromSource:!0});function C(e,o,s,n){if(r(e)||null==e.data)return null;const l=e.data,i=!(l instanceof HTMLImageElement)||a(l.width)&&a(l.height),u=n.renderingContext.parameters.maxMaxAnisotropy,c=s&&!n.capabilities.shaderTextureLOD?1:u,m=i&&!e.downsampled&&c>1,d=s||!o.wrapTextures?P:M,p=E(e.encoding),h=e.usage&t.Color?"opaque"===o.alphaMode?3:4:3;return new g(l,{mipmap:m,maxAnisotropy:c,encoding:p,wrap:d,components:h,noUnpackFlip:!0})}const P={s:p.CLAMP_TO_EDGE,t:p.CLAMP_TO_EDGE},M={s:p.REPEAT,t:p.REPEAT};function S(a,r,s,l,c,m){const g=m.rendererTextureUsage,p=e=>R(l,s,e&g),h=r.metallicRoughness.baseColorFactor,f=e(r.metallicRoughness.baseColorFactor[3],0,1);a.baseColor=[h[0],h[1],h[2],f],a.hasParametersFromSource=!!r.hasParametersFromSource,a.usePBR=m.usePBR,a.mrrFactors=[r.metallicRoughness.metallicFactor,r.metallicRoughness.roughnessFactor,r.hasParametersFromSource?.2:.5],a.emissiveFactor=r.emissiveFactor,a.isIntegratedMesh=m.isIntegratedMesh,a.textureAlphaCutoff="mask"===r.alphaMode?r.alphaCutoff:i,a.alphaDiscardMode="opaque"===r.alphaMode?d.Opaque:"mask"===r.alphaMode?d.Mask:d.MaskBlend;const T=[],x=p(t.Color|t.AlphaMask);o(x)&&(a.baseColorTexture=new n(c,x),T.push(a.baseColorTexture.loadPromise));const b=p(t.MetallicRoughness);o(b)&&(a.metallicRoughnessTexture=new n(c,b),T.push(a.metallicRoughnessTexture.loadPromise));const F=p(t.Emissive);o(F)&&(a.emissionTexture=new n(c,F),T.push(a.emissionTexture.loadPromise));const C=p(t.Occlusion);o(C)&&(a.occlusionTexture=new n(c,C),T.push(a.occlusionTexture.loadPromise));const P=p(t.Normal);return o(P)&&(a.normalTexture=new n(c,P),T.push(a.normalTexture.loadPromise)),a.commonMaterialParameters.hasSlicePlane=m.slicePlaneEnabled,a.commonMaterialParameters.doubleSided=r.doubleSided,a.commonMaterialParameters.cullFace=r.cullFace,a.ellipsoidMode=u(m.viewSpatialReference),Promise.all(T)}function D(e){const a=!!e.compressedTextureS3TC,o=!!e.compressedTextureETC,r=has("disable-feature:i3s-basis")?0:s.Basis|s.KTX2,t=s.JPG|s.PNG,n=r|s.DDS_S3TC;return t|(a?n:0)|(o?r:0)}function w(e,a){return e.find((e=>0!=(e.encoding&a)))}function R(e,a,s){if(r(e)||s===t.None)return null;for(let r=0;r<e.length;r++){const t=e[r];if(o(t)&&0!=(t.usage&s)){const e=a[r];return o(e)?e.id:null}}return null}function E(e){switch(e){case s.KTX2:return c.KTX2_ENCODING;case s.Basis:return c.BASIS_ENCODING;case s.DDS_S3TC:return c.DDS_ENCODING;case s.PNG:return"image/png";case s.JPG:return"image/jpeg";case s.KTX_ETC2:return"image/ktx";default:return""}}export{S as configureMaterial,C as createTexture,F as defaultMaterial,h as getMaterialAndTextures,b as getMaterialAndTexturesFromShared,D as getSupportedEncodings,w as selectEncoding};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as
|
|
5
|
+
import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../core/Accessor.js";import r from"../../../../core/Evented.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{c}from"../../../../chunks/vec4f64.js";import{projectBoundingSphere as n}from"../../../../geometry/projection.js";import{create as a,toRect as p}from"../../../../geometry/support/aaBoundingBox.js";import{create as i,intersects as u}from"../../../../geometry/support/aaBoundingRect.js";import{ForAllFeaturesReturnType as m}from"../II3SMeshView3D.js";const f=a();let l=class extends e{constructor(t){super(t),this.events=new r}forEach(t){this.forAllFeatures((e=>(t(e),m.CONTINUE)))}forEachBounds(t,e){const r=this.getFeatureExtent;for(const o of t)e(r(o,f))}forEachInBounds(t,e){this.forAllFeatures((r=>{const o=this.getFeatureExtent(r,h);return u(t,p(o,d))&&e(r),m.CONTINUE}),(e=>{if(n(e.node.mbs,this.sourceSpatialReference,y,this.viewSpatialReference),y[0]>=t[0]&&y[2]<=t[2]&&y[1]>=t[1]&&y[3]<=t[3])return m.CONTINUE;const r=Math.max(t[0],Math.min(y[0],t[2])),o=Math.max(t[1],Math.min(y[1],t[3])),s=y[0]-r,c=y[1]-o;return s*s+c*c<=y[3]*y[3]?m.CONTINUE:m.SKIP}))}};t([o({constructOnly:!0})],l.prototype,"featureAdapter",void 0),t([o({constructOnly:!0})],l.prototype,"forAllFeatures",void 0),t([o({constructOnly:!0})],l.prototype,"getFeatureExtent",void 0),t([o({constructOnly:!0})],l.prototype,"sourceSpatialReference",void 0),t([o({constructOnly:!0})],l.prototype,"viewSpatialReference",void 0),l=t([s("esri.views.3d.layers.i3s.I3SQueryFeatureStore")],l);const y=c(),h=a(),d=i();export{l as I3SQueryFeatureStore};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import r from"../../../core/Evented.js";import{isSome as o,unwrapOr as a}from"../../../core/maybe.js";import{when as i}from"../../../core/reactiveUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{afterDispatch as l}from"../../../core/accessorSupport/watch.js";import{f as p}from"../../../chunks/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../geometry/ellipsoidUtils.js";import m from"../../ViewAnimation.js";import{ViewingMode as d}from"../../ViewingMode.js";import{Constraints as h}from"./Constraints.js";import{AnimationController as u}from"./controllers/AnimationController.js";import{State as
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import r from"../../../core/Evented.js";import{isSome as o,unwrapOr as a}from"../../../core/maybe.js";import{when as i}from"../../../core/reactiveUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{afterDispatch as l}from"../../../core/accessorSupport/watch.js";import{f as p}from"../../../chunks/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../geometry/ellipsoidUtils.js";import m from"../../ViewAnimation.js";import{ViewingMode as d}from"../../ViewingMode.js";import{Constraints as h}from"./Constraints.js";import{AnimationController as u}from"./controllers/AnimationController.js";import{State as g}from"./controllers/CameraController.js";import{PropertiesPool as C}from"../support/PropertiesPool.js";import{Camera as y,PaddingSide as f}from"../webgl-engine/lib/Camera.js";import{RenderState as _}from"../../support/RenderState.js";let v=class extends t{constructor(){super(...arguments),this._propertiesPool=new C({camera:y},this),this._lastSeenCameraProjectionValues=new y,this.mode=_.ANIMATING,this.rasterPixelRatio=1,this.contentPixelRatio=1,this.events=new r,this.viewingMode=d.Global,this._cameraChanged=!1,this._updateQueue=new Array,this._processingUpdates=!1}init(e,t){this._set("viewingMode",e),this._set("spatialReference",t),this._set("constraints",new h({mode:this.viewingMode}))}exit(){this.cameraController=null,this._propertiesPool.destroy(),this._propertiesPool=new C({camera:y},this)}createInitialCamera(){if(this.viewingMode===d.Global){const e=c(this.spatialReference).radius;this.camera=new y({eye:p(4*e,0,0),center:p(e,0,0),up:p(0,0,1)})}else this.camera=new y({eye:p(0,0,100),center:p(0,0,0),up:p(0,1,0)})}get animation(){return this.cameraController instanceof u&&o(this.cameraController.viewAnimation)?this.cameraController.viewAnimation:null}get camera(){return this._get("camera")}set camera(e){e!==j&&j.copyFrom(e),j.computeUp(this.viewingMode),this.events.emit("before-camera-change",j);const t=this._get("camera");if(this._cameraProjectionChanged(this._lastSeenCameraProjectionValues,j)&&(this._lastSeenCameraProjectionValues.copyFrom(j),this.events.emit("camera-projection-changed",this._lastSeenCameraProjectionValues)),(!t||!t.equals(j))&&(this._set("camera",this._propertiesPool.get("camera").copyFrom(j)),this._cameraChanged=!t||!t.almostEquals(j),this._cameraChanged)){const e=l((()=>{this._cameraChanged=!1,e.remove()}))}}get pixelRatio(){return this.camera.pixelRatio}get contentCamera(){return a(this._contentCamera,this.camera)}set contentCamera(e){this._contentCamera=o(e)?e.clone():null}get fixedContentCamera(){return o(this._contentCamera)}get isGlobal(){return this.viewingMode===d.Global}get isLocal(){return this.viewingMode===d.Local}get navigating(){return!(!this.cameraController||!this.cameraController.isInteractive)}get stationary(){return!this._cameraChanged&&!this.navigating}get cameraController(){return this._get("cameraController")}set cameraController(e){this.stopActiveCameraController()?(e&&(this.removeHandles(P),this.addHandles(i((()=>e.state===g.Finished||e.state===g.Stopped),(()=>{this._set("cameraController",null),this.updateCamera((t=>e.onControllerEnd(t)))}),{sync:!0,once:!0}),P),e.onControllerStart(this.camera)),this._set("cameraController",e)):e&&(e.state=g.Rejected)}switchCameraController(e){return this.cameraController=e,e.state!==g.Rejected}stopActiveCameraController(){return!(this.cameraController&&!this.cameraController.stopController())}updateCamera(e){this._updateQueue.push(e),this._processUpdateQueue()}_processUpdateQueue(){if(0===this._updateQueue.length||this._processingUpdates)return;this._processingUpdates=!0;const e=this._updateQueue.shift();j.copyFrom(this._get("camera")),e(j),this.camera=j,this._processingUpdates=!1,this._processUpdateQueue()}_cameraProjectionChanged(e,t){return e.fov!==t.fov||(e.fullViewport[0]!==t.fullViewport[0]||e.fullViewport[1]!==t.fullViewport[1]||e.fullViewport[2]!==t.fullViewport[2]||e.fullViewport[3]!==t.fullViewport[3]||(e.padding[f.TOP]!==t.padding[f.TOP]||e.padding[f.RIGHT]!==t.padding[f.RIGHT]||e.padding[f.BOTTOM]!==t.padding[f.BOTTOM]||e.padding[f.LEFT]!==t.padding[f.LEFT]))}};e([s()],v.prototype,"mode",void 0),e([s({readOnly:!0,type:m})],v.prototype,"animation",null),e([s({type:y})],v.prototype,"camera",null),e([s({readOnly:!0})],v.prototype,"pixelRatio",null),e([s()],v.prototype,"rasterPixelRatio",void 0),e([s()],v.prototype,"contentPixelRatio",void 0),e([s({})],v.prototype,"_contentCamera",void 0),e([s({type:y})],v.prototype,"contentCamera",null),e([s({readOnly:!0})],v.prototype,"fixedContentCamera",null),e([s({readOnly:!0})],v.prototype,"constraints",void 0),e([s({readOnly:!0})],v.prototype,"events",void 0),e([s({readOnly:!0})],v.prototype,"isGlobal",null),e([s({readOnly:!0})],v.prototype,"isLocal",null),e([s({readOnly:!0})],v.prototype,"viewingMode",void 0),e([s({readOnly:!0})],v.prototype,"spatialReference",void 0),e([s()],v.prototype,"navigating",null),e([s()],v.prototype,"stationary",null),e([s()],v.prototype,"_cameraChanged",void 0),e([s()],v.prototype,"cameraController",null),v=e([n("esri.views.3d.state.ViewState")],v);const w=v,j=new y,P="ViewStateHandles";export{w as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Camera.js";import i from"../../../Viewpoint.js";import r from"../../../core/Accessor.js";import a from"../../../core/Logger.js";import{isNone as s,isSome as o,destroyMaybe as n}from"../../../core/maybe.js";import{watch as l,on as h,sync as p,when as c}from"../../../core/reactiveUtils.js";import{addFrameTask as d}from"../../../core/scheduling.js";import{createScreenPoint as m}from"../../../core/screenUtils.js";import{property as v}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{d as w}from"../../../chunks/vec3.js";import{d as g}from"../../../chunks/vec3f64.js";import{s as C}from"../../../chunks/vec4.js";import{c as y}from"../../../chunks/vec4f64.js";import _ from"../../../geometry/Extent.js";import f from"../../../geometry/Point.js";import{canProject as R}from"../../../geometry/support/webMercatorUtils.js";import{ViewingMode as x}from"../../ViewingMode.js";import{applyAll as P}from"../camera/constraintUtils.js";import{cameraOnContentAlongViewDirection as O,surfaceElevationBelowRenderLocation as T}from"../camera/intersectionUtils.js";import{ConstraintsManager as S}from"./ConstraintsManager.js";import{Frustum as b}from"./Frustum.js";import{GoToOperation as I}from"./GoToOperation.js";import{SurfaceCollisionCorrectionController as j}from"./controllers/SurfaceCollisionCorrectionController.js";import{internalToExternal as M,externalToInternal as E,toExtent as H,distanceToScale as L,scaleToZoom as N,fromExtent as B,OrientationMode as A,getObserverForPointAtDistance as U,scaleToDistance as D,zoomToScale as k}from"../support/cameraUtils.js";import{PropertiesPool as z}from"../support/PropertiesPool.js";import{fromCamera as G,toCamera as V}from"../support/viewpointUtils.js";import{Camera as F,PaddingSide as q}from"../webgl-engine/lib/Camera.js";import{RenderStateFeature as W}from"../webgl-engine/lib/RenderStateFeature.js";import{RenderState as J}from"../../support/RenderState.js";let K=class extends r{get camera(){const e=this._get("camera");if(!this.ready)return e;const t=M(this.view,this.view.state.camera,Z);return t&&e&&t.equals(e)?e:t.clone()}set camera(e){this._updatePropertyBeforeReady("camera",e)||(this.view.elevationProvider?.enableElevationCache(!0),this.setStateCamera(E(this.view,e),{applyConstraints:!1})||a.getLogger(this.declaredClass).error("#camera=","Invalid camera",e),this.view.elevationProvider?.enableElevationCache(!1))}get contentCamera(){const e=this._get("contentCamera");if(!this.ready)return e;const t=M(this.view,this.view.state.contentCamera,Z);return t&&e&&t.equals(e)?e:t.clone()}set contentCamera(e){if(this._updatePropertyBeforeReady("contentCamera",e))return;const t=E(this.view,e);s(t)?this.view.state.contentCamera=null:(this._updateElevation(t),this.view.state.contentCamera=t)}installContentCameraReset(e){if(this.removeHandles(ie),this.test.contentCameraResetState.clear(),!this.view.state.fixedContentCamera)return!1;const t=this.zoom,i=this.view.state.camera.distance**2,r=g(this.view.state.camera.center),a=e.sticky?this.contentCamera.clone():null;return this.addHandles([l((()=>this.contentCamera),(()=>{e.sticky||(this.removeHandles(ie),this.test.contentCameraResetState.clear())})),l((()=>this.zoom),(e=>{void 0!==e&&void 0!==t&&(this.test.contentCameraResetState.set("view.zoom",Math.abs(e-t)/2),Math.abs(e-t)>2?this.contentCamera=null:this.view.state.fixedContentCamera||(this.contentCamera=a))})),l((()=>this.view.state.camera),(e=>{const t=w(r,e.center);this.test.contentCameraResetState.set("camera.center",t/i),t>i?this.contentCamera=null:this.view.state.fixedContentCamera||(this.contentCamera=a)}))],ie),!0}get center(){return this.ready?this.view.pointsOfInterest.centerOnContent.location:this._get("center")}set center(e){this._updatePropertyBeforeReady("center",e)||(e?this.isCompatible(e)?this.setStateCamera(this._centerToCamera(e),{applyConstraints:!0})?this.view.pointsOfInterest.centerOnContent.runTask():a.getLogger(this.declaredClass).error("#center=","Invalid center",e):a.getLogger(this.declaredClass).error("#center=","Center has an incompatible spatial reference (center: "+(e.spatialReference?e.spatialReference.wkid:"none")+", view: "+this.view.spatialReference?.wkid+")",e):a.getLogger(this.declaredClass).error("#center=","Center may not be null or undefined"))}get extent(){if(!this.ready)return this._get("extent");const e=this.view,t=H(e,e.state.camera,e.pointsOfInterest.centerOnContent.renderLocation);return o(t)?t:this._get("extent")}set extent(e){this._updatePropertyBeforeReady("extent",e)||(e?this.isCompatible(e)?this.setStateCamera(this._extentToCamera(e),{applyConstraints:!0})||a.getLogger(this.declaredClass).error("#extent=","Invalid extent",e):a.getLogger(this.declaredClass).error("#extent=","Extent has an incompatible spatial reference (extent: "+(e.spatialReference?e.spatialReference.wkid:"none")+", view: "+this.view.spatialReference?.wkid+")",e):a.getLogger(this.declaredClass).error("#extent=","Extent may not be null or undefined"))}get frustum(){const e=this._propertiesPool.get("frustum");return e.renderCoordsHelper=this.view.renderCoordsHelper,e.update(this.view.state.camera),e}get hasInitialView(){return!!this.view.get("map.initialViewProperties.viewpoint")}get scale(){if(this.ready){const e=this.view.pointsOfInterest.centerOnContent;return L(this.view,e.distance,e.location.latitude)}return this._get("scale")}set scale(e){this._updatePropertyBeforeReady("scale",e)||this.setStateCamera(this._scaleToCamera(e),{applyConstraints:!0})||a.getLogger(this.declaredClass).error("#scale=","Invalid scale",e)}get padding(){if(!this.ready)return this._get("padding");const e=this.view.state.camera,t=e.padding,i=e.pixelRatio,r=this._get("padding"),a=Math.round(t[q.TOP]/i),s=Math.round(t[q.RIGHT]/i),o=Math.round(t[q.BOTTOM]/i),n=Math.round(t[q.LEFT]/i);return null!=r&&r.top===a&&r.right===s&&r.bottom===o&&r.left===n?r:{top:a,right:s,bottom:o,left:n}}set padding(e){this._updatePropertyBeforeReady("padding",e)||(this._paddingToArray(e,this.view.state.camera.pixelRatio,ee),this.view.state.updateCamera((e=>e.padding=ee)))}_paddingToArray(e,t,i){e?C(i,e.top||0,e.right||0,e.bottom||0,e.left||0):C(i,0,0,0,0);for(let r=0;r<4;r++)i[r]=Math.round(i[r]*t)}get screenCenter(){const e=this.padding;return m((this.view.width-(e.left+e.right))/2+e.left,(this.view.height-(e.top+e.bottom))/2+e.top)}get viewpoint(){return this.ready?G(this.view,this.camera):this._get("viewpoint")}set viewpoint(e){if(!this._updatePropertyBeforeReady("viewpoint",e))if(e)if(this.isCompatible(e))this.setStateCamera(this._viewpointToCamera(e),{applyConstraints:!e.camera})||a.getLogger(this.declaredClass).error("#viewpoint=","Invalid viewpoint",e);else{const t=o(e.camera)?e.camera.position:e.targetGeometry,i=o(t)&&t.spatialReference;a.getLogger(this.declaredClass).error("#viewpoint=","Viewpoint has an incompatible spatial reference (viewpoint: "+(i?i.wkid:"none")+", view: "+this.view.spatialReference?.wkid+")",e)}else a.getLogger(this.declaredClass).error("#viewpoint=","Viewpoint may not be null or undefined")}get zoom(){return this.ready?N(this.view,this.scale):this._get("zoom")}set zoom(e){this._updatePropertyBeforeReady("zoom",e)||void 0===e||this.setStateCamera(this._zoomToCamera(e),{applyConstraints:!0})||a.getLogger(this.declaredClass).error("#zoom=","Invalid zoom",e)}get _maximumPixelRatio(){return this.view?._stage?.renderer.isFeatureEnabled(W.NativePixelResolution)?this._windowDevicePixelRatio:this.view?.qualitySettings.maximumPixelRatio}get _devicePixelRatio(){return o(this._devicePixelRatioOverride)?this._devicePixelRatioOverride:Math.min(this._windowDevicePixelRatio,this._maximumPixelRatio)}get _idlePixelRatio(){return o(this._devicePixelRatioOverride)?this._devicePixelRatioOverride:this.view._stage.renderer.isFeatureEnabled(W.NativePixelResolution,J.IDLE)?this._windowDevicePixelRatio:Math.min(this._windowDevicePixelRatio,this.view.qualitySettings.maximumPixelRatio)}get _hidpiContent(){return this._devicePixelRatio<=this.view?.qualitySettings.maximumPixelRatio}constructor(e){super(e),this._propertiesPool=new z({frustum:b},this),this._cameraSetByUser=!1,this._gotoOperation=null,this.constraintsManager=null,this.ready=!1,this._windowDevicePixelRatio=1,this._devicePixelRatioOverride=null,this._cameraChangeTime=0,this._updatingIgnoreRenderState=!1,this.test={vsm:this,contentCameraResetState:new Map,setDevicePixelRatio:e=>this._devicePixelRatioOverride=e,renderState:null,get maximumPixelRatio(){return this.vsm._maximumPixelRatio},set updatingIgnoreRenderState(e){this.vsm._updatingIgnoreRenderState=e},get updatingIgnoreRenderState(){return this.vsm._updatingIgnoreRenderState||o(this.renderState)}}}initialize(){this._cameraChangeTime=performance.now(),this.addHandles([h((()=>this.view.state.events),"before-camera-change",(e=>e&&this._updateElevation(e))),l((()=>this.view.state?.camera),((e,t)=>this._cameraChangedHandler(e,t)),p)]),c((()=>this.view.state?.camera),(e=>this._updateElevation(e)),{once:!0,sync:!0}),this.addHandles([d({prepare:()=>this._prepareFrame()}),l((()=>this.view.state.cameraController),(()=>{this._cameraSetByUser=!0,this.removeHandles(te)})),h((()=>this.view.state.events),"camera-projection-changed",(()=>this.notifyChange("scale")))])}destroy(){this.exit(),this._propertiesPool=n(this._propertiesPool)}init(){this.constraintsManager=new S({view:this.view}),this._prepareFrame();const e=this._getInitialProperties();this._cameraSetByUser=!1,this._set("ready",!0);for(const t of e)this.set(t.name,t.value);if(!this._cameraSetByUser){const e=this.view.get("map.initialViewProperties.viewpoint")||this.view.initialExtent;e&&this.isCompatible(e)?this._setInitialView(e):this.view.state.viewingMode===x.Local&&this.addHandles(c((()=>this.view.basemapTerrain.ready),(()=>{this.removeHandles(te),this._setInitialView(this.view.dataExtent)}),{once:!0,initial:!0}),te)}}exit(){this._cancelGoToOperation(),this.ready&&(this._override("padding",this.padding),this._set("ready",!1),this._clearOverride("hasInitialView"),this._cameraSetByUser=!1,this.removeHandles(te),this.constraintsManager=n(this.constraintsManager))}async goTo(e,t){const i={animate:!0,...t};return o(this._gotoOperation)&&this._gotoOperation.abort(i.animate),this._gotoOperation=new I(e,i,this.view),this.view.resourceController.scheduler.stopFrame(),this._gotoOperation}debugSetCameraOnContent(){this.setStateCamera(O(this.view),{applyConstraints:!1})}step(e){const t=this.view.state,i=t?.cameraController;i&&(t.updateCamera((t=>i.stepController(e,t))),i.steppingFinished&&i.finishController())}_cancelGoToOperation(){o(this._gotoOperation)&&(this._gotoOperation.abort(),this._gotoOperation=null)}_getInitialProperties(){const e=new Set,t=[];for(const{propertyName:i,overrides:r}of X){const a=e.has(i),s=this._isOverridden(i);!a&&s&&t.push({name:i,value:this._get(i)}),this._clearOverride(i),(a||s)&&r.forEach((t=>e.add(t)))}return t}_setInitialView(e){if(s(e)||this._cameraSetByUser)return;if(e instanceof t)return void this.setStateCamera(E(this.view,e),{applyConstraints:!1});if(e instanceof i){if(e.targetGeometry instanceof _){const t=B(this.view,e.targetGeometry,0,.5,A.LOCKED);return void(o(t)&&this.setStateCamera(E(this.view,t),{applyConstraints:!0}))}const t={applyConstraints:!e.camera},i=this._viewpointToCamera(e);return void this.setStateCamera(i,t)}const r=B(this.view,e,0,.5,A.LOCKED);o(r)&&this.setStateCamera(E(this.view,r),{applyConstraints:!0})}_updatePropertyBeforeReady(e,t){return!this.ready&&(this._override(e,t),t&&Q.includes(e)&&this._override("hasInitialView",!0),!0)}isCompatible(e){return!s(e)&&(e instanceof i?e.camera?this.isCompatible(e.camera):this.isCompatible(e.targetGeometry):e instanceof t?this.isCompatible(e.position):e.spatialReference&&R(e.spatialReference,this.view.spatialReference))}_getPreservingHeadingTilt(e=Y){return this._cameraSetByUser?(e.heading=this.camera.heading,e.tilt=this.camera.tilt):(e.heading=0,e.tilt=.5),e}_centerPointAtDistanceToCamera(e,t,i=$){const{heading:r,tilt:a}=this._getPreservingHeadingTilt(),o=U(this.view,r,a,e,t,A.ADJUST);return s(o)?null:(i.copyFrom(this.view.state.camera),i.eye=o.eye,i.center=o.center,i.up=o.up,i)}_centerToCamera(e){const t=this.view.pointsOfInterest.centerOnContent;t.runTask();const i=t.distance;return this._centerPointAtDistanceToCamera(e,i)}_extentToCamera(e){const{heading:t,tilt:i}=this._getPreservingHeadingTilt(),r=B(this.view,e,t,i,A.ADJUST,Z);return r?E(this.view,r):null}_scaleToCamera(e){if(null==e)return null;const t=this.view.pointsOfInterest.centerOnContent;t.runTask();const i=t.renderLocation,r=t.location.latitude;if(null==r)return null;const a=D(this.view,e,r);return this._centerPointAtDistanceToCamera(i,a)}_zoomToCamera(e){return this._scaleToCamera(k(this.view,e))}_viewpointToCamera(e){return E(this.view,V(this.view,e))}setStateCamera(e,t){return!(s(e)||!this.view.state.stopActiveCameraController())&&(this._cameraSetByUser=!0,t.doNotCancelGoToOperation||this._cancelGoToOperation(),this.view.state.updateCamera((i=>{t.positionAndOrientationOnly?(i.eye=e.eye,i.center=e.center,i.up=e.up):i.copyFrom(e),t.applyConstraints&&P(this.view,i)})),t.applyConstraints||(this.view.state.cameraController=new j({view:this.view,desiredCamera:e})),!0)}_prepareFrame(){const{surface:e,canvas:t}=this.view;if(!e||!t)return;this._windowDevicePixelRatio=window.devicePixelRatio;const i=this._devicePixelRatio,r=Math.round(e.clientWidth*i),a=Math.round(e.clientHeight*i);if(0!==r&&0!==a&&(t.width===r&&t.height===a||(t.width=r,t.height=a),this.view.state)){const e=this.view.state.camera;e.fullWidth===r&&e.fullHeight===a&&e.pixelRatio===i||($.copyFrom(e),$.pixelRatio!==i&&(this._paddingToArray(this.padding,i,ee),$.padding=ee),$.fullWidth=r,$.fullHeight=a,$.pixelRatio=i,this.view.state.camera=$),this._updateRenderState(),this.view.state.idlePixelRatio=this._idlePixelRatio,this.view.state.hidpiContent=this._hidpiContent}}_updateElevation(e){const t=this.view.basemapTerrain&&this.view.basemapTerrain.spatialReference,i=this.view.renderCoordsHelper?.getAltitude(e.eye)??0,r=t?T(this.view,e.eye):0;e.relativeElevation=i-r}_updateRenderState(){o(this.test.renderState)?this.view.state.mode=this.test.renderState:this.view.animation?this.view.state.mode=J.ANIMATING:this.view.interacting?this.view.state.mode=J.INTERACTING:(this.view.state.mode===J.ANIMATING&&(this._cameraChangeTime=0),performance.now()-this._cameraChangeTime<=re?this.view.state.mode=J.INTERACTING:this.view.state.mode=J.IDLE)}_cameraChangedHandler(e,t){e&&t&&e.almostEquals(t)||(this._cameraChangeTime=performance.now(),this._updateRenderState())}};e([v({type:t,dependsOn:["view.state.camera","ready"]})],K.prototype,"camera",null),e([v({type:t,dependsOn:["view.state.contentCamera","ready"]})],K.prototype,"contentCamera",null),e([v({type:f})],K.prototype,"center",null),e([v({type:_})],K.prototype,"extent",null),e([v({readOnly:!0})],K.prototype,"frustum",null),e([v({readOnly:!0})],K.prototype,"hasInitialView",null),e([v({readOnly:!0,type:Boolean})],K.prototype,"ready",void 0),e([v({type:Number})],K.prototype,"scale",null),e([v()],K.prototype,"padding",null),e([v({readOnly:!0})],K.prototype,"screenCenter",null),e([v({constructOnly:!0})],K.prototype,"view",void 0),e([v({type:i})],K.prototype,"viewpoint",null),e([v({type:Number})],K.prototype,"zoom",null),e([v()],K.prototype,"_maximumPixelRatio",null),e([v()],K.prototype,"_devicePixelRatio",null),e([v({readOnly:!0})],K.prototype,"_idlePixelRatio",null),e([v({readOnly:!0})],K.prototype,"_hidpiContent",null),e([v()],K.prototype,"_windowDevicePixelRatio",void 0),e([v()],K.prototype,"_devicePixelRatioOverride",void 0),K=e([u("esri.views.3d.state.ViewStateManager")],K);const Q=["camera","viewpoint","extent","scale","center","zoom"],X=[{propertyName:"camera",overrides:["viewpoint"]},{propertyName:"viewpoint",overrides:["extent"]},{propertyName:"extent",overrides:["center","scale"]},{propertyName:"center",overrides:[]},{propertyName:"scale",overrides:["zoom"]},{propertyName:"zoom",overrides:[]},{propertyName:"padding",overrides:[]}],Y={heading:0,tilt:0},Z=new t,$=new F,ee=y(),te="pending-initial-view",ie="content-camera-reset",re=300,ae=100;export{ae as INTERACTING_TIMEOUT,K as ViewStateManager};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Camera.js";import i from"../../../Viewpoint.js";import r from"../../../core/Accessor.js";import a from"../../../core/Logger.js";import{isNone as s,isSome as n,destroyMaybe as o}from"../../../core/maybe.js";import{watch as l,on as h,sync as p,when as c}from"../../../core/reactiveUtils.js";import{addFrameTask as d}from"../../../core/scheduling.js";import{createScreenPoint as m}from"../../../core/screenUtils.js";import{property as v}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{d as g}from"../../../chunks/vec3.js";import{d as w}from"../../../chunks/vec3f64.js";import{s as y}from"../../../chunks/vec4.js";import{c as C}from"../../../chunks/vec4f64.js";import _ from"../../../geometry/Extent.js";import f from"../../../geometry/Point.js";import{canProject as R}from"../../../geometry/support/webMercatorUtils.js";import{ViewingMode as x}from"../../ViewingMode.js";import{applyAll as P}from"../camera/constraintUtils.js";import{cameraOnContentAlongViewDirection as S,surfaceElevationBelowRenderLocation as T}from"../camera/intersectionUtils.js";import{ConstraintsManager as O}from"./ConstraintsManager.js";import{Frustum as b}from"./Frustum.js";import{GoToOperation as I}from"./GoToOperation.js";import{SurfaceCollisionCorrectionController as j}from"./controllers/SurfaceCollisionCorrectionController.js";import{internalToExternal as M,externalToInternal as E,toExtent as A,distanceToScale as N,scaleToZoom as H,fromExtent as L,OrientationMode as B,getObserverForPointAtDistance as U,scaleToDistance as D,zoomToScale as V}from"../support/cameraUtils.js";import{PropertiesPool as k}from"../support/PropertiesPool.js";import{fromCamera as z,toCamera as G}from"../support/viewpointUtils.js";import{Camera as F,PaddingSide as q}from"../webgl-engine/lib/Camera.js";import{RenderFeature as W}from"../webgl-engine/lib/RenderFeature.js";import{RenderState as J}from"../../support/RenderState.js";let K=class extends r{get camera(){const e=this._get("camera");if(!this.ready)return e;const t=M(this.view,this.view.state.camera,Z);return t&&e&&t.equals(e)?e:t.clone()}set camera(e){this._updatePropertyBeforeReady("camera",e)||(this.view.elevationProvider?.enableElevationCache(!0),this.setStateCamera(E(this.view,e),{applyConstraints:!1})||a.getLogger(this.declaredClass).error("#camera=","Invalid camera",e),this.view.elevationProvider?.enableElevationCache(!1))}get contentCamera(){const e=this._get("contentCamera");if(!this.ready)return e;const t=M(this.view,this.view.state.contentCamera,Z);return t&&e&&t.equals(e)?e:t.clone()}set contentCamera(e){if(this._updatePropertyBeforeReady("contentCamera",e))return;const t=E(this.view,e);s(t)?this.view.state.contentCamera=null:(this._updateElevation(t),this.view.state.contentCamera=t)}installContentCameraReset(e){if(this.removeHandles(ie),this.test.contentCameraResetState.clear(),!this.view.state.fixedContentCamera)return!1;const t=this.zoom,i=this.view.state.camera.distance**2,r=w(this.view.state.camera.center),a=e.sticky?this.contentCamera.clone():null;return this.addHandles([l((()=>this.contentCamera),(()=>{e.sticky||(this.removeHandles(ie),this.test.contentCameraResetState.clear())})),l((()=>this.zoom),(e=>{void 0!==e&&void 0!==t&&(this.test.contentCameraResetState.set("view.zoom",Math.abs(e-t)/2),Math.abs(e-t)>2?this.contentCamera=null:this.view.state.fixedContentCamera||(this.contentCamera=a))})),l((()=>this.view.state.camera),(e=>{const t=g(r,e.center);this.test.contentCameraResetState.set("camera.center",t/i),t>i?this.contentCamera=null:this.view.state.fixedContentCamera||(this.contentCamera=a)}))],ie),!0}get center(){return this.ready?this.view.pointsOfInterest.centerOnContent.location:this._get("center")}set center(e){this._updatePropertyBeforeReady("center",e)||(e?this.isCompatible(e)?this.setStateCamera(this._centerToCamera(e),{applyConstraints:!0})?this.view.pointsOfInterest.centerOnContent.runTask():a.getLogger(this.declaredClass).error("#center=","Invalid center",e):a.getLogger(this.declaredClass).error("#center=","Center has an incompatible spatial reference (center: "+(e.spatialReference?e.spatialReference.wkid:"none")+", view: "+this.view.spatialReference?.wkid+")",e):a.getLogger(this.declaredClass).error("#center=","Center may not be null or undefined"))}get extent(){if(!this.ready)return this._get("extent");const e=this.view,t=A(e,e.state.camera,e.pointsOfInterest.centerOnContent.renderLocation);return n(t)?t:this._get("extent")}set extent(e){this._updatePropertyBeforeReady("extent",e)||(e?this.isCompatible(e)?this.setStateCamera(this._extentToCamera(e),{applyConstraints:!0})||a.getLogger(this.declaredClass).error("#extent=","Invalid extent",e):a.getLogger(this.declaredClass).error("#extent=","Extent has an incompatible spatial reference (extent: "+(e.spatialReference?e.spatialReference.wkid:"none")+", view: "+this.view.spatialReference?.wkid+")",e):a.getLogger(this.declaredClass).error("#extent=","Extent may not be null or undefined"))}get frustum(){const e=this._propertiesPool.get("frustum");return e.renderCoordsHelper=this.view.renderCoordsHelper,e.update(this.view.state.camera),e}get hasInitialView(){return!!this.view.get("map.initialViewProperties.viewpoint")}get scale(){if(this.ready){const e=this.view.pointsOfInterest.centerOnContent;return N(this.view,e.distance,e.location.latitude)}return this._get("scale")}set scale(e){this._updatePropertyBeforeReady("scale",e)||this.setStateCamera(this._scaleToCamera(e),{applyConstraints:!0})||a.getLogger(this.declaredClass).error("#scale=","Invalid scale",e)}get padding(){if(!this.ready)return this._get("padding");const e=this.view.state.camera,t=e.padding,i=e.pixelRatio,r=this._get("padding"),a=Math.round(t[q.TOP]/i),s=Math.round(t[q.RIGHT]/i),n=Math.round(t[q.BOTTOM]/i),o=Math.round(t[q.LEFT]/i);return null!=r&&r.top===a&&r.right===s&&r.bottom===n&&r.left===o?r:{top:a,right:s,bottom:n,left:o}}set padding(e){this._updatePropertyBeforeReady("padding",e)||(this._paddingToArray(e,this.view.state.camera.pixelRatio,ee),this.view.state.updateCamera((e=>e.padding=ee)))}_paddingToArray(e,t,i){e?y(i,e.top||0,e.right||0,e.bottom||0,e.left||0):y(i,0,0,0,0);for(let r=0;r<4;r++)i[r]=Math.round(i[r]*t)}get screenCenter(){const e=this.padding;return m((this.view.width-(e.left+e.right))/2+e.left,(this.view.height-(e.top+e.bottom))/2+e.top)}get viewpoint(){return this.ready?z(this.view,this.camera):this._get("viewpoint")}set viewpoint(e){if(!this._updatePropertyBeforeReady("viewpoint",e))if(e)if(this.isCompatible(e))this.setStateCamera(this._viewpointToCamera(e),{applyConstraints:!e.camera})||a.getLogger(this.declaredClass).error("#viewpoint=","Invalid viewpoint",e);else{const t=n(e.camera)?e.camera.position:e.targetGeometry,i=n(t)&&t.spatialReference;a.getLogger(this.declaredClass).error("#viewpoint=","Viewpoint has an incompatible spatial reference (viewpoint: "+(i?i.wkid:"none")+", view: "+this.view.spatialReference?.wkid+")",e)}else a.getLogger(this.declaredClass).error("#viewpoint=","Viewpoint may not be null or undefined")}get zoom(){return this.ready?H(this.view,this.scale):this._get("zoom")}set zoom(e){this._updatePropertyBeforeReady("zoom",e)||void 0===e||this.setStateCamera(this._zoomToCamera(e),{applyConstraints:!0})||a.getLogger(this.declaredClass).error("#zoom=","Invalid zoom",e)}get _pixelRatio(){return n(this._devicePixelRatioOverride)?this._devicePixelRatioOverride:this._usePhysicalPixelRendering?this._windowDevicePixelRatio:Math.min(this._windowDevicePixelRatio,this.view?.qualitySettings.maximumPixelRatio)}get _rasterPixelRatio(){return n(this._devicePixelRatioOverride)?this._devicePixelRatioOverride:this._usePhysicalPixelRenderingAny?this._windowDevicePixelRatio:Math.min(this._windowDevicePixelRatio,this.view.qualitySettings.maximumPixelRatio)}get _usePhysicalPixelRendering(){return this.view?._stage?.renderer.isFeatureEnabled(W.PhysicalPixelRendering)??!1}get _usePhysicalPixelRenderingAny(){const e=this.view?._stage?.renderer;return e&&(e.isFeatureEnabled(W.PhysicalPixelRendering,J.IDLE)||e.isFeatureEnabled(W.PhysicalPixelRendering,J.INTERACTING)||e.isFeatureEnabled(W.PhysicalPixelRendering,J.ANIMATING))}constructor(e){super(e),this._propertiesPool=new k({frustum:b},this),this._cameraSetByUser=!1,this._gotoOperation=null,this.constraintsManager=null,this.ready=!1,this._windowDevicePixelRatio=1,this._devicePixelRatioOverride=null,this._cameraChangeTime=0,this._updatingIgnoreRenderState=!1,this.test={viewStateManager:this,contentCameraResetState:new Map,setDevicePixelRatio:e=>this._devicePixelRatioOverride=e,renderState:null,get maximumPixelRatio(){return this.viewStateManager.view.qualitySettings.maximumPixelRatio},set updatingIgnoreRenderState(e){this.viewStateManager._updatingIgnoreRenderState=e},get updatingIgnoreRenderState(){return this.viewStateManager._updatingIgnoreRenderState||n(this.renderState)}}}initialize(){this._cameraChangeTime=performance.now(),this.addHandles([h((()=>this.view.state.events),"before-camera-change",(e=>e&&this._updateElevation(e))),l((()=>this.view.state?.camera),((e,t)=>this._cameraChangedHandler(e,t)),p)]),c((()=>this.view.state?.camera),(e=>this._updateElevation(e)),{once:!0,sync:!0}),this.addHandles([d({prepare:()=>this._prepareFrame()}),l((()=>this.view.state.cameraController),(()=>{this._cameraSetByUser=!0,this.removeHandles(te)})),h((()=>this.view.state.events),"camera-projection-changed",(()=>this.notifyChange("scale")))])}destroy(){this.exit(),this._propertiesPool=o(this._propertiesPool)}init(){this.constraintsManager=new O({view:this.view}),this._prepareFrame();const e=this._getInitialProperties();this._cameraSetByUser=!1,this._set("ready",!0);for(const t of e)this.set(t.name,t.value);if(!this._cameraSetByUser){const e=this.view.get("map.initialViewProperties.viewpoint")||this.view.initialExtent;e&&this.isCompatible(e)?this._setInitialView(e):this.view.state.viewingMode===x.Local&&this.addHandles(c((()=>this.view.basemapTerrain.ready),(()=>{this.removeHandles(te),this._setInitialView(this.view.dataExtent)}),{once:!0,initial:!0}),te)}}exit(){this._cancelGoToOperation(),this.ready&&(this._override("padding",this.padding),this._set("ready",!1),this._clearOverride("hasInitialView"),this._cameraSetByUser=!1,this.removeHandles(te),this.constraintsManager=o(this.constraintsManager))}async goTo(e,t){const i={animate:!0,...t};return n(this._gotoOperation)&&this._gotoOperation.abort(i.animate),this._gotoOperation=new I(e,i,this.view),this.view.resourceController.scheduler.stopFrame(),this._gotoOperation}debugSetCameraOnContent(){this.setStateCamera(S(this.view),{applyConstraints:!1})}step(e){const t=this.view.state,i=t?.cameraController;i&&(t.updateCamera((t=>i.stepController(e,t))),i.steppingFinished&&i.finishController())}_cancelGoToOperation(){n(this._gotoOperation)&&(this._gotoOperation.abort(),this._gotoOperation=null)}_getInitialProperties(){const e=new Set,t=[];for(const{propertyName:i,overrides:r}of X){const a=e.has(i),s=this._isOverridden(i);!a&&s&&t.push({name:i,value:this._get(i)}),this._clearOverride(i),(a||s)&&r.forEach((t=>e.add(t)))}return t}_setInitialView(e){if(s(e)||this._cameraSetByUser)return;if(e instanceof t)return void this.setStateCamera(E(this.view,e),{applyConstraints:!1});if(e instanceof i){if(e.targetGeometry instanceof _){const t=L(this.view,e.targetGeometry,0,.5,B.LOCKED);return void(n(t)&&this.setStateCamera(E(this.view,t),{applyConstraints:!0}))}const t={applyConstraints:!e.camera},i=this._viewpointToCamera(e);return void this.setStateCamera(i,t)}const r=L(this.view,e,0,.5,B.LOCKED);n(r)&&this.setStateCamera(E(this.view,r),{applyConstraints:!0})}_updatePropertyBeforeReady(e,t){return!this.ready&&(this._override(e,t),t&&Q.includes(e)&&this._override("hasInitialView",!0),!0)}isCompatible(e){return!s(e)&&(e instanceof i?e.camera?this.isCompatible(e.camera):this.isCompatible(e.targetGeometry):e instanceof t?this.isCompatible(e.position):e.spatialReference&&R(e.spatialReference,this.view.spatialReference))}_getPreservingHeadingTilt(e=Y){return this._cameraSetByUser?(e.heading=this.camera.heading,e.tilt=this.camera.tilt):(e.heading=0,e.tilt=.5),e}_centerPointAtDistanceToCamera(e,t,i=$){const{heading:r,tilt:a}=this._getPreservingHeadingTilt(),n=U(this.view,r,a,e,t,B.ADJUST);return s(n)?null:(i.copyFrom(this.view.state.camera),i.eye=n.eye,i.center=n.center,i.up=n.up,i)}_centerToCamera(e){const t=this.view.pointsOfInterest.centerOnContent;t.runTask();const i=t.distance;return this._centerPointAtDistanceToCamera(e,i)}_extentToCamera(e){const{heading:t,tilt:i}=this._getPreservingHeadingTilt(),r=L(this.view,e,t,i,B.ADJUST,Z);return r?E(this.view,r):null}_scaleToCamera(e){if(null==e)return null;const t=this.view.pointsOfInterest.centerOnContent;t.runTask();const i=t.renderLocation,r=t.location.latitude;if(null==r)return null;const a=D(this.view,e,r);return this._centerPointAtDistanceToCamera(i,a)}_zoomToCamera(e){return this._scaleToCamera(V(this.view,e))}_viewpointToCamera(e){return E(this.view,G(this.view,e))}setStateCamera(e,t){return!(s(e)||!this.view.state.stopActiveCameraController())&&(this._cameraSetByUser=!0,t.doNotCancelGoToOperation||this._cancelGoToOperation(),this.view.state.updateCamera((i=>{t.positionAndOrientationOnly?(i.eye=e.eye,i.center=e.center,i.up=e.up):i.copyFrom(e),t.applyConstraints&&P(this.view,i)})),t.applyConstraints||(this.view.state.cameraController=new j({view:this.view,desiredCamera:e})),!0)}_prepareFrame(){const{surface:e,canvas:t}=this.view;if(!e||!t)return;this._windowDevicePixelRatio=window.devicePixelRatio;const i=this._pixelRatio,r=Math.round(e.clientWidth*i),a=Math.round(e.clientHeight*i);if(0!==r&&0!==a&&(t.width===r&&t.height===a||(t.width=r,t.height=a),this.view.state)){const e=this.view.state.camera;e.fullWidth===r&&e.fullHeight===a&&e.pixelRatio===i||($.copyFrom(e),$.pixelRatio!==i&&(this._paddingToArray(this.padding,i,ee),$.padding=ee),$.fullWidth=r,$.fullHeight=a,$.pixelRatio=i,this.view.state.camera=$),this._updateViewState()}}_updateElevation(e){const t=this.view.basemapTerrain&&this.view.basemapTerrain.spatialReference,i=this.view.renderCoordsHelper?.getAltitude(e.eye)??0,r=t?T(this.view,e.eye):0;e.relativeElevation=i-r}_updateViewState(){n(this.test.renderState)?this.view.state.mode=this.test.renderState:this.view.animation?this.view.state.mode=J.ANIMATING:this.view.interacting?this.view.state.mode=J.INTERACTING:(this.view.state.mode===J.ANIMATING&&(this._cameraChangeTime=0),performance.now()-this._cameraChangeTime<=re?this.view.state.mode=J.INTERACTING:this.view.state.mode=J.IDLE),this.view.state.rasterPixelRatio=this._rasterPixelRatio,this.view.state.contentPixelRatio=Math.min(this._pixelRatio,this.view.qualitySettings.maximumPixelRatio)}_cameraChangedHandler(e,t){e&&t&&e.almostEquals(t)||(this._cameraChangeTime=performance.now(),this._updateViewState())}};e([v({type:t,dependsOn:["view.state.camera","ready"]})],K.prototype,"camera",null),e([v({type:t,dependsOn:["view.state.contentCamera","ready"]})],K.prototype,"contentCamera",null),e([v({type:f})],K.prototype,"center",null),e([v({type:_})],K.prototype,"extent",null),e([v({readOnly:!0})],K.prototype,"frustum",null),e([v({readOnly:!0})],K.prototype,"hasInitialView",null),e([v({readOnly:!0,type:Boolean})],K.prototype,"ready",void 0),e([v({type:Number})],K.prototype,"scale",null),e([v()],K.prototype,"padding",null),e([v({readOnly:!0})],K.prototype,"screenCenter",null),e([v({constructOnly:!0})],K.prototype,"view",void 0),e([v({type:i})],K.prototype,"viewpoint",null),e([v({type:Number})],K.prototype,"zoom",null),e([v({readOnly:!0})],K.prototype,"_pixelRatio",null),e([v({readOnly:!0})],K.prototype,"_rasterPixelRatio",null),e([v({readOnly:!0})],K.prototype,"_usePhysicalPixelRendering",null),e([v({readOnly:!0})],K.prototype,"_usePhysicalPixelRenderingAny",null),e([v()],K.prototype,"_windowDevicePixelRatio",void 0),e([v()],K.prototype,"_devicePixelRatioOverride",void 0),K=e([u("esri.views.3d.state.ViewStateManager")],K);const Q=["camera","viewpoint","extent","scale","center","zoom"],X=[{propertyName:"camera",overrides:["viewpoint"]},{propertyName:"viewpoint",overrides:["extent"]},{propertyName:"extent",overrides:["center","scale"]},{propertyName:"center",overrides:[]},{propertyName:"scale",overrides:["zoom"]},{propertyName:"zoom",overrides:[]},{propertyName:"padding",overrides:[]}],Y={heading:0,tilt:0},Z=new t,$=new F,ee=C(),te="pending-initial-view",ie="content-camera-reset",re=300,ae=100;export{ae as INTERACTING_TIMEOUT,K as ViewStateManager};
|