@arcgis/core 4.33.0-next.20250206 → 4.33.0-next.20250208
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/applications/Components/styleUtils.js +1 -1
- package/applications/Components/webStyleSymbolUtils.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/{5b20ee64248f2d5c937f.js → 08980b1ad3d5d67c6390.js} +1 -1
- package/assets/esri/core/workers/chunks/0a8e388e96af44deeabb.js +1 -0
- package/assets/esri/core/workers/chunks/{38cd7745b8ef1b8b6196.js → 12d6baeffd55a98a7c75.js} +1 -1
- package/assets/esri/core/workers/chunks/{b1f5344e57ee679a7e81.js → 140d0c4285c6978103ea.js} +7 -7
- package/assets/esri/core/workers/chunks/143a193fa3a6e645c8ac.js +1 -0
- package/assets/esri/core/workers/chunks/{2a7f5d09cdc0333fa4bd.js → 2611adb4f328f95ee508.js} +1 -1
- package/assets/esri/core/workers/chunks/2def7db73a776e759dae.js +1 -0
- package/assets/esri/core/workers/chunks/308ec51ff4a66f7fcb0d.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/{72cf9192292e5c85c6df.js → 32d3657dcae89b740f8b.js} +2 -2
- package/assets/esri/core/workers/chunks/{72cf9192292e5c85c6df.js.LICENSE.txt → 32d3657dcae89b740f8b.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/354531dc2f0dea2ad96f.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/35e4af82a08b4eadbfab.js +1 -0
- package/assets/esri/core/workers/chunks/369a2b8484a8807bde38.js +1 -0
- package/assets/esri/core/workers/chunks/4040158835f9036967cd.js +2 -0
- package/assets/esri/core/workers/chunks/{1a2e1a414e651e988435.js.LICENSE.txt → 4040158835f9036967cd.js.LICENSE.txt} +1 -6
- package/assets/esri/core/workers/chunks/53810519ff5922b42cd2.js +1 -0
- package/assets/esri/core/workers/chunks/{15f850c9a1154fc57e5a.js → 5721557a1d8eab23a55b.js} +1 -1
- package/assets/esri/core/workers/chunks/594d923400fd74881833.js +1 -0
- package/assets/esri/core/workers/chunks/{32f5f00aab55ef16dcf1.js → 5b85f9da022742f602e2.js} +1 -1
- package/assets/esri/core/workers/chunks/62a1d60ad4bf6469c4dd.js +1 -0
- package/assets/esri/core/workers/chunks/{bab541feca7ab4d3f993.js → 6ea02ff25f051c08e6c3.js} +1 -1
- package/assets/esri/core/workers/chunks/{81aa8cc289fd02ca4da6.js → 7058001bf66f9f3d5d45.js} +1 -1
- package/assets/esri/core/workers/chunks/{e8ae8a11d8439e2a66ad.js → 706f867a9034d62a8ef7.js} +1 -1
- package/assets/esri/core/workers/chunks/77764ca90bdd13ee2167.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/{1ab83753d9eec0463461.js → 7b367bb0ed9c218ca595.js} +1 -1
- package/assets/esri/core/workers/chunks/{8e334fa440ae542e2e34.js → 7e49ddb5a2182f2c9ca6.js} +1 -1
- package/assets/esri/core/workers/chunks/8191dd3d7451b2e7b95e.js +1 -0
- package/assets/esri/core/workers/chunks/8c32cee395da0a7b9a8e.js +1 -0
- package/assets/esri/core/workers/chunks/{48ecc5a74fecbb2b9c6f.js → 8d8f5f08d730270e1165.js} +1 -1
- package/assets/esri/core/workers/chunks/94225d92afbdb10dfedb.js +1 -0
- package/assets/esri/core/workers/chunks/94490937dca566fe2640.js +1 -0
- package/assets/esri/core/workers/chunks/{b9ce0049e27a3e1ed9f9.js → 9b2fab133786e5d47631.js} +1 -1
- package/assets/esri/core/workers/chunks/{28374a64790342e1b5ae.js → 9d61590c4d21c7421925.js} +1 -1
- package/assets/esri/core/workers/chunks/b21b152fa15896577242.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/{5a25cef6355fd20e44e7.js → b765670b47d209d7655a.js} +2 -2
- package/assets/esri/core/workers/chunks/{5a25cef6355fd20e44e7.js.LICENSE.txt → b765670b47d209d7655a.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/b97673755cd2cc5164e8.js +1 -0
- package/assets/esri/core/workers/chunks/bb9ab85a135d211637f6.js +1 -0
- package/assets/esri/core/workers/chunks/c26ffbff1115e76bcb0f.js +1 -0
- package/assets/esri/core/workers/chunks/c38c154062cd838dd144.js +1 -0
- package/assets/esri/core/workers/chunks/d29c3bf29fcd7fa31f1a.js +1 -0
- package/assets/esri/core/workers/chunks/d339dee99c4820b63f39.js +1 -0
- package/assets/esri/core/workers/chunks/de1f3c4b8000c2d73013.js +1 -0
- package/assets/esri/core/workers/chunks/{4decfae8bc5e80878bdd.js → de4384b5833a60e88e31.js} +1 -1
- package/assets/esri/core/workers/chunks/e37e5d2e233d7f6ccd52.js +314 -0
- package/assets/esri/core/workers/chunks/e4b3f2d5c43518b0cde7.js +1 -0
- package/assets/esri/core/workers/chunks/e5e3b6d00d27b5bb354f.js +1 -0
- package/assets/esri/core/workers/chunks/e93dea6b112ce8e2779b.js +1 -0
- package/assets/esri/core/workers/chunks/edb580ce96da6fd66503.js +1 -0
- package/assets/esri/core/workers/chunks/f14b318bab5efcf43419.js +1 -0
- package/assets/esri/core/workers/chunks/{24e47f748f0e4f815c6e.js → f32ca4381e804cc3481e.js} +1 -1
- package/assets/esri/core/workers/chunks/f9070edd8e0b2a57af79.js +1 -0
- package/assets/esri/themes/base/widgets/_ItemList.scss +6 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/ImageMaterial.glsl.js +4 -4
- package/geometry/Mesh.js +1 -1
- package/geometry/support/Indices.js +1 -1
- package/geometry/support/meshUtils/deduplicate.js +1 -1
- package/geometry/support/meshVertexSpaceUtils.js +1 -1
- package/geometry/support/triangulationUtils.js +1 -1
- package/interfaces.d.ts +61 -84
- package/layers/FeatureLayer.js +1 -1
- package/layers/SubtypeGroupLayer.js +1 -1
- package/layers/WCSLayer.js +1 -1
- package/layers/graphics/data/QueryEngineCapabilities.js +1 -1
- package/layers/graphics/sources/FeatureLayerSource.js +1 -1
- package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
- package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
- package/layers/graphics/sources/support/clientSideDefaults.js +1 -1
- package/layers/graphics/sources/support/sourceUtils.js +1 -1
- package/layers/mixins/BlendLayer.js +1 -1
- package/layers/mixins/FeatureLayerBase.js +1 -1
- package/layers/mixins/OperationalLayer.js +1 -1
- package/layers/mixins/operationalLayerModuleMap.js +1 -1
- package/layers/support/SubtypeSublayer.js +1 -1
- package/layers/support/arcadeUtils.js +1 -1
- package/layers/support/commonProperties.js +1 -1
- package/layers/support/layersCreator.js +1 -1
- package/package.json +2 -2
- package/portal/support/layersLoader.js +1 -1
- package/portal/support/loadUtils.js +1 -1
- package/rest/imageService.js +1 -1
- package/rest/support/ImageSampleParameters.js +1 -1
- package/rest/support/ImageSampleResult.js +1 -1
- package/rest/support/ImageVolumeResult.js +1 -1
- package/support/TablesMixin.js +1 -1
- package/support/arcadeUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/WebStyleSymbol.js +1 -1
- package/symbols/cim/cimAnalyzer.js +1 -1
- package/symbols/cim/fitVectorMarker.js +5 -0
- package/symbols/support/previewCIMSymbol.js +1 -1
- package/symbols/support/previewSymbol3D.js +1 -1
- package/symbols/support/previewWebStyleSymbol.js +1 -1
- package/symbols/support/styleUtils.js +1 -1
- package/symbols/support/symbolUtils.js +1 -1
- package/symbols/support/utils.js +1 -1
- package/symbols/support/webStyleAcceptedFormats.js +5 -0
- package/symbols/support/webStyleSymbolUtils.js +1 -1
- package/views/2d/engine/webgl/TextureManager.js +1 -1
- package/views/2d/layers/features/schema/SourceSchema.js +1 -1
- package/views/2d/layers/features/sources/FeatureSource.js +1 -1
- package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
- package/views/2d/layers/features/sources/strategies/DrillDownTileLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/PagedTileLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/ParquetLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/SnapshotLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/StreamLoadStrategy.js +1 -1
- package/views/3d/glTF/internal/resourceUtils.js +1 -1
- package/views/3d/layers/MediaLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DWebStyleSymbol.js +1 -1
- package/views/3d/layers/graphics/Labeler.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipeline.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorkerHandle.js +1 -1
- package/views/3d/layers/graphics/pipeline/PipelineCommand.js +1 -1
- package/views/3d/layers/graphics/pipeline/featureData/FeatureData.js +1 -1
- package/views/3d/layers/graphics/pipeline/featureData/processingUtils.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/DirectRenderer.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/FeaturePipelineRenderManager.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/LodRenderer.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/RenderCommandContext.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/RenderCommandEncoder.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/RenderGeometryBufferWriter.js +1 -1
- package/views/3d/layers/graphics/pipeline/symbolization/TestObjectSymbol.js +1 -1
- package/views/3d/layers/graphics/pipeline/symbolization/TestSymbol.js +1 -1
- package/views/3d/layers/graphics/pipeline/symbolization/UniqueValueFeatureRenderer.js +1 -1
- package/views/3d/layers/graphics/pipeline/symbolization/primitiveObjectUtils.js +1 -1
- package/views/3d/layers/graphics/pipeline/utils.js +5 -0
- package/views/3d/layers/graphics/webStyleUtils.js +1 -1
- package/views/3d/layers/graphics/wosrLoader.js +1 -1
- package/views/3d/webgl-engine/lib/GLTextureMaterial.js +1 -1
- package/views/3d/webgl-engine/lib/Texture.js +1 -1
- package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultBufferWriter.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/internal/bufferWriterUtils.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/shaders/ImageMaterial.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ImageMaterialTechnique.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/VisibleElements.js +1 -1
- package/widgets/Editor/components/FeatureList.js +1 -1
- package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/Feature/support/arcadeFeatureUtils.js +1 -1
- package/widgets/Sketch.js +1 -1
- package/widgets/support/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/07bff9e742f3e5877f3f.js +0 -1
- package/assets/esri/core/workers/chunks/1100d9d114287b6443e2.js +0 -1
- package/assets/esri/core/workers/chunks/1a2e1a414e651e988435.js +0 -2
- package/assets/esri/core/workers/chunks/287362f9af132fafe4de.js +0 -1
- package/assets/esri/core/workers/chunks/2adc533dadcb018a9755.js +0 -1
- package/assets/esri/core/workers/chunks/2ea5e5e6c4660a06b516.js +0 -1
- package/assets/esri/core/workers/chunks/3984bf01f055fc42bfbf.js +0 -1
- package/assets/esri/core/workers/chunks/41cd1a5c99ab3bbd1fb4.js +0 -1
- package/assets/esri/core/workers/chunks/5e7f16b312077ca8c18d.js +0 -1
- package/assets/esri/core/workers/chunks/6ec108bd955e064256b5.js +0 -1
- package/assets/esri/core/workers/chunks/6ef2514a6b7bbfb8e37d.js +0 -1
- package/assets/esri/core/workers/chunks/7b11bf5799ecb3640b48.js +0 -314
- package/assets/esri/core/workers/chunks/81efe1f47fd41b7a5cc1.js +0 -1
- package/assets/esri/core/workers/chunks/82d26884127ed772cc4b.js +0 -1
- package/assets/esri/core/workers/chunks/918bdba41fa470cf77fd.js +0 -1
- package/assets/esri/core/workers/chunks/91d2bdfa6e34c10b7f50.js +0 -1
- package/assets/esri/core/workers/chunks/92871ebb339a7b6ff29c.js +0 -1
- package/assets/esri/core/workers/chunks/991e0f619f1f81f94d56.js +0 -1
- package/assets/esri/core/workers/chunks/9a27824d94df702e6e28.js +0 -1
- package/assets/esri/core/workers/chunks/b3f9d7a676076a7557f5.js +0 -1
- package/assets/esri/core/workers/chunks/c1fd87af3129873369fd.js +0 -1
- package/assets/esri/core/workers/chunks/c4c2b94e5cee7b824093.js +0 -1
- package/assets/esri/core/workers/chunks/c85374360ac5e169af16.js +0 -1
- package/assets/esri/core/workers/chunks/c94ec324ecad77c53a87.js +0 -1
- package/assets/esri/core/workers/chunks/d175953337fa655dc6b0.js +0 -1
- package/assets/esri/core/workers/chunks/e26dc0c1654316bb1558.js +0 -1
- package/assets/esri/core/workers/chunks/fe817283bbcbca8fb296.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{throwIfAborted as e}from"../../../../../../core/promiseUtils.js";import{difference as t,union as s}from"../../../../../../core/SetUtils.js";import i from"../../../../../../layers/support/FieldsIndex.js";import{ParquetFile as a}from"../../../../../../libs/parquet/parquet.js";import{ALoadStrategy as r}from"./ALoadStrategy.js";import{FeatureSnapshotSourceChunk as l}from"./chunks/FeatureSnapshotSourceChunk.js";import{FeatureSetReaderJSON as o}from"../../support/FeatureSetReaderJSON.js";import{FeatureSetReaderParquet as n}from"../../support/FeatureSetReaderParquet.js";class m extends r{constructor(e,t,s,i){super(i),this._service=e,this._metadata=t,this._schema=s,this._chunkId=0,this._files=[],this._availableFields=new Set(s.mutable.availableFields);const{geometryInfo:a}=this._service;if("location"===a.type)this._availableFields.add(a.latitudeFieldName),this._availableFields.add(a.longitudeFieldName);else if(null!=a.multiscale&&a.multiscale.levels.length>=1){const e=a.multiscale.levels[0];this._availableFields.add(e.column)}else this._availableFields.add(a.primaryFieldName)}destroy(){for(const e of this._files)e.destroy()}get about(){return{willQueryAllFeatures:!0,willQueryFullResolutionGeometry:!0}}async updateFields(e){await this._promise;const i=new Set(e),a=t(i,this._availableFields);this._availableFields=s(a,this._availableFields),a.size&&await Promise.all(this._files.map((e=>{const t=Array.from(a).map((t=>e.metadata.getFieldIndex(t)));return e.inner.updateChunks(new Uint16Array(t))})))}async load(e){return null==this._promise&&(this._promise=this._download().then((()=>{this._loadHigherResGeometry()}))),this._promise}unload(e){}async addParquetFile(e){this._insert(e)}async _loadHigherResGeometry(){const{geometryInfo:e}=this._service;if("geometry"===e.type){if(!(null!=e.multiscale&&e.multiscale.levels.length>=1))return;await this.updateFields([e.primaryFieldName])}const t=Array.from(this._store.chunks());this._store.clear();for(const s of t)this._store.insert(s);this._store.refresh()}async _insert(t){const s=await a.create(t,{geometryInfo:this._service.geometryInfo,outSpatialReference:this._service.outSpatialReference,getCustomParameters:()=>this._schema.mutable.dataFilter.customParameters}),{geometryInfo:r}=this._service;e(this._options);const{fields:o,timeZoneByFieldName:m}=this._service.metadata.fieldsIndex,d=o.map((e=>({...e,index:s.metadata.getFieldIndex(e.name)}))),h=i.fromJSON({fields:d,timeZoneByFieldName:m}),u=new Uint16Array(Array.from(this._availableFields.values()).map((e=>h.get(e)?.index)).filter((e=>null!=e)));await s.inner.readChunksWithCallback(u,(e=>{const t=this._chunkId++,s=new n(this._metadata,h,r,e,t),i=new l(s,null,t,!1);this._store.insert(i)})),this._files.push(s)}async _download(){try{await Promise.all(this._service.source.urls.map((e=>this._insert(e))));const e=new l(o.empty(this._metadata),null,-1,!0);this._store.insert(e)}catch(e){throw console.error(e),e}}}export{m as ParquetLoadStrategy};
|
|
5
|
+
import{throwIfAborted as e}from"../../../../../../core/promiseUtils.js";import{difference as t,union as s}from"../../../../../../core/SetUtils.js";import i from"../../../../../../layers/support/FieldsIndex.js";import{ParquetFile as a}from"../../../../../../libs/parquet/parquet.js";import{ALoadStrategy as r}from"./ALoadStrategy.js";import{FeatureSnapshotSourceChunk as l}from"./chunks/FeatureSnapshotSourceChunk.js";import{FeatureSetReaderJSON as o}from"../../support/FeatureSetReaderJSON.js";import{FeatureSetReaderParquet as n}from"../../support/FeatureSetReaderParquet.js";class m extends r{constructor(e,t,s,i){super(i),this._service=e,this._metadata=t,this._schema=s,this._chunkId=0,this._files=[],this._availableFields=new Set(s.mutable.availableFields);const{geometryInfo:a}=this._service;if("location"===a.type)this._availableFields.add(a.latitudeFieldName),this._availableFields.add(a.longitudeFieldName);else if(null!=a.multiscale&&a.multiscale.levels.length>=1){const e=a.multiscale.levels[0];this._availableFields.add(e.column)}else this._availableFields.add(a.primaryFieldName)}destroy(){for(const e of this._files)e.destroy()}get about(){return{supportsDisplayFilter:!1,willQueryAllFeatures:!0,willQueryFullResolutionGeometry:!0}}async updateFields(e){await this._promise;const i=new Set(e),a=t(i,this._availableFields);this._availableFields=s(a,this._availableFields),a.size&&await Promise.all(this._files.map((e=>{const t=Array.from(a).map((t=>e.metadata.getFieldIndex(t)));return e.inner.updateChunks(new Uint16Array(t))})))}async load(e){return null==this._promise&&(this._promise=this._download().then((()=>{this._loadHigherResGeometry()}))),this._promise}unload(e){}async addParquetFile(e){this._insert(e)}async _loadHigherResGeometry(){const{geometryInfo:e}=this._service;if("geometry"===e.type){if(!(null!=e.multiscale&&e.multiscale.levels.length>=1))return;await this.updateFields([e.primaryFieldName])}const t=Array.from(this._store.chunks());this._store.clear();for(const s of t)this._store.insert(s);this._store.refresh()}async _insert(t){const s=await a.create(t,{geometryInfo:this._service.geometryInfo,outSpatialReference:this._service.outSpatialReference,getCustomParameters:()=>this._schema.mutable.dataFilter.customParameters}),{geometryInfo:r}=this._service;e(this._options);const{fields:o,timeZoneByFieldName:m}=this._service.metadata.fieldsIndex,d=o.map((e=>({...e,index:s.metadata.getFieldIndex(e.name)}))),h=i.fromJSON({fields:d,timeZoneByFieldName:m}),u=new Uint16Array(Array.from(this._availableFields.values()).map((e=>h.get(e)?.index)).filter((e=>null!=e)));await s.inner.readChunksWithCallback(u,(e=>{const t=this._chunkId++,s=new n(this._metadata,h,r,e,t),i=new l(s,null,t,!1);this._store.insert(i)})),this._files.push(s)}async _download(){try{await Promise.all(this._service.source.urls.map((e=>this._insert(e))));const e=new l(o.empty(this._metadata),null,-1,!0);this._store.insert(e)}catch(e){throw console.error(e),e}}}export{m as ParquetLoadStrategy};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../../../../../core/Error.js";import{throwIfAborted as e}from"../../../../../../core/promiseUtils.js";import r from"../../../../../../core/RandomLCG.js";import{AFetchLoadStrategy as o}from"./AFetchLoadStrategy.js";import{FeatureSnapshotSourceChunk as s}from"./chunks/FeatureSnapshotSourceChunk.js";import{FeatureSetReaderJSON as n}from"../../support/FeatureSetReaderJSON.js";class a extends o{constructor(t,e,o,s,n,a){super(t,e,o,n,a),this._random=new r(1e3),this._featureCount=s}get about(){return{willQueryAllFeatures:!0,willQueryFullResolutionGeometry:!0}}load(t){return null==this._promise&&(this._promise=this._downloadPages(this._featureCount)),this._promise}unload(t){}async _downloadPages(e){const r=Math.ceil(e/this._queryInfo.pageSize),o=Array.from({length:r},((t,e)=>e)).sort(((t,e)=>this._random.getInt()-this._random.getInt())),a=await Promise.all(o.map((t=>this._downloadPage(t)))),i=new s(n.empty(this._metadata),null,-1,!0);this._store.insert(i);const u=a.filter((t=>t));if(u.length)throw new t("featurelayer-query","Encountered errors when downloading data",{errors:u})}async _downloadPage(t){try{const r=this._queryInfo.createPagedQuery(t),o=await this._fetch(r,this._options,{chunkId:t.toString()}),n=new s(o,r.inner.toJSON(),t,!1);return e(this._options),this._store.insert(n),null}catch(r){return r}}}export{a as SnapshotLoadStrategy};
|
|
5
|
+
import t from"../../../../../../core/Error.js";import{throwIfAborted as e}from"../../../../../../core/promiseUtils.js";import r from"../../../../../../core/RandomLCG.js";import{AFetchLoadStrategy as o}from"./AFetchLoadStrategy.js";import{FeatureSnapshotSourceChunk as s}from"./chunks/FeatureSnapshotSourceChunk.js";import{FeatureSetReaderJSON as n}from"../../support/FeatureSetReaderJSON.js";class a extends o{constructor(t,e,o,s,n,a){super(t,e,o,n,a),this._random=new r(1e3),this._featureCount=s}get about(){return{supportsDisplayFilter:!1,willQueryAllFeatures:!0,willQueryFullResolutionGeometry:!0}}load(t){return null==this._promise&&(this._promise=this._downloadPages(this._featureCount)),this._promise}unload(t){}async _downloadPages(e){const r=Math.ceil(e/this._queryInfo.pageSize),o=Array.from({length:r},((t,e)=>e)).sort(((t,e)=>this._random.getInt()-this._random.getInt())),a=await Promise.all(o.map((t=>this._downloadPage(t)))),i=new s(n.empty(this._metadata),null,-1,!0);this._store.insert(i);const u=a.filter((t=>t));if(u.length)throw new t("featurelayer-query","Encountered errors when downloading data",{errors:u})}async _downloadPage(t){try{const r=this._queryInfo.createPagedQuery(t),o=await this._fetch(r,this._options,{chunkId:t.toString()}),n=new s(o,r.inner.toJSON(),t,!1);return e(this._options),this._store.insert(n),null}catch(r){return r}}}export{a as SnapshotLoadStrategy};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../../../core/Evented.js";import{handlesGroup as t}from"../../../../../../core/handleUtils.js";import"../../../../../../core/has.js";import{destroyMaybe as s}from"../../../../../../core/maybe.js";import{StreamFeatureManager as n}from"../../../../../../layers/graphics/data/StreamFeatureManager.js";import{createConnection as
|
|
5
|
+
import e from"../../../../../../core/Evented.js";import{handlesGroup as t}from"../../../../../../core/handleUtils.js";import"../../../../../../core/has.js";import{destroyMaybe as s}from"../../../../../../core/maybe.js";import{StreamFeatureManager as n}from"../../../../../../layers/graphics/data/StreamFeatureManager.js";import{createConnection as i}from"../../../../../../layers/graphics/sources/connections/createConnection.js";import{internalTimeReceivedField as o}from"../../../../../../layers/support/streamLayerUtils.js";import{StreamConnectionState as r}from"../StreamConnectionState.js";import{StreamFeatureStore as a}from"../StreamFeatureStore.js";import{ALoadStrategy as c}from"./ALoadStrategy.js";import{StreamSourceChunk as h}from"./chunks/StreamSourceChunk.js";class m extends c{constructor(t,s,i,c,h){super(i),this._service=t,this._dataFilter=s,this._streamOptions=c,this._metadata=h,this._connectionState=new r,this._forceRefresh=!1,this.events=new e;const{objectIdField:m,timeInfo:d}=this._metadata,{purgeOptions:_}=s;this._stagingStore=new a(this._metadata.weakCloneWithAdditionalFields([{name:o,alias:"timeReceived",type:"esriFieldTypeDate"}]),(e=>this.events.emit("features-updated",e))),this._manager=new n(this._stagingStore,m,d,_),this.connect()}destroy(){super.destroy(),this.disconnect()}get about(){return{supportsDisplayFilter:!1,willQueryAllFeatures:!1,willQueryFullResolutionGeometry:!1}}get connectionStatus(){return this._connectionState.connectionStatus}get errorString(){return this._connectionState?.errorString}async refresh(){const e=null!=this._chunk;this._manager.checkForUpdates()||!e||this._forceRefresh?(this._chunk&&this._store.remove(this._chunk),this._forceRefresh=!1,this._chunk=new h(this._stagingStore.reader),this._store.insert(this._chunk),this.events.emit("tick")):this.events.emit("tick")}async updateFields(e){throw new Error("Updating available fields not supported for StreamLayer")}async load(e){}unload(e){}disconnect(){this._connection=s(this._connection),this._connectionState.connection=null,this._handlesGroup?.remove()}connect(){if(null!=this._connection)return;const{geometryType:e,spatialReference:s}=this._metadata,{maxReconnectionAttempts:n,maxReconnectionInterval:o,geometryDefinition:r,definitionExpression:a,customParameters:c}=this._dataFilter;this._connection=i(this._service.source,s,this._streamOptions.outSR,e,a,r,n,o,c),this._handlesGroup=t([this._connection.on("data-received",(e=>this._onFeature(e))),this._connection.on("message-received",(e=>this._onWebSocketMessage(e)))]),this._connectionState.connection=this._connection}clear(){this._manager.checkForUpdates(),this._stagingStore.clear(),this._forceRefresh=!0}updateCustomParameters(e){this._connection?.updateCustomParameters(e)}sendMessageToSocket(e){this._connection?.sendMessageToSocket(e)}sendMessageToClient(e){this._connection?.sendMessageToClient(e)}_onWebSocketMessage(e){if("type"in e)switch(e.type){case"delete":if(e.objectIds)for(const t of e.objectIds)this._manager.removeById(t);if(e.trackIds)for(const t of e.trackIds)this._manager.removeByTrackId(t);break;case"clear":this.clear()}this.events.emit("message-received",e)}_onFeature(e){try{this._manager.add(e),this.events.emit("data-received",e)}catch(t){}}}export{m as StreamLoadStrategy};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"../../../../core/has.js";import{TextureEncodingMimeType as e}from"../../webgl-engine/lib/basicInterfaces.js";class t{constructor(t){this.data=t,this.type="encoded-mesh-texture",this.encoding=e.KTX2_ENCODING}}function
|
|
5
|
+
import has from"../../../../core/has.js";import{TextureEncodingMimeType as e}from"../../webgl-engine/lib/basicInterfaces.js";class t{constructor(t){this.data=t,this.type="encoded-mesh-texture",this.encoding=e.KTX2_ENCODING}}function n(e){return"encoded-mesh-texture"===e?.type}async function r(e){const t=new Blob([e]),n=await t.text();return JSON.parse(n)}async function o(n,r){if(r===e.KTX2_ENCODING)return new t(n);const o=new Blob([n],{type:r});let c=URL.createObjectURL(o);switch(r){case"image/jpeg":c+="#.jpg";break;case"image/png":c+="#.png"}const s=new Image;if(has("esri-iPhone"))return new Promise(((e,t)=>{const n=()=>{o(),e(s)},r=e=>{o(),t(e)},o=()=>{URL.revokeObjectURL(c),s.removeEventListener("load",n),s.removeEventListener("error",r)};s.addEventListener("load",n),s.addEventListener("error",r),s.src=c}));try{s.src=c,await s.decode()}catch(a){console.warn("Failed decoding HTMLImageElement")}return URL.revokeObjectURL(c),s}export{t as EncodedMeshTexture,o as imageFromBinaryData,n as isEncodedMeshTexture,r as jsonFromBinaryData};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import{makeHandle as r,handlesGroup as i,destroyHandle as n}from"../../../core/handleUtils.js";import"../../../core/has.js";import{isIterable as s}from"../../../core/iteratorUtils.js";import{getProjectiveTransform as a}from"../../../core/perspectiveUtils.js";import{debounce as o,isPromiseLike as d}from"../../../core/promiseUtils.js";import{watch as l,on as m,syncAndInitial as h}from"../../../core/reactiveUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import{create as g}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{toExtent as u}from"../../../geometry/support/aaBoundingRect.js";import{MediaElementView as y}from"../../../layers/support/MediaElementView.js";import{DrapeSourceType as _}from"./interfaces.js";import{LayerView3D as f}from"./LayerView3D.js";import{MediaLayerInteraction as E}from"./support/MediaLayerInteraction.js";import{drapedZ as
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Error.js";import{makeHandle as r,handlesGroup as i,destroyHandle as n}from"../../../core/handleUtils.js";import"../../../core/has.js";import{isIterable as s}from"../../../core/iteratorUtils.js";import{getProjectiveTransform as a}from"../../../core/perspectiveUtils.js";import{debounce as o,isPromiseLike as d}from"../../../core/promiseUtils.js";import{watch as l,on as m,syncAndInitial as h}from"../../../core/reactiveUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import{create as g}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{toExtent as u}from"../../../geometry/support/aaBoundingRect.js";import{MediaElementView as y}from"../../../layers/support/MediaElementView.js";import{DrapeSourceType as _}from"./interfaces.js";import{LayerView3D as f}from"./LayerView3D.js";import{MediaLayerInteraction as E}from"./support/MediaLayerInteraction.js";import{drapedZ as w}from"../terrain/OverlayRenderer.js";import{Attribute as v}from"../webgl-engine/lib/Attribute.js";import{ContentObjectType as b}from"../webgl-engine/lib/ContentObjectType.js";import{Geometry as D}from"../webgl-engine/lib/Geometry.js";import{DirtyState as R,DirtyOperation as j}from"../webgl-engine/lib/ModelDirtyTypes.js";import{Object3DHighlightStateID as I}from"../webgl-engine/lib/Object3DStateID.js";import{RenderGeometry as H}from"../webgl-engine/lib/RenderGeometry.js";import{Texture as G}from"../webgl-engine/lib/Texture.js";import{UpdatePolicy as T}from"../webgl-engine/lib/UpdatePolicy.js";import{VertexAttribute as A}from"../webgl-engine/lib/VertexAttribute.js";import{ImageMaterial as x}from"../webgl-engine/materials/ImageMaterial.js";import M from"../../layers/LayerView.js";import P from"../../layers/MediaLayerView.js";import{defaultHighlightName as S}from"../../support/HighlightDefaults.js";import{isInEffectiveScaleRange as L}from"../../support/layerViewUtils.js";import{TextureWrapMode as O}from"../../webgl/enums.js";let V=class extends(f(P(M))){get interactive(){return this._interaction.enabled}set interactive(e){this._interaction&&(this._interaction.enabled=e)}get selectedElement(){return this._interaction.selectedElement}set selectedElement(e){this._interaction&&(this._interaction.selectedElement=e)}get visibleAtCurrentScale(){return L(this.layer.effectiveScaleRange,this.view.scale)}constructor(e){super(e),this.type="media-3d",this.drapeSourceType=_.Features,this.updatePolicy=T.SYNC,this._uidToElement=new Map,this._highlightedElements=new Map,this._elementsInHighlightedId=new Map,this._renderElements=new Map,this._lastDrapingExtent=null,this._update=o((async(e,t,r)=>{const i=await this._collectMediaElements(e,t,r);this._synchronizeRenderElements(i)}),0);const{view:t,layer:r}=e;this._interaction=new E({view:t,layer:r}),this.addHandles(l((()=>this.interactionOptions),(e=>this._interaction.options=e),h))}initialize(){const{view:e,layer:t}=this;this._renderer=e.basemapTerrain.overlayManager.registerGeometryDrapeSource(this);const i=()=>this._updateWithLastDrapingExtent();this.addHandles([r((()=>e.basemapTerrain.overlayManager.unregisterDrapeSource(this))),m((()=>t.effectiveSource),"change",i),m((()=>t.effectiveSource),"refresh",i)]),this._updatingHandles.add((()=>this.suspended),i)}setDrapingExtent(e,t){this._lastDrapingExtent={overlays:e,spatialReference:t},this._updateWithLastDrapingExtent()}getHit(e){const t=this._uidToElement.get(e);return t?{type:"media",element:t,layer:this.layer}:null}highlight(e,t){const i=new I(t?.name??S),n=s(e)?Array.from(e):[e];this._elementsInHighlightedId.set(i,n);for(const r of n){const e=this._highlightedElements.get(r);e?e.add(i):this._highlightedElements.set(r,new Set([i]));const t=this._renderElements.get(r)?.getRenderData();t&&(t.renderGeometry.geometry.addHighlight(i),this._renderer.modifyGeometries([t.renderGeometry],R.HIGHLIGHT))}return r((()=>{const e=this._elementsInHighlightedId.get(i);if(e){for(const t of e){const e=this._highlightedElements.get(t);if(!e)continue;e.delete(i);const r=this._renderElements.get(t)?.getRenderData();r&&(r.renderGeometry.geometry.removeHighlight(i),this._renderer.modifyGeometries([r.renderGeometry],R.HIGHLIGHT)),0===e.size&&this._highlightedElements.delete(t)}this._elementsInHighlightedId.delete(i)}}))}isUpdating(){return super.isUpdating()||this._interaction.updating}_updateWithLastDrapingExtent(){if(null==this._lastDrapingExtent||this.suspended)return void(this._renderer&&this._synchronizeRenderElements(new Set));const{overlays:e,spatialReference:t}=this._lastDrapingExtent;this._updatingHandles.addPromise(this._update(e,t).catch((()=>{})))}async _collectMediaElements(e,t,r){const i=this.layer.effectiveSource;return null==i?new Set:new Set((await Promise.all(e.map((e=>i.queryElements(u(e.extent,t),{signal:r}))))).flat())}_synchronizeRenderElements(e){this._synchronizeRenderElementsRemove(e),this._synchronizeRenderElementsAdd(e)}_synchronizeRenderElementsRemove(e){this._renderElements.forEach(((t,r)=>{e.has(r)||(this._removeElement(r,t),this.emit("element-render-changed",{element:r}))}))}_synchronizeRenderElementsAdd(e){for(const t of e)this._renderElements.has(t)||this._createRenderElement(t)}_removeElement(e,t){this._destroyRenderData(e,t),this._renderElements.delete(e),this._uidToElement.delete(e.uid),t.handle.remove()}_createRenderElement(e){const t=new y({spatialReference:this.view.spatialReference,element:e}),r=new U(i([this._updatingHandles.add((()=>e.opacity),(e=>r.getRenderData()?.material.setParameters({opacity:e}))),this._updatingHandles.add((()=>t.coords),(()=>{r.data?this._updateGeometry(t,r):this._initializeRenderData(t,r)})),this._updatingHandles.add((()=>e.content),(()=>this._initializeRenderData(t,r))),n(t)]));this._renderElements.set(e,r),this._uidToElement.set(e.uid,e),this._updatingHandles.addPromise(e.load().catch((()=>{}))),this._initializeRenderData(t,r)}_initializeRenderData(e,t){const{coords:r,element:i}=e,{contentWidth:n,contentHeight:s}=i;if(null==r||null==i.content)return void this._destroyRenderData(i,t);if(t.data)return;const a=this._createTexture(i.content),o=a.load(this.view._stage.renderView.renderingContext),l=()=>{this.view._stage.add(a);const e=new x({textureId:a.id,opacity:i.opacity,perspectiveInterpolation:!0}),o=this._getPositionAttributeArray(r),d=[0,0,1,0,1,1,0,1],l=this._getPerspectiveDivideAttributeArray(o,n,s),m=[0,1,2,0,2,3],h=new D(e,[[A.POSITION,new v(o,m,3,!0)],[A.UV0,new v(d,m,2,!0)],[A.PERSPECTIVEDIVIDE,new v(l,m,1,!0)]]),c=new H(h,{layerUid:this.layer.uid,graphicUid:i.uid}),p=this._highlightedElements.get(i);p?.forEach((e=>c.geometry.addHighlight(e))),this._renderer.addGeometries([c],j.ADD),t.data=new C(c,a,e),this.emit("element-render-changed",{element:i})};d(o)?(t.data=a,this._updatingHandles.addPromise(o),o.then(l).catch((()=>a.dispose()))):l()}_updateGeometry(e,t){const{coords:r,element:i}=e;if(null==r||null==i.content)return void this._destroyRenderData(i,t);const n=t.getRenderData();if(!n)return;const s=this._getPositionAttributeArray(r);n.renderGeometry.geometry.setAttributeData(A.POSITION,s);const a=this._getPerspectiveDivideAttributeArray(s,i.contentWidth,i.contentHeight);n.renderGeometry.geometry.setAttributeData(A.PERSPECTIVEDIVIDE,a),n.renderGeometry.geometry.invalidateBoundingInfo(),this._renderer.modifyGeometries([n.renderGeometry],R.GEOMETRY),this.emit("element-render-changed",{element:i})}_getPositionAttributeArray(e){const[t,r,i,n]=e.rings[0];return[t[0],t[1],w,n[0],n[1],w,i[0],i[1],w,r[0],r[1],w]}_getPerspectiveDivideAttributeArray(e,t,r){a(z,[0,0,t,0,t,r,0,r],[e[0],e[1],e[3],e[4],e[6],e[7],e[9],e[10]]);const i=z[6]/z[8]*t,n=z[7]/z[8]*r;return[1,1+i,1+i+n,1+n]}_destroyRenderData(e,t){const r=t.data;if(null==r)return;if(t.data=null,r?.type===b.Texture)return void r.dispose();const i=r.texture;i.unload(),this.view._stage.remove(i),this._renderer.removeGeometries([r.renderGeometry],j.REMOVE),this.emit("element-render-changed",{element:e})}_createTexture(e){const r=e instanceof HTMLImageElement?e.naturalWidth:e.width,i=e instanceof HTMLImageElement?e.naturalHeight:e.height;if("getFrame"in e)throw new t("media-layer-view-3d","animation is not supported");return new G(e,{wrap:{s:O.CLAMP_TO_EDGE,t:O.CLAMP_TO_EDGE},preMultiplyAlpha:!0,width:r,height:i,mipmap:!0,updateCallback:()=>this.view.basemapTerrain.overlayManager.requestRender()})}get test(){}};e([c({readOnly:!0})],V.prototype,"type",void 0),e([c()],V.prototype,"layer",void 0),e([c()],V.prototype,"interactive",null),e([c()],V.prototype,"selectedElement",null),e([c({readOnly:!0})],V.prototype,"visibleAtCurrentScale",null),V=e([p("esri.views.3d.layers.MediaLayerView3D")],V);const z=g();class U{constructor(e){this.handle=e}getRenderData(){return this.data?.type===b.Texture?null:this.data}}class C{constructor(e,t,r){this.renderGeometry=e,this.texture=t,this.material=r,this.type="RenderData"}}const W=V;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.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{normalFromMat4 as r,fromMat4 as o}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as a,multiply as s,invert as i,getTranslation as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c,IDENTITY as u,clone as m}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as f}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{i as p,g as h,h as d,t as g,q as x,n as _,b as T,f as b,d as y,e as v}from"../../../../chunks/vec32.js";import{ZEROS as w,ONES as R,create as M}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as j}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as A}from"../../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as C}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as P}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToPoint as E}from"../../../../geometry/projection/projectVectorToPoint.js";import{create as O,fromBuffer as I,intersectsClippingArea as N}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as S}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as U,getContinuousIndexArray as B}from"../../../../geometry/support/Indices.js";import F from"../../../../geometry/support/MeshComponent.js";import D from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import G from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as L,isAbsoluteVertexSpace as V}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as $,isPlateCarree as H}from"../../../../geometry/support/spatialReferenceUtils.js";import{t as k}from"../../../../chunks/vec3.js";import{transformNormal as q,transformVectorENUPlateCarree as z,VectorType as W,transformVectorWMPlateCarree as Y,projectNormalToPCPF as J,transformTangent as K,projectTangentToPCPF as Q}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as X}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{makeDehydratedPoint as Z}from"../../../../layers/graphics/dehydratedPoint.js";import{MeshTransformUpdateAction as ee}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as te}from"../../../ViewingMode.js";import{isEncodedMeshTexture as re}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as oe}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as ne}from"./ElevationAligners.js";import{needsElevationUpdates3D as ae,evaluateElevationInfoAtPoint as se}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as ie}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as le}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as ce}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as ue,MeshFastUpdateProcessor as me}from"./MeshFastUpdateProcessor.js";import{createMaterial as fe}from"../support/edgeUtils.js";import{parseColorMixMode as pe,encodeSymbolColor as he}from"../support/symbolColorUtils.js";import{debugFlags as de}from"../../support/debugFlags.js";import{Attribute as ge}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as xe,CullFaceOptions as _e}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as Te}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as be}from"../../webgl-engine/lib/Geometry.js";import{Object3D as ye}from"../../webgl-engine/lib/Object3D.js";import{Texture as ve}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as we}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as Re}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as Me}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as je,advancedMRRFactors as Ae,schematicMRRFactors as Ce}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as Pe}from"../../../webgl/enums.js";const Ee=["mesh"];class Oe extends ce{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new ue,this._fastUpdateProcessor=new me,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){de.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new Me({color:[1,0,1,1]}),this._debugTangentNormalMaterial=new Me({color:[1,.5,0,1]}),this._debugFaceNormalMaterial=new Me({color:[0,1,1,1]}))}destroy(){super.destroy(),this._textures.forEach((e=>e.unload())),this._context.stage.removeMany(this._materialInfoCache.materials),this._context.stage.removeMany(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy(this._context.stage)}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Ee,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache,this._context)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>t(e)?.layerOpacityChanged(r,this._context.isAsync)))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,ae)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters((({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync))),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters((({material:t})=>t.setParameters({usePBR:e}))),!0}updateTransform(e,t,r,o){if(!e.fastTransformUpdatesAllowed)return!1;const n=e.fastTransformUpdatesEnabled;switch(o){case ee.EnableFastUpdates:if(n)return!0;break;case ee.DisableFastUpdates:if(!n)return!0;break;default:if(!n)return!!this.updateTransform(e,t,r,ee.EnableFastUpdates)&&(e.autoDisableFastTransformUpdates((()=>this.updateTransform(e,t,r,ee.DisableFastUpdates))),!0)}const a=this._context.renderCoordsHelper.spatialReference,s=ot,{origin:i,transform:l}=r;if(!C(t,p(Xe,i.x,i.y,i.z??0),s,a))return!1;switch(o){case ee.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case ee.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case ee.UpdateFastLocalOrigin:e.updateFastLocalOrigin(s,l,this._context.localOriginFactory)}const{elevationContext:c}=e;c.centerPointInElevationSR=this._getCenterPointInElevationSR(s);const{elevationProvider:u,renderCoordsHelper:m}=this._context,f=(e,t)=>se(e,u,c,m,t);return e.alignedSampledElevation=ne(e,c,u.spatialReference,f,m,s),e.updateTransform(s,l,this._context.isAsync),e.updateAutoDisableFastTransformUpdates((()=>this.updateTransform(e,t,r,ee.DisableFastUpdates))),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,n=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:n,uid:`vc:${o},vt:${n},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:n,colorTexture:a,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,f=We(n),p=We(a),h=Ye(s),d=We(i),g=Ye(l);if(o.color=n,o.colorTexture=a,o.normalTexture=i,o.uid=`${o.uid},cmuid:${f},ctmuid:${p},cttuid:${h},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof D){const{metallic:e,roughness:r,metallicRoughnessTexture:n,metallicRoughnessTextureTransform:a,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:f}=t.material,p=We(n),h=Ye(a),d=We(i),g=We(c),x=Ye(u),_=We(m),T=Ye(f);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=n,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=Ve(s),o.normalTextureTransform=Ve(l),o.emissiveTextureTransform=Ve(u),o.occlusionTextureTransform=Ve(f),o.metallicRoughnessTextureTransform=Ve(a),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${p},mrtt:${h},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${T}`}return o}_getInternalTextureId(e){const t=this._getInternalTexture(e,xe.Opaque);return t?.id}_getInternalTexture(e,t){const r=ze(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let n=this._textures.get(o);if(!n){let a=null;const s=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,i={wrap:$e(e.wrap),noUnpackFlip:!0,maxAnisotropy:s,mipmap:s>1};re(r)?(a=r.data,i.preMultiplyAlpha=!1,i.encoding=r.encoding):(a=r,i.preMultiplyAlpha=t!==xe.Opaque,i.downsampleUncompressed=this._context.graphicsCoreOwner.view.qualitySettings.graphics3D.uncompressedTextureDownsamplingEnabled),n=new ve(a,i),this._textures.set(o,n),n.load(this._context.stage.renderView.renderingContext),this._context.stage.add(n),n.events.on("unloaded",(()=>{this._textures.delete(o)}))}return n}_setInternalMaterialTextureParameters(t,r){if(null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture))}_setInternalMaterialParameters(e,t){null!=e.color&&qe(e.color,t),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=oe(e.colorTextureTransform),t.normalTextureTransformMatrix=oe(e.normalTextureTransform);const r=null!=e.normalTextureTransform?.scale?e.normalTextureTransform?.scale:f;t.scale=[r[0],r[1]],t.occlusionTextureTransformMatrix=oe(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=oe(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=oe(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=this.symbolLayer.material?.colorMixMode??null;if(r)t.externalColor=j;else{const r=this.symbolLayer.material?.color??null;r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=j)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_getOrCreateMaterial(t,r){const o=r.material?.color,n=r.material?.colorTexture,a=r.material?.alphaMode,s="blend"===a,i=!("opaque"===a)&&(ke(t)||null!=o&&o.a<1||n?.transparent||s),l=this._materialProperties(t,r,i),c=this._materialInfoCache.byUid(l.uid);if(c)return this._setInternalMaterialTextureParameters(l,c.material.parameters),c.material;const u={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=je({normalTexture:l.normalTexture,metallicRoughnessTexture:l.metallicRoughnessTexture,metallicFactor:l.metallic,roughnessFactor:l.roughness,emissiveTexture:l.emissiveTexture,emissiveFactor:e.toUnitRGB(l.emissiveColor),occlusionTexture:l.occlusionTexture}),f={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:w,diffuse:R,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:_e.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};f.mrrFactors=m?Ce:[l.metallic,l.roughness,Ae[2]],r.material&&(f.doubleSided=r.material.doubleSided,f.cullFace=r.material.doubleSided?_e.None:_e.Back,f.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(f),this._setMaterialTransparentParameter(f,u),this._setInternalMaterialParameters(l,f);const p=new Re(f,this._context);return u.material=p,this._materialInfoCache.set(l.uid,u),this._context.stage.add(p),p}_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?xe.MaskBlend:xe.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?xe.Opaque:"mask"===t.alphaMode?xe.Mask:xe.Blend}_createFaceDebugNormals(e,t){const o=t.length,a=e.spatialReference.isGeographic?20015077/180:1,s=.1*Math.max(e.extent.width*a,e.extent.height*a,e.extent.zmax-e.extent.zmin),i=[],l=[],c=t[0].transformation,u=r(n(),c);for(let r=0;r<o;r++){const e=t[r].attributes.get(we.POSITION);if(!e)continue;const o=e.data,n=e.indices;for(let t=0;t<n.length;t+=3)Ge(o,n,t,tt),De(o,n,t,Xe,Ze,et),h(Xe,Xe,Ze),h(Xe,Xe,et),d(Xe,Xe,1/3),g(Xe,Xe,c),i.push(...Xe),x(tt,tt,u),_(tt,tt),T(Xe,Xe,tt,s),i.push(...Xe),l.push(l.length),l.push(l.length)}return i.length?new be(this._debugFaceNormalMaterial,[[we.POSITION,new ge(i,l,3,!0)]],null,Te.Line):null}_createPerVertexDebugVectors(e,t,a,s,i){const l=t.length,c=e.spatialReference.isGeographic?20015077/180:1,u=.1*i*Math.max(e.extent.width*c,e.extent.height*c,e.extent.zmax-e.extent.zmin),m=[],f=[],h=t[0].transformation,d=r(n(),h);a===we.TANGENT&&o(d,h);for(let r=0;r<l;r++){const e=t[r],o=e.attributes.get(we.POSITION),n=e.attributes.get(a);if(!o||!n)continue;const s=o.data,i=o.indices,l=n.data,c=n.indices;for(let t=0;t<i.length;t++){const e=3*i[t],r=c[t]*n.stride;p(Xe,s[e+0],s[e+1],s[e+2]),g(Xe,Xe,h),m.push(...Xe),p(Ze,l[r+0],l[r+1],l[r+2]),x(Ze,Ze,d),_(Ze,Ze),T(Xe,Xe,Ze,u),m.push(...Xe),f.push(f.length),f.push(f.length)}}return m.length?new be(s,[[we.POSITION,new ge(m,f,3,!0)]],null,Te.Line):null}_createAs3DShape(e,t,r,o){const n=e.geometry;if("mesh"!==n.type)return null;const a=this._createGeometryInfo(n,t,o);if(null==a)return null;const{geometries:s,objectTransformation:i}=a;if(de.DRAW_MESH_GEOMETRY_NORMALS){const e=this._createPerVertexDebugVectors(n,s,we.NORMAL,this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(n,s,we.TANGENT,this._debugTangentNormalMaterial,.5),r=this._createFaceDebugNormals(n,s);e&&s.push(e),t&&s.push(t),r&&s.push(r)}const l=new ye({geometries:s,layerUid:this._context.layer.uid,graphicUid:o,isElevationSource:!0});l.transformation=i;const c=fe(this.symbolLayer,{opacity:this._getLayerOpacity()}),u=c?new le(s[0].material,c,this._context.slicePlaneEnabled):null,m=new ie(this,l,s,null,null,ne,r,u);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=ae(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,m.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(n),r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:f,renderCoordsHelper:p}=this._context,h=(e,t)=>se(e,f,r,p,t);return m.alignedSampledElevation=ne(m,r,f.spatialReference,h,p),m}_fastTransformUpdatesAllowed(e){const{vertexSpace:t,spatialReference:r}=e;if(!L(t))return!1;const{type:o}=t,{view:n}=this._context.graphicsCoreOwner,{viewingMode:a}=n.state,s=n.spatialReference;return a===te.Global&&"local"===o||a===te.Local&&$(s,r)&&"georeferenced"===o&&!r.isGeographic}_getCenterPointInElevationSR(e){const t=Z(0,0,0,this._context.elevationProvider.spatialReference??null);return E([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_passthroughReprojectionInfo(e){return e.reprojection===st.NONE&&!!e.objectTransformation}_createPositionBuffer(e,t){const r=e.vertexAttributes.position;let o,n=r;if(t.reprojection===st.NONE)return{position:n,georeferencedPositionBuffer:o};const a=t.reprojection===st.RENDER?t.transformBeforeProject:null;a&&(n=k(new Float64Array(n.length),n,a));const{normal:s,tangent:i}=e.vertexAttributes;this._passthroughReprojectionInfo(t)||!s&&!i||(o=n);const l=n===r||n===o?new Float64Array(n.length):n;return P(n,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:o}}_createNormalBuffer(e,t,r,o){const n=e.vertexAttributes.normal;if(null==n)return null;let a=n;const s=o.reprojection===st.RENDER?o.transformBeforeProject:null;s&&(a=q(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(o.reprojection===st.NONE)return a;if("local"===i){if(!H(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return z(a,W.NORMAL,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Y(a,W.NORMAL,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return J(a,r,e.spatialReference,t,c,l)}_createTangentBuffer(e,t,r,o){const n=e.vertexAttributes.tangent;if(null==n)return null;let a=n;const s=o.reprojection===st.RENDER?o.transformBeforeProject:null;s&&(a=K(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(o.reprojection===st.NONE)return a;if("local"===i){if(!H(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return z(a,W.TANGENT,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Y(a,W.TANGENT,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return Q(a,r,e.spatialReference,t,c,l)}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=pe(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return he(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,n=e.vertexAttributes.uv,a=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(n&&n.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),{position:i,georeferencedPositionBuffer:l}=this._createPositionBuffer(e,s),u=Je(e),m=this._createSymbolColorBuffer(t),f=this._createNormalBuffer(e,i,l,s),p=this._createTangentBuffer(e,i,l,s),h=n,{transformation:d,position:g,normal:x,tangent:_}=this._passthroughReprojectionInfo(s)?{transformation:s.objectTransformation,position:i,normal:f,tangent:p}:this._transformOriginLocal(e,i,f,p);return{positionBuffer:g,normalBuffer:x,tangentBuffer:_,uvBuffer:h,colorBuffer:u,symbolColorBuffer:m,objectTransformation:d,geometryTransformation:s.reprojection===st.NONE&&s.geometryTransformation?s.geometryTransformation:c()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?$(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?st.NONE:st.RENDER:st.NONE;if(V(t))return{reprojection:r};const o=t.origin,n=c(),i=e.transform?.localMatrix??u;if(r===st.NONE){C(e.spatialReference,o,n,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:n,geometryTransformation:m(i)}}const l=a(c(),o);return s(l,l,i),{reprojection:r,transformBeforeProject:l}}_transformOriginLocal(e,t,r,o){const n=this._context.renderCoordsHelper.spatialReference,a=e.origin;Qe[0]=a.x,Qe[1]=a.y,Qe[2]=a.z??0;const s=c();C(e.spatialReference,Qe,s,n),i(rt,s);const{position:l,normal:u,tangent:m}=e.vertexAttributes,f=t===l?new Float64Array(t.length):t;k(f,t,rt);const p=r?r===u?new Float32Array(r.length):r:null,h=o?o===m?new Float32Array(o.length):o:null;return r&&p&&q(r,p,rt),o&&h&&K(o,h,rt),{transformation:s,position:f,normal:p,tangent:h}}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=X(e,r??e.spatialReference);return!!o&&(I(o,nt),!N(nt,this._context.clippingExtent))}_createGeometryInfo(e,t,r){if(!A(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(!this._validateVertexSpace(e))return null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:n,uvBuffer:a,colorBuffer:s,symbolColorBuffer:i,normalBuffer:c,tangentBuffer:u,objectTransformation:m,geometryTransformation:f}=o,p=Le(e),h=new Array;let d=!1;const g=l(Xe,m),x=this._context.localOriginFactory.getOrigin(g);for(const l of p){if(!this._validateFaces(e,l))return null;const t=Ne(e,l);if(0===t.length)continue;const o=Se(n,c,l,t);o.didFlipNormals&&(d=!0);const m=[[we.POSITION,new ge(n,t,3,!0)],[we.NORMAL,new ge(o.normals,o.indices,3,!0)]];s&&m.push([we.COLOR,new ge(s,t,4,!0)]),i&&m.push([we.SYMBOLCOLOR,new ge(i,U(t.length),4,!0)]),a&&m.push([we.UV0,new ge(a,t,2,!0)]),u&&m.push([we.TANGENT,new ge(u,t,4,!0)]);const p=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),g=this._getOrCreateMaterial(e,l),_=new be(g,m,null,Te.Mesh,p);_.transformation=f,_.localOrigin=x,h.push(_)}return d&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:h,objectTransformation:m}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}_validateVertexSpace(e){const{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:r}=e;return t!==te.Local||"local"!==r.type||(this.logger.warn("Displaying a mesh with a local vertex space in a view in local viewing mode is not supported."),!1)}test(){return{...super.test(),materials:this._materialInfoCache.materials}}}class Ie{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}function Ne(e,t){return t.faces??B(e.vertexAttributes.position.length/3)}function Se(e,t,r,o){switch(r.shading||"flat"){default:case"source":return Be(e,t,r,o);case"flat":return Ue(e,o);case"smooth":return Fe(e,o)}}function Ue(e,t){const r=S(t.length),o=new Array(3*t.length);for(let n=0;n<t.length;n+=3){const a=Ge(e,t,n,tt);for(let e=0;e<3;e++)r[n+e]=a[e],o[n+e]=n/3}return new Ie(r,o,!1)}function Be(e,t,r,o){if(null==t)return Ue(e,o);let n=!1;if(!r.trustSourceNormals)for(let a=0;a<o.length;a+=3){Ge(e,o,a,tt);for(let e=0;e<3;e++){const r=3*o[a+e];Xe[0]=t[r],Xe[1]=t[r+1],Xe[2]=t[r+2],b(tt,Xe)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],n=!0)}}return new Ie(t,o,n)}function Fe(e,t){const r={};for(let a=0;a<t.length;a+=3){const o=Ge(e,t,a,tt);for(let e=0;e<3;e++){const n=t[a+e];let s=r[n];s||(s={normal:M(),count:0},r[n]=s),h(s.normal,s.normal,o),s.count++}}const o=S(3*t.length),n=new Array(3*t.length);for(let a=0;a<t.length;a++){const e=r[t[a]];1!==e.count&&(_(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*a+t]=e.normal[t];n[a]=a}return new Ie(o,n,!1)}function De(e,t,r,o,n,a){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],n[0]=e[i],n[1]=e[i+1],n[2]=e[i+2],a[0]=e[l],a[1]=e[l+1],a[2]=e[l+2]}function Ge(e,t,r,o){return De(e,t,r,Xe,Ze,et),y(Ze,Ze,Xe),y(et,et,Xe),v(Xe,Ze,et),_(o,Xe),o}function Le(e){return e.components??at}function Ve(e){if(!e)return null;const{scale:r,offset:o,rotation:n}=e;return{scale:r,offset:o,rotation:t(n)}}function $e(e="repeat"){if("string"==typeof e){const t=He(e);return{s:t,t}}return{s:He(e.horizontal),t:He(e.vertical)}}function He(e){switch(e){case"clamp":return Pe.CLAMP_TO_EDGE;case"mirror":return Pe.MIRRORED_REPEAT;default:return Pe.REPEAT}}function ke(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}function qe(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}function ze(e){return e.data??e.url}function We(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}function Ye(e){const{offset:t,scale:r,rotation:o}=e??Ke;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}function Je(e){return e.vertexAttributes.color}const Ke=new G,Qe=M(),Xe=M(),Ze=M(),et=M(),tt=M(),rt=c(),ot=c(),nt=O(),at=[new F];var st;!function(e){e[e.NONE=0]="NONE",e[e.RENDER=1]="RENDER"}(st||(st={}));export{Oe as Graphics3DMeshFillSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{normalFromMat4 as r,fromMat4 as o}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as a,multiply as s,invert as i,getTranslation as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c,IDENTITY as u,clone as m}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as f}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{i as p,g as h,h as d,t as g,q as x,n as _,b as T,f as b,d as y,e as v}from"../../../../chunks/vec32.js";import{ZEROS as w,ONES as R,create as M}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as j}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as A}from"../../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as C}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as P}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToPoint as E}from"../../../../geometry/projection/projectVectorToPoint.js";import{create as O,fromBuffer as I,intersectsClippingArea as N}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as S}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as U,getContinuousIndexArray as B}from"../../../../geometry/support/Indices.js";import F from"../../../../geometry/support/MeshComponent.js";import D from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import G from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as L,isAbsoluteVertexSpace as V}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as $,isPlateCarree as H}from"../../../../geometry/support/spatialReferenceUtils.js";import{t as k}from"../../../../chunks/vec3.js";import{transformNormal as q,transformVectorENUPlateCarree as z,VectorType as W,transformVectorWMPlateCarree as Y,projectNormalToPCPF as J,transformTangent as K,projectTangentToPCPF as Q}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as X}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{makeDehydratedPoint as Z}from"../../../../layers/graphics/dehydratedPoint.js";import{MeshTransformUpdateAction as ee}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as te}from"../../../ViewingMode.js";import{isEncodedMeshTexture as re}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as oe}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as ne}from"./ElevationAligners.js";import{needsElevationUpdates3D as ae,evaluateElevationInfoAtPoint as se}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as ie}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as le}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as ce}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as ue,MeshFastUpdateProcessor as me}from"./MeshFastUpdateProcessor.js";import{createMaterial as fe}from"../support/edgeUtils.js";import{parseColorMixMode as pe,encodeSymbolColor as he}from"../support/symbolColorUtils.js";import{debugFlags as de}from"../../support/debugFlags.js";import{Attribute as ge}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as xe,CullFaceOptions as _e}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as Te}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as be}from"../../webgl-engine/lib/Geometry.js";import{Object3D as ye}from"../../webgl-engine/lib/Object3D.js";import{Texture as ve}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as we}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as Re}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as Me}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as je,advancedMRRFactors as Ae,schematicMRRFactors as Ce}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as Pe}from"../../../webgl/enums.js";const Ee=["mesh"];class Oe extends ce{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new ue,this._fastUpdateProcessor=new me,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){de.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new Me({color:[1,0,1,1]}),this._debugTangentNormalMaterial=new Me({color:[1,.5,0,1]}),this._debugFaceNormalMaterial=new Me({color:[0,1,1,1]}))}destroy(){super.destroy(),this._textures.forEach((e=>e.unload())),this._context.stage.removeMany(this._materialInfoCache.materials),this._context.stage.removeMany(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy(this._context.stage)}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Ee,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache,this._context)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>t(e)?.layerOpacityChanged(r,this._context.isAsync)))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,ae)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters((({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync))),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters((({material:t})=>t.setParameters({usePBR:e}))),!0}updateTransform(e,t,r,o){if(!e.fastTransformUpdatesAllowed)return!1;const n=e.fastTransformUpdatesEnabled;switch(o){case ee.EnableFastUpdates:if(n)return!0;break;case ee.DisableFastUpdates:if(!n)return!0;break;default:if(!n)return!!this.updateTransform(e,t,r,ee.EnableFastUpdates)&&(e.autoDisableFastTransformUpdates((()=>this.updateTransform(e,t,r,ee.DisableFastUpdates))),!0)}const a=this._context.renderCoordsHelper.spatialReference,s=ot,{origin:i,transform:l}=r;if(!C(t,p(Xe,i.x,i.y,i.z??0),s,a))return!1;switch(o){case ee.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case ee.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case ee.UpdateFastLocalOrigin:e.updateFastLocalOrigin(s,l,this._context.localOriginFactory)}const{elevationContext:c}=e;c.centerPointInElevationSR=this._getCenterPointInElevationSR(s);const{elevationProvider:u,renderCoordsHelper:m}=this._context,f=(e,t)=>se(e,u,c,m,t);return e.alignedSampledElevation=ne(e,c,u.spatialReference,f,m,s),e.updateTransform(s,l,this._context.isAsync),e.updateAutoDisableFastTransformUpdates((()=>this.updateTransform(e,t,r,ee.DisableFastUpdates))),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,n=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:n,uid:`vc:${o},vt:${n},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:n,colorTexture:a,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,f=We(n),p=We(a),h=Ye(s),d=We(i),g=Ye(l);if(o.color=n,o.colorTexture=a,o.normalTexture=i,o.uid=`${o.uid},cmuid:${f},ctmuid:${p},cttuid:${h},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof D){const{metallic:e,roughness:r,metallicRoughnessTexture:n,metallicRoughnessTextureTransform:a,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:f}=t.material,p=We(n),h=Ye(a),d=We(i),g=We(c),x=Ye(u),_=We(m),T=Ye(f);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=n,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=Ve(s),o.normalTextureTransform=Ve(l),o.emissiveTextureTransform=Ve(u),o.occlusionTextureTransform=Ve(f),o.metallicRoughnessTextureTransform=Ve(a),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${p},mrtt:${h},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${T}`}return o}_getInternalTextureId(e){const t=this._getInternalTexture(e,xe.Opaque);return t?.id}_getInternalTexture(e,t){const r=ze(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let n=this._textures.get(o);if(!n){let a=null;const s=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,i={wrap:$e(e.wrap),noUnpackFlip:!0,maxAnisotropy:s,mipmap:s>1};re(r)?(a=r.data,i.preMultiplyAlpha=!1,i.encoding=r.encoding):(a=r,i.preMultiplyAlpha=t!==xe.Opaque,i.downsampleUncompressed=this._context.graphicsCoreOwner.view.qualitySettings.graphics3D.uncompressedTextureDownsamplingEnabled),n=new ve(a,i),this._textures.set(o,n),n.load(this._context.stage.renderView.renderingContext),this._context.stage.add(n),n.events.on("unloaded",(()=>{this._textures.delete(o)}))}return n}_setInternalMaterialTextureParameters(t,r){if(null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture))}_setInternalMaterialParameters(e,t){null!=e.color&&qe(e.color,t),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=oe(e.colorTextureTransform),t.normalTextureTransformMatrix=oe(e.normalTextureTransform);const r=null!=e.normalTextureTransform?.scale?e.normalTextureTransform?.scale:f;t.scale=[r[0],r[1]],t.occlusionTextureTransformMatrix=oe(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=oe(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=oe(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=this.symbolLayer.material?.colorMixMode??null;if(r)t.externalColor=j;else{const r=this.symbolLayer.material?.color??null;r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=j)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_getOrCreateMaterial(t,r){const o=r.material?.color,n=r.material?.colorTexture,a=r.material?.alphaMode,s="blend"===a,i=!("opaque"===a)&&(ke(t)||null!=o&&o.a<1||n?.transparent||s),l=this._materialProperties(t,r,i),c=this._materialInfoCache.byUid(l.uid);if(c)return this._setInternalMaterialTextureParameters(l,c.material.parameters),c.material;const u={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=je({normalTexture:l.normalTexture,metallicRoughnessTexture:l.metallicRoughnessTexture,metallicFactor:l.metallic,roughnessFactor:l.roughness,emissiveTexture:l.emissiveTexture,emissiveFactor:e.toUnitRGB(l.emissiveColor),occlusionTexture:l.occlusionTexture}),f={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:w,diffuse:R,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:_e.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled};f.mrrFactors=m?Ce:[l.metallic,l.roughness,Ae[2]],r.material&&(f.doubleSided=r.material.doubleSided,f.cullFace=r.material.doubleSided?_e.None:_e.Back,f.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(f),this._setMaterialTransparentParameter(f,u),this._setInternalMaterialParameters(l,f);const p=new Re(f,this._context);return u.material=p,this._materialInfoCache.set(l.uid,u),this._context.stage.add(p),p}_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?xe.MaskBlend:xe.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?xe.Opaque:"mask"===t.alphaMode?xe.Mask:xe.Blend}_createFaceDebugNormals(e,t){const o=t.length,a=e.spatialReference.isGeographic?20015077/180:1,s=.1*Math.max(e.extent.width*a,e.extent.height*a,e.extent.zmax-e.extent.zmin),i=[],l=[],c=t[0].transformation,u=r(n(),c);for(let r=0;r<o;r++){const e=t[r].attributes.get(we.POSITION);if(!e)continue;const o=e.data,n=e.indices;for(let t=0;t<n.length;t+=3)Ge(o,n,t,tt),De(o,n,t,Xe,Ze,et),h(Xe,Xe,Ze),h(Xe,Xe,et),d(Xe,Xe,1/3),g(Xe,Xe,c),i.push(...Xe),x(tt,tt,u),_(tt,tt),T(Xe,Xe,tt,s),i.push(...Xe),l.push(l.length),l.push(l.length)}return i.length?new be(this._debugFaceNormalMaterial,[[we.POSITION,new ge(i,l,3,!0)]],null,Te.Line):null}_createPerVertexDebugVectors(e,t,a,s,i){const l=t.length,c=e.spatialReference.isGeographic?20015077/180:1,u=.1*i*Math.max(e.extent.width*c,e.extent.height*c,e.extent.zmax-e.extent.zmin),m=[],f=[],h=t[0].transformation,d=r(n(),h);a===we.TANGENT&&o(d,h);for(let r=0;r<l;r++){const e=t[r],o=e.attributes.get(we.POSITION),n=e.attributes.get(a);if(!o||!n)continue;const s=o.data,i=o.indices,l=n.data,c=n.indices;for(let t=0;t<i.length;t++){const e=3*i[t],r=c[t]*n.stride;p(Xe,s[e+0],s[e+1],s[e+2]),g(Xe,Xe,h),m.push(...Xe),p(Ze,l[r+0],l[r+1],l[r+2]),x(Ze,Ze,d),_(Ze,Ze),T(Xe,Xe,Ze,u),m.push(...Xe),f.push(f.length),f.push(f.length)}}return m.length?new be(s,[[we.POSITION,new ge(m,f,3,!0)]],null,Te.Line):null}_createAs3DShape(e,t,r,o){const n=e.geometry;if("mesh"!==n.type)return null;const a=this._createGeometryInfo(n,t,o);if(null==a)return null;const{geometries:s,objectTransformation:i}=a;if(de.DRAW_MESH_GEOMETRY_NORMALS){const e=this._createPerVertexDebugVectors(n,s,we.NORMAL,this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(n,s,we.TANGENT,this._debugTangentNormalMaterial,.5),r=this._createFaceDebugNormals(n,s);e&&s.push(e),t&&s.push(t),r&&s.push(r)}const l=new ye({geometries:s,layerUid:this._context.layer.uid,graphicUid:o,isElevationSource:!0});l.transformation=i;const c=fe(this.symbolLayer,{opacity:this._getLayerOpacity()}),u=c?new le(s[0].material,c,this._context.slicePlaneEnabled):null,m=new ie(this,l,s,null,null,ne,r,u);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=ae(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,m.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(n),r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:f,renderCoordsHelper:p}=this._context,h=(e,t)=>se(e,f,r,p,t);return m.alignedSampledElevation=ne(m,r,f.spatialReference,h,p),m}_fastTransformUpdatesAllowed(e){const{vertexSpace:t,spatialReference:r}=e;if(!L(t))return!1;const{type:o}=t,{view:n}=this._context.graphicsCoreOwner,{viewingMode:a}=n.state,s=n.spatialReference;return a===te.Global&&"local"===o||a===te.Local&&$(s,r)&&"georeferenced"===o&&!r.isGeographic}_getCenterPointInElevationSR(e){const t=Z(0,0,0,this._context.elevationProvider.spatialReference??null);return E([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_passthroughReprojectionInfo(e){return e.reprojection===st.NONE&&!!e.objectTransformation}_createPositionBuffer(e,t){const r=e.vertexAttributes.position;let o,n=r;if(t.reprojection===st.NONE)return{position:n,georeferencedPositionBuffer:o};const a=t.reprojection===st.RENDER?t.transformBeforeProject:null;a&&(n=k(new Float64Array(n.length),n,a));const{normal:s,tangent:i}=e.vertexAttributes;this._passthroughReprojectionInfo(t)||!s&&!i||(o=n);const l=n===r||n===o?new Float64Array(n.length):n;return P(n,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:o}}_createNormalBuffer(e,t,r,o){const n=e.vertexAttributes.normal;if(null==n)return null;let a=n;const s=o.reprojection===st.RENDER?o.transformBeforeProject:null;s&&(a=q(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(o.reprojection===st.NONE)return a;if("local"===i){if(!H(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return z(a,W.NORMAL,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Y(a,W.NORMAL,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return J(a,r,e.spatialReference,t,c,l)}_createTangentBuffer(e,t,r,o){const n=e.vertexAttributes.tangent;if(null==n)return null;let a=n;const s=o.reprojection===st.RENDER?o.transformBeforeProject:null;s&&(a=K(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(o.reprojection===st.NONE)return a;if("local"===i){if(!H(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return z(a,W.TANGENT,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Y(a,W.TANGENT,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return Q(a,r,e.spatialReference,t,c,l)}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=pe(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return he(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,n=e.vertexAttributes.uv,a=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(n&&n.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),{position:i,georeferencedPositionBuffer:l}=this._createPositionBuffer(e,s),u=Je(e),m=this._createSymbolColorBuffer(t),f=this._createNormalBuffer(e,i,l,s),p=this._createTangentBuffer(e,i,l,s),h=n,{transformation:d,position:g,normal:x,tangent:_}=this._passthroughReprojectionInfo(s)?{transformation:s.objectTransformation,position:i,normal:f,tangent:p}:this._transformOriginLocal(e,i,f,p);return{positionBuffer:g,normalBuffer:x,tangentBuffer:_,uvBuffer:h,colorBuffer:u,symbolColorBuffer:m,objectTransformation:d,geometryTransformation:s.reprojection===st.NONE&&s.geometryTransformation?s.geometryTransformation:c()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?$(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?st.NONE:st.RENDER:st.NONE;if(V(t))return{reprojection:r};const o=t.origin,n=c(),i=e.transform?.localMatrix??u;if(r===st.NONE){C(e.spatialReference,o,n,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:n,geometryTransformation:m(i)}}const l=a(c(),o);return s(l,l,i),{reprojection:r,transformBeforeProject:l}}_transformOriginLocal(e,t,r,o){const n=this._context.renderCoordsHelper.spatialReference,a=e.origin;Qe[0]=a.x,Qe[1]=a.y,Qe[2]=a.z??0;const s=c();C(e.spatialReference,Qe,s,n),i(rt,s);const{position:l,normal:u,tangent:m}=e.vertexAttributes,f=t===l?new Float64Array(t.length):t;k(f,t,rt);const p=r?r===u?new Float32Array(r.length):r:null,h=o?o===m?new Float32Array(o.length):o:null;return r&&p&&q(r,p,rt),o&&h&&K(o,h,rt),{transformation:s,position:f,normal:p,tangent:h}}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=X(e,r??e.spatialReference);return!!o&&(I(o,nt),!N(nt,this._context.clippingExtent))}_createGeometryInfo(e,t,r){if(!A(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(!this._validateVertexSpace(e))return null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:n,uvBuffer:a,colorBuffer:s,symbolColorBuffer:i,normalBuffer:c,tangentBuffer:u,objectTransformation:m,geometryTransformation:f}=o,p=Le(e),h=new Array;let d=!1;const g=l(Xe,m),x=this._context.localOriginFactory.getOrigin(g);for(const l of p){if(!this._validateFaces(e,l))return null;const t=Ne(e,l);if(0===t.length)continue;const o=Se(n,c,l,t);o.didFlipNormals&&(d=!0);const m=[[we.POSITION,new ge(n,t,3,!0)],[we.NORMAL,new ge(o.normals,o.indices,3,!0)]];s&&m.push([we.COLOR,new ge(s,t,4,!0)]),i&&m.push([we.SYMBOLCOLOR,new ge(i,U(t.length),4,!0)]),a&&m.push([we.UV0,new ge(a,t,2,!0)]),u&&m.push([we.TANGENT,new ge(u,t,4,!0)]);const p=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),g=this._getOrCreateMaterial(e,l),_=new be(g,m,null,Te.Mesh,p);_.transformation=f,_.localOrigin=x,h.push(_)}return d&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:h,objectTransformation:m}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}_validateVertexSpace(e){const{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:r}=e;return t!==te.Local||"local"!==r.type||(this.logger.warn("Displaying a mesh with a local vertex space in a view in local viewing mode is not supported."),!1)}test(){return{...super.test(),materials:this._materialInfoCache.materials}}}class Ie{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}function Ne(e,t){return t.faces??B(e.vertexAttributes.position.length/3)}function Se(e,t,r,o){switch(r.shading||"flat"){default:case"source":return Be(e,t,r,o);case"flat":return Ue(e,o);case"smooth":return Fe(e,o)}}function Ue(e,t){const r=S(t.length),o=new Array(3*t.length);for(let n=0;n<t.length;n+=3){const a=Ge(e,t,n,tt);for(let e=0;e<3;e++)r[n+e]=a[e],o[n+e]=n/3}return new Ie(r,o,!1)}function Be(e,t,r,o){if(null==t)return Ue(e,o);let n=!1;if(!r.trustSourceNormals)for(let a=0;a<o.length;a+=3){Ge(e,o,a,tt);for(let e=0;e<3;e++){const r=3*o[a+e];Xe[0]=t[r],Xe[1]=t[r+1],Xe[2]=t[r+2],b(tt,Xe)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],n=!0)}}return new Ie(t,o,n)}function Fe(e,t){const r={};for(let a=0;a<t.length;a+=3){const o=Ge(e,t,a,tt);for(let e=0;e<3;e++){const n=t[a+e];let s=r[n];s||(s={normal:M(),count:0},r[n]=s),h(s.normal,s.normal,o),s.count++}}const o=S(3*t.length),n=new Array(3*t.length);for(let a=0;a<t.length;a++){const e=r[t[a]];1!==e.count&&(_(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*a+t]=e.normal[t];n[a]=a}return new Ie(o,n,!1)}function De(e,t,r,o,n,a){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],n[0]=e[i],n[1]=e[i+1],n[2]=e[i+2],a[0]=e[l],a[1]=e[l+1],a[2]=e[l+2]}function Ge(e,t,r,o){return De(e,t,r,Xe,Ze,et),y(Ze,Ze,Xe),y(et,et,Xe),v(Xe,Ze,et),_(o,Xe),o}function Le(e){return e.components??at}function Ve(e){if(!e)return null;const{scale:r,offset:o,rotation:n}=e;return{scale:r,offset:o,rotation:t(n)}}function $e(e="repeat"){if("string"==typeof e){const t=He(e);return{s:t,t}}return{s:He(e.horizontal),t:He(e.vertical)}}function He(e){switch(e){case"clamp":return Pe.CLAMP_TO_EDGE;case"mirror":return Pe.MIRRORED_REPEAT;default:return Pe.REPEAT}}function ke(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}function qe(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}function ze(e){return e.data??e.url}function We(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}function Ye(e){const{offset:t,scale:r,rotation:o}=e??Ke;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}function Je(e){return e.vertexAttributes.color}const Ke=new G,Qe=M(),Xe=M(),Ze=M(),et=M(),tt=M(),rt=c(),ot=c(),nt=O(),at=[new F];var st;!function(e){e[e.NONE=0]="NONE",e[e.RENDER=1]="RENDER"}(st||(st={}));export{Oe 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.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{
|
|
5
|
+
import{defaultAcceptedFormats as t}from"../../../../symbols/support/webStyleAcceptedFormats.js";import{emptySymbolComplexity as r}from"./defaultSymbolComplexity.js";import{ApplyRendererDiffResult as s,FastUpdateStatus as e}from"./interfaces.js";import{Loadable as i}from"./Loadable.js";import{getSymbolMemorySize as o}from"./symbolMemory.js";class l extends i{constructor(t,r,s){super(r),this.symbol=t,this._convert=s,this.symbologySnappingSupported=!1,this.graphics3DSymbol=null,this.referenced=0}getSymbolLayerSize(t){return null!=this.graphics3DSymbol?this.graphics3DSymbol.getSymbolLayerSize(t):null}get symbolLayers(){return null!=this.graphics3DSymbol?this.graphics3DSymbol.symbolLayers:[]}get extentPadding(){return null!=this.graphics3DSymbol?this.graphics3DSymbol.extentPadding:0}async doLoad(r){const s=await this.symbol.fetchSymbol({signal:r,acceptedFormats:t});s.id=this.symbol.id,this.graphics3DSymbol=this._convert(s),null!=this.graphics3DSymbol&&await this.graphics3DSymbol.load()}createGraphics3DGraphic(t){return null!=this.graphics3DSymbol?this.graphics3DSymbol.createGraphics3DGraphic(t,this):null}get complexity(){return null!=this.graphics3DSymbol?this.graphics3DSymbol.complexity:r}globalPropertyChanged(t,r){return null!=this.graphics3DSymbol&&this.graphics3DSymbol.globalPropertyChanged(t,r)}applyRendererDiff(t,r){return null!=this.graphics3DSymbol?this.graphics3DSymbol.applyRendererDiff(t,r):s.RecreateSymbol}prepareSymbolPatch(t){null!=this.graphics3DSymbol&&this.graphics3DSymbol.prepareSymbolPatch(t)}updateGeometry(t,r){return null!=this.graphics3DSymbol&&this.graphics3DSymbol.updateGeometry(t,r)}updateTransform(t,r,s,e){return this.graphics3DSymbol?.updateTransform(t,r,s,e)??!1}onRemoveGraphic(){}updateFocus(t,r){}getFastUpdateStatus(){return this.graphics3DSymbol?.getFastUpdateStatus()??e.Loading}destroy(){null!=this.graphics3DSymbol&&this.graphics3DSymbol.destroy(),this.graphics3DSymbol=void 0,super.destroy()}get destroyed(){return void 0===this.graphics3DSymbol}get cachedMemory(){return o(this)}}export{l as Graphics3DWebStyleSymbol};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/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 i}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import r from"../../../../core/Logger.js";import{disposeMaybe as l,abortMaybe as a}from"../../../../core/maybe.js";import{throwIfAborted as o,isAbortError as n}from"../../../../core/promiseUtils.js";import{watch as c}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/RandomLCG.js";import{subclass as b}from"../../../../core/accessorSupport/decorators/subclass.js";import{fromValues as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{hydrateGraphic as g}from"../../../../layers/graphics/hydratedFeatures.js";import{createLabelFunction as u}from"../../../../layers/support/labelFormatUtils.js";import{hasCalloutSupport as d}from"../../../../symbols/callouts/calloutUtils.js";import{VisibilityGroup as y,VisibilityFlag as m}from"./enums.js";import{make as f}from"./Graphics3DCalloutSymbolLayerFactory.js";import{LineCalloutSymbolLayerRenderingInfo as C,LineCalloutCreationContext as x}from"./Graphics3DLineCalloutSymbolLayer.js";import{getGraphics3DSymbol as _}from"./graphicSymbolUtils.js";import{LabelInfo as L}from"./LabelInfo.js";import{LabelParameters as w}from"./LabelParameters.js";import{horizontalPlacementFromAnchor as v,verticalPlacementFromAnchor as j,textRenderAlignmentFromHorizontalPlacement as G}from"./placementUtils.js";import"../../../../geometry/support/Indices.js";import"./pipeline/rendering/FeaturePipelineRenderManager.js";import"../../webgl-engine/lib/BoundingInfo.js";import{VertexAttribute as D}from"../../webgl-engine/lib/VertexAttribute.js";import"../../../ViewingMode.js";import"../../support/buffer/InterleavedLayout.js";import"../../webgl-engine/core/shaderLibrary/ShaderOutput.js";import"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import"../../webgl-engine/core/shaderLibrary/output/Emissions.glsl.js";import"../../webgl-engine/core/shaderLibrary/shading/Normals.glsl.js";import"../../webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import"../../webgl-engine/lib/basicInterfaces.js";import"../../webgl-engine/lib/Material.js";import"../../webgl-engine/lib/OrderIndependentTransparency.js";import"../../webgl-engine/lib/RayIntersections.js";import"../../webgl-engine/lib/RenderSlot.js";import"../../webgl-engine/lib/verticalOffsetUtils.js";import"../../../../geometry/support/buffer/BufferView.js";import"../../../../core/mathUtils.js";import"../../../../chunks/boundedPlane.js";import"../../../../geometry/support/Axis.js";import"../../../../geometry/support/ray.js";import"../../../../geometry/support/vectorStacks.js";import"../../webgl-engine/core/shaderModules/glsl.js";import"../../../webgl/BindType.js";import"../../webgl-engine/lib/DefaultVertexAttributeLocations.js";import"../../../../core/HeapSort.js";import"../../../webgl/checkWebGLError.js";import"../../../webgl/enums.js";import"../../../webgl/renderState.js";import"../../webgl-engine/lib/OITPass.js";import"../../webgl-engine/lib/StencilUtils.js";import"../../webgl-engine/core/shaderLibrary/Slice.glsl.js";import"../support/symbolColorUtils.js";import"../../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import"../support/FastSymbolUpdates.js";import"../../webgl-engine/effects/ssao/SSAO.js";import"../../../webgl/ShaderBuilder.js";import"../../webgl-engine/shaders/DefaultMaterialTechniqueConfiguration.js";import{MaterialCollection as A}from"../../webgl-engine/lib/MaterialCollection.js";import{TextRenderer as I}from"../../webgl-engine/lib/TextRenderer.js";import{TextRenderParameters as S}from"../../webgl-engine/lib/TextRenderParameters.js";import{TextTextureAtlas as T}from"../../webgl-engine/lib/TextTextureAtlas.js";import{WebGLLayer as R}from"../../webgl-engine/lib/WebGLLayer.js";import{TaskPriority as P}from"../../../support/Scheduler.js";import{Yield as O}from"../../../support/Yield.js";class E{constructor(e,t){this.labelingContext=e,this.graphics3DGraphic=t,this.hasGraphics3DResources=!1,this.visible=!1,this.textureAtlasHandles=[],this.textInitialized=!1,this.textRenderers=new Array,this.textLabelPlacements=new Array}}class V{constructor(e,t,s,i,r){this.labelClass=e,this.graphics3DSymbol=t,this.graphics3DCalloutSymbolLayer=s,this.textRenderParameters=i,this.labelFunction=r,this.calloutSymbolLayerIndex=0}}class U{constructor(e,t,s,i,r,l,a,o){this.layer=t,this.graphics3DCore=s,this.scaleVisibility=i,this.emptySymbolLabelSupported=r,this.elevationInfoOverride=l,this.disablePlacement=a,this.active=o,this.labelClassAbortController=new AbortController,this.labelClassContexts=new Array,this.graphics=new Map,this.labelsToInitialize=new Map,this.stageLayer=new R(e,{pickable:!0,disableOctree:!0},t.uid)}destroy(){this.stageLayer.destroy()}}let M=class extends t{constructor(e){super(e),this._dirty=!1,this._labels=new Map,this._labelingContexts=new Array}setup(){this.dispose(),this.addHandles([c((()=>this.view.state?.camera),(()=>this.setDirty())),c((()=>this.view.state?.rasterPixelRatio),(()=>this._resetAllLabels())),this.view.resourceController.scheduler.registerTask(P.LABELER,this)]),this._textTextureAtlas=new T({view:this.view}),this._hudMaterialCollection=new A(this.view._stage),this._calloutMaterialCollection=new A(this.view._stage)}dispose(){this.removeAllHandles(),this._textTextureAtlas=l(this._textTextureAtlas),this._hudMaterialCollection=l(this._hudMaterialCollection),this._calloutMaterialCollection=l(this._calloutMaterialCollection),this._labelingContexts.length=0,this._labels.clear()}destroy(){this.dispose(),W.graphic=null,W.renderingInfo=null,W.layer=null}_activateLabelingContext(e){e.graphics.forEach(((t,s)=>{const i=new E(e,t);this._labels.set(s,i),e.labelsToInitialize.set(s,i),t.setVisibilityFlag(y.LABEL,m.USER,!0)})),e.active=!0}_deactivateLabelingContext(e){e.graphics.forEach(((e,t)=>{e.setVisibilityFlag(y.LABEL,m.USER,!1),this.setLabelGraphicVisibility(e,!1),e.clearLabelGraphics(),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];s&&(e.textureAtlasHandles.push(this._textTextureAtlas.addText(s,(e=>z(t.stageObject,e)))),F(t.stageObject,s))}}_removeLabelTextureFromAtlas(e){e.textureAtlasHandles.forEach((e=>e.remove())),e.textureAtlasHandles.length=0}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),O}_updateLabels(e){if(this._dirty){this._dirty=!1;for(const t of this._labelingContexts)if(t.active)if(H(t))this._dirty=!0;else if(B(t.labelClassContexts)){if(null===t.labelClassContexts){this._deactivateLabelingContext(t);continue}this._createLabelClassContext(t),this._dirty=!0}else for(const[s,i]of t.labelsToInitialize)if(this._ensureGraphics3DResources(i)&&(this._labels.set(s,i),this.deconflictor.setDirty(),e.madeProgress()),(i.visible&&i.textInitialized||!i.visible&&i.hasGraphics3DResources)&&(t.labelsToInitialize.delete(s),e.madeProgress()),e.done){this._dirty=!0;break}this._dirty||this.notifyChange("updating")}}async _createLabelClassContextAsync(e){const t=e.labelClassAbortController?.signal;e.layer.when&&await e.layer.when(),o(t),e.scaleVisibility?.updateScaleRangeActive();const l=e.graphics3DCore,a=l.layer,n=a.labelingInfo?.filter((e=>!!e.symbol));if(!n||0===n.length)return;let c=!1;await s(n,(async(s,a)=>{const n=s.symbol,h=_(l.getOrCreateGraphics3DSymbol(n));if(null==h)return void r.getLogger(this).error("Failed to create Graphics3DSymbol for label");await h.load(),o(t);let b=null;d(n)&&n.hasVisibleCallout()&&(b=f(n,l.symbolCreationContext),await b.load(),o(t));const p=await i(u(s,e.layer.fieldsIndex,this.view.spatialReference));if(o(t),!0===p.ok){const i=await this._createTextRenderParameters(h.symbol);o(t),e.labelClassContexts[a]=new V(s,h,b,i,p.value)}else r.getLogger(this).error(`Label expression failed to evaluate: ${p.error}`),c=!0})),o(t)}async _createLabelClassContext(e){return null==e.labelClassPromise&&(e.labelClassPromise=this._createLabelClassContextAsync(e).catch((t=>{if(n(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.at(0);return"text"!==t?.type?null:S.fromSymbol(t,this.view.state.rasterPixelRatio)}_destroyLabelClassContext(e){for(const s of e.labelClassContexts)--s.graphics3DSymbol.referenced;const t=e.labelClassAbortController;e.labelClassAbortController=new AbortController,a(t),e.labelClassContexts.length=0,e.labelClassPromise=null,this.notifyChange("updating")}_createTextSymbolGraphic(e,t,s,i,r,l){const a=new w(s,v(s.anchor),j(s.anchor),e.text,p(e.displayWidth,e.displayHeight));return W.graphic=t,W.layer=i,W.renderingInfo=null,r.createLabel(W,a,this._hudMaterialCollection,this._textTextureAtlas,(()=>l.placement?.elevationOffset??null))}_createLineCalloutGraphic(e,t,s,i,r){W.graphic=e,W.layer=r;const l=i.screenOffset[0];return W.renderingInfo=new C(null,t,i.translation,i.centerOffset,l,i.centerOffsetUnits,i.elevationOffset,this._calloutMaterialCollection),s.createGraphics3DGraphic(W)}_ensureGraphics3DResources(e){if(e.hasGraphics3DResources)return!1;const t=e.graphics3DGraphic;if(t.destroyed)return!1;this._ensureTextTextureResources(e);const s=e.labelingContext,i=s.labelClassContexts;if(B(i)||!s.emptySymbolLabelSupported&&0===t.layers.length)return!1;let r=!1;const l=t.graphic,a=s.layer,o=N(s.layer);for(let n=0;n<i.length;n++){const c=e.textRenderers[n],h=e.textLabelPlacements[n];if(null==c||null==h)continue;const b=i[n],p=b.graphics3DSymbol,g=k(p),u=p.symbolLayers[0];if(!u)continue;u.setElevationInfoOverride(s.elevationInfoOverride);const d=new L(t,g,b.labelClass),f=this._createTextSymbolGraphic(c,l,h,a,u,d);if(null==f)return!1;f._labelClass=b.labelClass,f._labelIndex=n,t.addLabelGraphic(f,s.stageLayer),t.deconflictionPriority=b.textRenderParameters?.definition.size??0,t.setVisibilityFlag(y.LABEL,m.USER,o),t.setVisibilityFlag(y.LABEL,m.SCALE_RANGE,!0),t.setVisibilityFlag(y.LABEL,m.DECONFLICTION,!1),r=!0;const C=b.graphics3DCalloutSymbolLayer;if(C&&h.hasLabelVerticalOffset){C.setElevationInfoOverride(s.elevationInfoOverride);const e=this._createLineCalloutGraphic(l,g,C,h,a);null!=e&&(b.calloutSymbolLayerIndex=t.labelLayers.length,t.addLabelGraphic(e,s.stageLayer))}break}return r&&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];e?.onRemoveGraphic(s)}e.graphics3DGraphic.deconflictionPriority=0,e.graphics3DGraphic.clearLabelGraphics(),e.hasGraphics3DResources=!1}_ensureTextTextureResources(e){if(e.textInitialized)return;const t=e.labelingContext,s=t.labelClassContexts;if(B(s))return;const i=e.graphics3DGraphic.graphic;for(let l=0;l<s.length;l++){const a=s[l];if(e.textRenderers[l]=null,e.textLabelPlacements[l]=null,null==a?.textRenderParameters)continue;const o=a.labelFunction;let n;if("arcade"===o.type)try{const e=o.needsHydrationToEvaluate()?g(i,t.layer):i;n=o.evaluate(e)}catch(r){n=null}else n=o.evaluate(i);if(null==n||""===n||/^\s+$/.test(n))continue;const c=a.graphics3DSymbol;if(!c.symbolLayers[0])continue;const h=e.graphics3DGraphic,b="label-3d"===c.symbol?.type?c.symbol:null,p=a.labelClass,u=t.disablePlacement,d=new L(h,b,p,u).placement;if(null==d)continue;const y=v(d.anchor),m=G(y);e.textRenderers[l]=new I(n,m,a.textRenderParameters,T.maxSize),e.textLabelPlacements[l]=d}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 i=new E(e,t);this._labels.set(s,i),e.labelsToInitialize.set(s,i)}this.setDirty(),this.deconflictor.setDirty()}_updateGraphicGeometry(e,t){const s=t.graphic.uid,i=this._labels.get(s);if(!i)return!0;for(const r of i.graphics3DGraphic.labelLayers){if(null==r._labelClass)continue;if(!e.labelClassContexts[r._labelIndex].graphics3DSymbol.symbolLayers[0].updateGeometry(r,t.graphic.geometry))return!1}return this.setDirty(),this.deconflictor.setDirty(),!0}_removeGraphic(e,t){const s=t.graphic.uid,i=this._labels.get(s);e.graphics.delete(s),i&&(this._destroyGraphic(i,s),e.labelsToInitialize.delete(s),this.setDirty(),this.deconflictor.setDirty())}_destroyGraphic(e,t){this._labels.delete(t),e.textureAtlasHandles.length&&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 i=new Map;t.graphics.forEach((e=>i.set(e.graphic.uid,e)));const r=e=>e.labelLayers[0];if(s.graphics3DSymbol.symbolLayers[0].globalPropertyChanged(e,i,r),s.graphics3DCalloutSymbolLayer){const t=e=>e.labelLayers[s.calloutSymbolLayerIndex];s.graphics3DCalloutSymbolLayer.globalPropertyChanged(e,i,t)}}}_visibilityInfoChange(e){const t=N(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 i=this._labels.get(s);i&&(this._destroyGraphic(i,s),i.visible=!1,e.labelsToInitialize.set(s,i))})),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 i=s?.emptySymbolLabelSupported||!1,r=s?.elevationInfoOverride||null,l=s?.disablePlacement||null;if(this._findLabelingContext(e))return;const a=e.layer,o=new U(this.view._stage,a,e,t,i,r,l,N(a));return this._labelingContexts.push(o),this.setDirty(),{addGraphic:e=>this._addGraphic(o,e),removeGraphic:e=>this._removeGraphic(o,e),updateGraphicGeometry:e=>this._updateGraphicGeometry(o,e),layerLabelsEnabled:()=>N(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),remove:()=>this._removeGraphicsOwner(e),setDirty:()=>this.setDirty()}}_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))),t.destroy(),this.setDirty()}setLabelGraphicVisibility(e,t){const s=e.graphic.uid,i=this._labels.get(s);i&&i.visible!==t&&(t&&!i.textureAtlasHandles.length?(this._addLabelTextureToAtlas(i),i.textInitialized||i.labelingContext.labelsToInitialize.set(s,i)):!t&&i.textureAtlasHandles.length&&this._removeLabelTextureFromAtlas(i),i.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=>H(e)))}get updatingProgress(){if(!this.updating||!this._textTextureAtlas)return 1;const e=this._labelingContexts.length>0?this._labelingContexts.reduce(((e,t)=>e+(H(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(){}};function F(e,t){e.geometries[0].setAttributeData(D.SIZE,[t.displayWidth,t.displayHeight]),e.geometryVertexAttributeUpdated(e.geometries[0],D.SIZE)}function z(e,t){e.geometries[0].setAttributeData(D.UV0,t),e.geometryVertexAttributeUpdated(e.geometries[0],D.UV0,!0)}function H(e){return!!e.labelClassPromise&&!!e.labelClassAbortController}function B(e){return!e||0===e.length}function k(e){return"label-3d"===e.symbol?.type?e.symbol:null}function N(e){return!0===e.labelsVisible&&!!e.labelingInfo?.some((e=>!!e.symbol))}e([h({constructOnly:!0})],M.prototype,"view",void 0),e([h({constructOnly:!0})],M.prototype,"deconflictor",void 0),e([h()],M.prototype,"_textTextureAtlas",void 0),e([h({type:Boolean,readOnly:!0})],M.prototype,"updating",null),M=e([b("esri.views.3d.layers.graphics.Labeler")],M);const W=new x(null,null,null);export{M as Labeler,N as areLabelsVisible};
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{forEach as s,result as i}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import l from"../../../../core/Logger.js";import{disposeMaybe as a,abortMaybe as r}from"../../../../core/maybe.js";import{throwIfAborted as o,isAbortError as n}from"../../../../core/promiseUtils.js";import{watch as c}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/RandomLCG.js";import{subclass as b}from"../../../../core/accessorSupport/decorators/subclass.js";import{fromValues as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{hydrateGraphic as u}from"../../../../layers/graphics/hydratedFeatures.js";import{createLabelFunction as d}from"../../../../layers/support/labelFormatUtils.js";import{hasCalloutSupport as y}from"../../../../symbols/callouts/calloutUtils.js";import{VisibilityGroup as g,VisibilityFlag as m}from"./enums.js";import{make as f}from"./Graphics3DCalloutSymbolLayerFactory.js";import{LineCalloutSymbolLayerRenderingInfo as C,LineCalloutCreationContext as x}from"./Graphics3DLineCalloutSymbolLayer.js";import{getGraphics3DSymbol as _}from"./graphicSymbolUtils.js";import{LabelInfo as L}from"./LabelInfo.js";import{LabelParameters as v}from"./LabelParameters.js";import{horizontalPlacementFromAnchor as G,verticalPlacementFromAnchor as D,textRenderAlignmentFromHorizontalPlacement as w}from"./placementUtils.js";import{MaterialCollection as A}from"../../webgl-engine/lib/MaterialCollection.js";import{TextRenderer as I}from"../../webgl-engine/lib/TextRenderer.js";import{TextRenderParameters as T}from"../../webgl-engine/lib/TextRenderParameters.js";import{TextTextureAtlas as S}from"../../webgl-engine/lib/TextTextureAtlas.js";import{VertexAttribute as R}from"../../webgl-engine/lib/VertexAttribute.js";import{WebGLLayer as P}from"../../webgl-engine/lib/WebGLLayer.js";import{TaskPriority as j}from"../../../support/Scheduler.js";import{Yield as E}from"../../../support/Yield.js";class O{constructor(e,t){this.labelingContext=e,this.graphics3DGraphic=t,this.hasGraphics3DResources=!1,this.visible=!1,this.textureAtlasHandles=[],this.textInitialized=!1,this.textRenderers=new Array,this.textLabelPlacements=new Array}}class V{constructor(e,t,s,i,l){this.labelClass=e,this.graphics3DSymbol=t,this.graphics3DCalloutSymbolLayer=s,this.textRenderParameters=i,this.labelFunction=l,this.calloutSymbolLayerIndex=0}}class z{constructor(e,t,s,i,l,a,r,o){this.layer=t,this.graphics3DCore=s,this.scaleVisibility=i,this.emptySymbolLabelSupported=l,this.elevationInfoOverride=a,this.disablePlacement=r,this.active=o,this.labelClassAbortController=new AbortController,this.labelClassContexts=new Array,this.graphics=new Map,this.labelsToInitialize=new Map,this.stageLayer=new P(e,{pickable:!0,disableOctree:!0},t.uid)}destroy(){this.stageLayer.destroy()}}let F=class extends t{constructor(e){super(e),this._dirty=!1,this._labels=new Map,this._labelingContexts=new Array}setup(){this.dispose(),this.addHandles([c((()=>this.view.state?.camera),(()=>this.setDirty())),c((()=>this.view.state?.rasterPixelRatio),(()=>this._resetAllLabels())),this.view.resourceController.scheduler.registerTask(j.LABELER,this)]),this._textTextureAtlas=new S({view:this.view}),this._hudMaterialCollection=new A(this.view._stage),this._calloutMaterialCollection=new A(this.view._stage)}dispose(){this.removeAllHandles(),this._textTextureAtlas=a(this._textTextureAtlas),this._hudMaterialCollection=a(this._hudMaterialCollection),this._calloutMaterialCollection=a(this._calloutMaterialCollection),this._labelingContexts.length=0,this._labels.clear()}destroy(){this.dispose(),W.graphic=null,W.renderingInfo=null,W.layer=null}_activateLabelingContext(e){e.graphics.forEach(((t,s)=>{const i=new O(e,t);this._labels.set(s,i),e.labelsToInitialize.set(s,i),t.setVisibilityFlag(g.LABEL,m.USER,!0)})),e.active=!0}_deactivateLabelingContext(e){e.graphics.forEach(((e,t)=>{e.setVisibilityFlag(g.LABEL,m.USER,!1),this.setLabelGraphicVisibility(e,!1),e.clearLabelGraphics(),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];s&&(e.textureAtlasHandles.push(this._textTextureAtlas.addText(s,(e=>M(t.stageObject,e)))),U(t.stageObject,s))}}_removeLabelTextureFromAtlas(e){e.textureAtlasHandles.forEach((e=>e.remove())),e.textureAtlasHandles.length=0}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),E}_updateLabels(e){if(this._dirty){this._dirty=!1;for(const t of this._labelingContexts)if(t.active)if(H(t))this._dirty=!0;else if(k(t.labelClassContexts)){if(null===t.labelClassContexts){this._deactivateLabelingContext(t);continue}this._createLabelClassContext(t),this._dirty=!0}else for(const[s,i]of t.labelsToInitialize)if(this._ensureGraphics3DResources(i)&&(this._labels.set(s,i),this.deconflictor.setDirty(),e.madeProgress()),(i.visible&&i.textInitialized||!i.visible&&i.hasGraphics3DResources)&&(t.labelsToInitialize.delete(s),e.madeProgress()),e.done){this._dirty=!0;break}this._dirty||this.notifyChange("updating")}}async _createLabelClassContextAsync(e){const t=e.labelClassAbortController?.signal;e.layer.when&&await e.layer.when(),o(t),e.scaleVisibility?.updateScaleRangeActive();const a=e.graphics3DCore,r=a.layer,n=r.labelingInfo?.filter((e=>!!e.symbol));if(!n||0===n.length)return;let c=!1;await s(n,(async(s,r)=>{const n=s.symbol,h=_(a.getOrCreateGraphics3DSymbol(n));if(null==h)return void l.getLogger(this).error("Failed to create Graphics3DSymbol for label");await h.load(),o(t);let b=null;y(n)&&n.hasVisibleCallout()&&(b=f(n,a.symbolCreationContext),await b.load(),o(t));const p=await i(d(s,e.layer.fieldsIndex,this.view.spatialReference));if(o(t),!0===p.ok){const i=await this._createTextRenderParameters(h.symbol);o(t),e.labelClassContexts[r]=new V(s,h,b,i,p.value)}else l.getLogger(this).error(`Label expression failed to evaluate: ${p.error}`),c=!0})),o(t)}async _createLabelClassContext(e){return null==e.labelClassPromise&&(e.labelClassPromise=this._createLabelClassContextAsync(e).catch((t=>{if(n(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.at(0);return"text"!==t?.type?null:T.fromSymbol(t,this.view.state.rasterPixelRatio)}_destroyLabelClassContext(e){for(const s of e.labelClassContexts)--s.graphics3DSymbol.referenced;const t=e.labelClassAbortController;e.labelClassAbortController=new AbortController,r(t),e.labelClassContexts.length=0,e.labelClassPromise=null,this.notifyChange("updating")}_createTextSymbolGraphic(e,t,s,i,l,a){const r=new v(s,G(s.anchor),D(s.anchor),e.text,p(e.displayWidth,e.displayHeight));return W.graphic=t,W.layer=i,W.renderingInfo=null,l.createLabel(W,r,this._hudMaterialCollection,this._textTextureAtlas,(()=>a.placement?.elevationOffset??null))}_createLineCalloutGraphic(e,t,s,i,l){W.graphic=e,W.layer=l;const a=i.screenOffset[0];return W.renderingInfo=new C(null,t,i.translation,i.centerOffset,a,i.centerOffsetUnits,i.elevationOffset,this._calloutMaterialCollection),s.createGraphics3DGraphic(W)}_ensureGraphics3DResources(e){if(e.hasGraphics3DResources)return!1;const t=e.graphics3DGraphic;if(t.destroyed)return!1;this._ensureTextTextureResources(e);const s=e.labelingContext,i=s.labelClassContexts;if(k(i)||!s.emptySymbolLabelSupported&&0===t.layers.length)return!1;let l=!1;const a=t.graphic,r=s.layer,o=N(s.layer);for(let n=0;n<i.length;n++){const c=e.textRenderers[n],h=e.textLabelPlacements[n];if(null==c||null==h)continue;const b=i[n],p=b.graphics3DSymbol,u=B(p),d=p.symbolLayers[0];if(!d)continue;d.setElevationInfoOverride(s.elevationInfoOverride);const y=new L(t,u,b.labelClass),f=this._createTextSymbolGraphic(c,a,h,r,d,y);if(null==f)return!1;f._labelClass=b.labelClass,f._labelIndex=n,t.addLabelGraphic(f,s.stageLayer),t.deconflictionPriority=b.textRenderParameters?.definition.size??0,t.setVisibilityFlag(g.LABEL,m.USER,o),t.setVisibilityFlag(g.LABEL,m.SCALE_RANGE,!0),t.setVisibilityFlag(g.LABEL,m.DECONFLICTION,!1),l=!0;const C=b.graphics3DCalloutSymbolLayer;if(C&&h.hasLabelVerticalOffset){C.setElevationInfoOverride(s.elevationInfoOverride);const e=this._createLineCalloutGraphic(a,u,C,h,r);null!=e&&(b.calloutSymbolLayerIndex=t.labelLayers.length,t.addLabelGraphic(e,s.stageLayer))}break}return l&&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];e?.onRemoveGraphic(s)}e.graphics3DGraphic.deconflictionPriority=0,e.graphics3DGraphic.clearLabelGraphics(),e.hasGraphics3DResources=!1}_ensureTextTextureResources(e){if(e.textInitialized)return;const t=e.labelingContext,s=t.labelClassContexts;if(k(s))return;const i=e.graphics3DGraphic.graphic;for(let a=0;a<s.length;a++){const r=s[a];if(e.textRenderers[a]=null,e.textLabelPlacements[a]=null,null==r?.textRenderParameters)continue;const o=r.labelFunction;let n;if("arcade"===o.type)try{const e=o.needsHydrationToEvaluate()?u(i,t.layer):i;n=o.evaluate(e)}catch(l){n=null}else n=o.evaluate(i);if(null==n||""===n||/^\s+$/.test(n))continue;const c=r.graphics3DSymbol;if(!c.symbolLayers[0])continue;const h=e.graphics3DGraphic,b="label-3d"===c.symbol?.type?c.symbol:null,p=r.labelClass,d=t.disablePlacement,y=new L(h,b,p,d).placement;if(null==y)continue;const g=G(y.anchor),m=w(g);e.textRenderers[a]=new I(n,m,r.textRenderParameters,S.maxSize),e.textLabelPlacements[a]=y}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 i=new O(e,t);this._labels.set(s,i),e.labelsToInitialize.set(s,i)}this.setDirty(),this.deconflictor.setDirty()}_updateGraphicGeometry(e,t){const s=t.graphic.uid,i=this._labels.get(s);if(!i)return!0;for(const l of i.graphics3DGraphic.labelLayers){if(null==l._labelClass)continue;if(!e.labelClassContexts[l._labelIndex].graphics3DSymbol.symbolLayers[0].updateGeometry(l,t.graphic.geometry))return!1}return this.setDirty(),this.deconflictor.setDirty(),!0}_removeGraphic(e,t){const s=t.graphic.uid,i=this._labels.get(s);e.graphics.delete(s),i&&(this._destroyGraphic(i,s),e.labelsToInitialize.delete(s),this.setDirty(),this.deconflictor.setDirty())}_destroyGraphic(e,t){this._labels.delete(t),e.textureAtlasHandles.length&&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 i=new Map;t.graphics.forEach((e=>i.set(e.graphic.uid,e)));const l=e=>e.labelLayers[0];if(s.graphics3DSymbol.symbolLayers[0].globalPropertyChanged(e,i,l),s.graphics3DCalloutSymbolLayer){const t=e=>e.labelLayers[s.calloutSymbolLayerIndex];s.graphics3DCalloutSymbolLayer.globalPropertyChanged(e,i,t)}}}_visibilityInfoChange(e){const t=N(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 i=this._labels.get(s);i&&(this._destroyGraphic(i,s),i.visible=!1,e.labelsToInitialize.set(s,i))})),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 i=s?.emptySymbolLabelSupported||!1,l=s?.elevationInfoOverride||null,a=s?.disablePlacement||null;if(this._findLabelingContext(e))return;const r=e.layer,o=new z(this.view._stage,r,e,t,i,l,a,N(r));return this._labelingContexts.push(o),this.setDirty(),{addGraphic:e=>this._addGraphic(o,e),removeGraphic:e=>this._removeGraphic(o,e),updateGraphicGeometry:e=>this._updateGraphicGeometry(o,e),layerLabelsEnabled:()=>N(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),remove:()=>this._removeGraphicsOwner(e),setDirty:()=>this.setDirty()}}_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))),t.destroy(),this.setDirty()}setLabelGraphicVisibility(e,t){const s=e.graphic.uid,i=this._labels.get(s);i&&i.visible!==t&&(t&&!i.textureAtlasHandles.length?(this._addLabelTextureToAtlas(i),i.textInitialized||i.labelingContext.labelsToInitialize.set(s,i)):!t&&i.textureAtlasHandles.length&&this._removeLabelTextureFromAtlas(i),i.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=>H(e)))}get updatingProgress(){if(!this.updating||!this._textTextureAtlas)return 1;const e=this._labelingContexts.length>0?this._labelingContexts.reduce(((e,t)=>e+(H(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(){}};function U(e,t){e.geometries[0].setAttributeData(R.SIZE,[t.displayWidth,t.displayHeight]),e.geometryVertexAttributeUpdated(e.geometries[0],R.SIZE)}function M(e,t){e.geometries[0].setAttributeData(R.UV0,t),e.geometryVertexAttributeUpdated(e.geometries[0],R.UV0,!0)}function H(e){return!!e.labelClassPromise&&!!e.labelClassAbortController}function k(e){return!e||0===e.length}function B(e){return"label-3d"===e.symbol?.type?e.symbol:null}function N(e){return!0===e.labelsVisible&&!!e.labelingInfo?.some((e=>!!e.symbol))}e([h({constructOnly:!0})],F.prototype,"view",void 0),e([h({constructOnly:!0})],F.prototype,"deconflictor",void 0),e([h()],F.prototype,"_textTextureAtlas",void 0),e([h({type:Boolean,readOnly:!0})],F.prototype,"updating",null),F=e([b("esri.views.3d.layers.graphics.Labeler")],F);const W=new x(null,null,null);export{F as Labeler,N 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.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import r from"../../../../../core/Error.js";import{makeHandle as t}from"../../../../../core/handleUtils.js";import{destroyMaybe as o}from"../../../../../core/maybe.js";import i from"../../../../../core/Promise.js";import{on as n}from"../../../../../core/reactiveUtils.js";import{property as s}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators/subclass.js";import{FeatureLayerViewPerformanceInfo as u}from"../../FeatureLayerViewPerformanceInfo.js";import{Feature3DPipelineWorkerHandle as l}from"./Feature3DPipelineWorkerHandle.js";import{FeaturePipelineRenderManager as d}from"./rendering/FeaturePipelineRenderManager.js";import{emptyHighlightHandle as p}from"../../support/highlightUtils.js";import{LayerViewPerformanceInfo as m}from"../../support/LayerViewPerformanceInfo.js";import{UpdatePolicy as c}from"../../../webgl-engine/lib/UpdatePolicy.js";let y=class extends i{constructor(e){super(e),this._renderer=null,this.graphicsQuery={queryForSymbologySnapping:(e,t)=>{throw new r("unsupported-symbology-snapping")},executeQuery:async(e,r)=>await this._workerHandle.executeQuery(e,r),executeQueryForIds:async(e,r)=>await this._workerHandle.executeQueryForIds(e,r),executeQueryForCount:async(e,r)=>await this._workerHandle.executeQueryForCount(e,r),executeQueryForExtent:async(e,r)=>await this._workerHandle.executeQueryForExtent(e,r),executeQueryForLatestObservations:async(e,r)=>await this._workerHandle.executeQueryForLatestObservations(e,r)},this.maximumNumberOfFeatures=1e3}initialize(){if("point"!==this.layerView.layer.geometryType)throw new r("unsupported-geometry-type",`${this.layerView.layer.geometryType} is not supported`);this.addResolvingPromise(this.setup())}destroy(){this.removeAllHandles(),this._workerHandle.destroy(),o(this._renderer)}async setup(){const{layer:e,view:r}=this.layerView,{spatialReference:t,renderSpatialReference:o,resourceController:i}=r,s=r.state.viewingMode;if(this._renderer=new d({view:r,layerUid:e.uid}),"feature"!==e.type)throw new Error("Only FeatureLayer is supported");const a=new l({schedule:e=>i.immediate.schedule(e),layer:e,viewSpatialReference:t,renderSpatialReference:o,viewingMode:s,
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import r from"../../../../../core/Error.js";import{makeHandle as t}from"../../../../../core/handleUtils.js";import{destroyMaybe as o}from"../../../../../core/maybe.js";import i from"../../../../../core/Promise.js";import{on as n}from"../../../../../core/reactiveUtils.js";import{property as s}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators/subclass.js";import{FeatureLayerViewPerformanceInfo as u}from"../../FeatureLayerViewPerformanceInfo.js";import{Feature3DPipelineWorkerHandle as l}from"./Feature3DPipelineWorkerHandle.js";import{FeaturePipelineRenderManager as d}from"./rendering/FeaturePipelineRenderManager.js";import{emptyHighlightHandle as p}from"../../support/highlightUtils.js";import{LayerViewPerformanceInfo as m}from"../../support/LayerViewPerformanceInfo.js";import{UpdatePolicy as c}from"../../../webgl-engine/lib/UpdatePolicy.js";let y=class extends i{constructor(e){super(e),this._renderer=null,this.graphicsQuery={queryForSymbologySnapping:(e,t)=>{throw new r("unsupported-symbology-snapping")},executeQuery:async(e,r)=>await this._workerHandle.executeQuery(e,r),executeQueryForIds:async(e,r)=>await this._workerHandle.executeQueryForIds(e,r),executeQueryForCount:async(e,r)=>await this._workerHandle.executeQueryForCount(e,r),executeQueryForExtent:async(e,r)=>await this._workerHandle.executeQueryForExtent(e,r),executeQueryForLatestObservations:async(e,r)=>await this._workerHandle.executeQueryForLatestObservations(e,r)},this.maximumNumberOfFeatures=1e3}initialize(){if("point"!==this.layerView.layer.geometryType)throw new r("unsupported-geometry-type",`${this.layerView.layer.geometryType} is not supported`);this.addResolvingPromise(this.setup())}destroy(){this.removeAllHandles(),this._workerHandle.destroy(),o(this._renderer)}async setup(){const{layer:e,view:r}=this.layerView,{spatialReference:t,renderSpatialReference:o,resourceController:i}=r,s=r.state.viewingMode;if(this._renderer=new d({view:r,layerUid:e.uid}),"feature"!==e.type)throw new Error("Only FeatureLayer is supported");const a=new l({schedule:e=>i.immediate.schedule(e),layer:e,viewSpatialReference:t,renderSpatialReference:o,viewingMode:s,renderer:this._renderer});this._workerHandle=await a.when(),this.addHandles([this.layerView.view.featureTiles.addClient(),n((()=>this.layerView.view.featureTiles.tiles),"change",(e=>{this._workerHandle.onTileTreeChange(e)}),{onListenerAdd:e=>this._workerHandle.onTileTreeChange({added:e.toArray(),removed:[]}),onListenerRemove:e=>this._workerHandle.onTileTreeChange({added:[],removed:e.toArray()})})])}get legendEnabled(){return!1}get hasAllFeatures(){return!1}get hasAllFeaturesInView(){return!1}get hasFullGeometries(){return!1}get symbologySnappingSupported(){return!1}get scaleVisibilitySuspended(){return!1}get suspendInfo(){return{}}get updating(){return this._workerHandle.updating}get dataUpdating(){return!1}get updatePolicy(){return c.ASYNC}get maximumNumberOfFeaturesExceeded(){return!1}get updatingProgressValue(){return 1}get usedMemory(){return this._renderer?.usedMemory??0}get unloadedMemory(){return 0}get ignoresMemoryFactor(){return!0}get totalFeatures(){return this._renderer?.totalFeatures??0}get performanceInfo(){const e=this.totalFeatures;return new u(new m(this.usedMemory,e,e,this.maximumNumberOfFeatures,0,null),e,e,this.maximumNumberOfFeaturesExceeded,"tiles","n/a")}get suspendResumeExtentMode(){return"computed"}forEachGraphic(e){}findGraphic(e){return null}highlight(e){return p}maskOccludee(e){return t()}async whenGraphicBounds(e,r){return null}computeAttachmentOrigin(e,r){return null}elevationAlignPointsInFeatures(e,t){throw new r("unsupported-elevation-alignment")}async doRefresh(e){}setVisibility(e,r){}getMissingAttributesForFeature(e){return null}getHydratedGeometry(e){return null}};e([s()],y.prototype,"layerView",void 0),e([s()],y.prototype,"updating",null),e([s()],y.prototype,"totalFeatures",null),y=e([a("esri.views.3d.layers.graphics.pipeline.Feature3DPipeline")],y);export{y as Feature3DPipeline};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Evented.js";import{throwIfAborted as r}from"../../../../../core/promiseUtils.js";import{watch as a,initial as i}from"../../../../../core/reactiveUtils.js";import{property as n}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import s from"../../../../../geometry/Extent.js";import{initializeProjection as u,project as l}from"../../../../../geometry/projection.js";import m from"../../../../../geometry/SpatialReference.js";import{QueryEngine as d}from"../../../../../layers/graphics/data/QueryEngine.js";import c from"../../../../../rest/support/Query.js";import{Tile3DManager as p}from"./Tile3DManager.js";import{FeatureData as f}from"./featureData/FeatureData.js";import{FeatureDataStore as h}from"./featureData/FeatureDataStore.js";import{TiledFeatureStore as y}from"./featureSet/TiledFeatureStore.js";import{Tile3DFetcher as _}from"./fetching/Tile3DFetcher.js";import{RenderCommandContext as g}from"./rendering/RenderCommandContext.js";import{UniqueValueFeatureRenderer as S}from"./symbolization/UniqueValueFeatureRenderer.js";import{RenderCoordsHelper as w}from"../../../support/RenderCoordsHelper.js";let C=class extends t.EventedAccessor{constructor(){super(...arguments),this.remoteClient=null,this._featureDataStore=new h,this._featureStore=new y,this._tileManager=null,this._renderer=null,this._fetcher=null,this._queryEngine=null,this._defaultQueryJSON=null}get updating(){return this._tileManager.updating}destroy(){this._featureStore.clear(),this._tileManager?.destroy()}async setup({viewSpatialReference:e,renderSpatialReference:t,viewingMode:r,baseQuery:n,url:o,objectIdField:f,capabilities:h,fieldsIndex:y,timeInfo:C,fullExtent:j}){const v=m.fromJSON(e),x=m.fromJSON(t);this._fetcher=new _(v,c.fromJSON(n),o,f,h),this._queryEngine=new d({hasZ:!0,hasM:!1,geometryType:"esriGeometryPoint",objectIdField:f,fieldsIndex:y,availableFields:[f],spatialReference:e,featureStore:this._featureStore,timeInfo:C}),this._renderer=new S({viewSpatialReference:v,renderSpatialReference:x,renderCoordsHelper:w.create(r,x),renderCommandContext:new g(r,(async(e,t)=>{const r={materialId:e,type:t};await this.remoteClient.invoke("createMaterial",r)}),(async e=>{const t={materialId:e};await this.remoteClient.invoke("createDirectRenderer",t)}),(async(e,t,r)=>{const a={rendererId:e,lodRenderGeometry:t};await this.remoteClient.invoke("createLoDRenderer",a,{transferList:r})}),(async(e,t)=>{const r={commands:e};await this.remoteClient.invoke("dispatchRenderCommands",r,{transferList:t})}))}),this._defaultQueryJSON=new c({outSpatialReference:v}).toJSON();let R=null;if(null!=j){const e=s.fromJSON(j);await u(e.spatialReference,v),R=l(e,v)}return this._tileManager=new p({loadTile:(e,t)=>this._fetcher.fetch(e,t),createAddTileCommand:(e,t)=>this._createAddTileCommand(e,t),createRemoveTileCommand:e=>this._createRemoveTileCommand(e),extent:R}),this.addHandles(a((()=>this.updating),(e=>{this.emit("notify-updating",{updating:e})})),i),await this._renderer.load(),Q}async executeQuery(e,t){return{result:await this._queryEngine.executeQuery(this._ensureQuery(e),t)}}async executeQueryForIds(e,t){const r=await this._queryEngine.executeQueryForIdSet(this._ensureQuery(e),t);return{result:Array.from(r)}}async executeQueryForCount(e,t){return{result:await this._queryEngine.executeQueryForCount(this._ensureQuery(e),t)}}async executeQueryForExtent(e,t){return{result:await this._queryEngine.executeQueryForExtent(this._ensureQuery(e),t)}}async executeQueryForLatestObservations(e,t){return{result:await this._queryEngine.executeQueryForLatestObservations(this._ensureQuery(e),t)}}async onTileTreeChange(e){return await this._tileManager.onTileTreeChange(e),Q}async _createAddTileCommand(e,t){const a=new f(e),i=await this._renderer.createAddCommand(a);return r(t),i.appendPipelineStateCommand((()=>{this._featureDataStore.add(a),this._featureStore.addTile(e)})),i}async _createRemoveTileCommand(e){const t=this._featureStore,r=this._featureDataStore,a=this._renderer,i=r.get(e);if(null==i)return null;const n=await a.createRemoveCommand(i.id);return n.appendPipelineStateCommand((()=>{r.remove(e),t.removeTile(e)})),n}_ensureQuery(e){return e??this._defaultQueryJSON}};e([n()],C.prototype,"updating",null),C=e([o("esri.views.3d.layers.graphics.pipeline.Feature3DPipelineWorker")],C);const j=C,Q={result:void 0};export{j 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.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import r from"../../../../../core/Promise.js";import{property as t}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import{WorkerHandle as n}from"../../../../../core/workers/WorkerHandle.js";import i from"../../../../../geometry/Extent.js";import a from"../../../../../rest/support/FeatureSet.js";let s=class extends r{constructor(e){super(e),this.schedule=null,this._workerUpdating=!0}get updating(){return this._workerUpdating}initialize(){this._workerHandle=new d(this.schedule,{createMaterial:async({materialId:e,type:r})=>(await this.renderer.createMaterial(e,r),u),createDirectRenderer:async({materialId:e})=>(await this.renderer.createDirectRenderer(e),u),createLoDRenderer:async({rendererId:e,lodRenderGeometry:r},t)=>(await this.renderer.createLoDRenderer(e,r,t?.signal??void 0),u),dispatchRenderCommands:async({commands:e})=>(await this.renderer.executeRenderCommands(e),u)});const{layer:e,viewSpatialReference:r,renderSpatialReference:t}=this;this.addResolvingPromise((async()=>{await e.load();const{fullExtent:o}=e;await this._workerHandle.invokeMethod("setup",{url:e.parsedUrl?.path??"",baseQuery:e.createQuery().toJSON(),viewSpatialReference:r.toJSON(),renderSpatialReference:t.toJSON(),viewingMode:this.viewingMode,objectIdField:e.objectIdField,capabilities:e.capabilities,timeInfo:e.timeInfo?.toJSON(),fieldsIndex:e.fieldsIndex.toJSON(),fullExtent:o?.toJSON()})})()),this.addHandles(this._workerHandle.on("notify-updating",(({updating:e})=>{this._workerUpdating=e})))}onTileTreeChange({added:e,removed:r}){if(0===e.length&&0===r.length)return;const t=e.map(c),o=r.map(c);this._workerHandle.invokeMethod("onTileTreeChange",{added:t,removed:o})}async executeQuery(e,r){const t=await this._workerHandle.invokeMethod("executeQuery",e?.toJSON(),r),o=a.fromJSON(t);return this._ensureLayerOnFeatures(o),o}async executeQueryForIds(e,r){return await this._workerHandle.invokeMethod("executeQueryForIds",e?.toJSON(),r)}async executeQueryForCount(e,r){return await this._workerHandle.invokeMethod("executeQueryForCount",e?.toJSON(),r)}async executeQueryForExtent(e,r){const{count:t,extent:o}=await this._workerHandle.invokeMethod("executeQueryForExtent",e?.toJSON(),r);return{count:t,extent:i.fromJSON(o)}}async executeQueryForLatestObservations(e,r){const t=await this._workerHandle.invokeMethod("executeQueryForLatestObservations",e?.toJSON(),r),o=a.fromJSON(t);return this._ensureLayerOnFeatures(o),o}_ensureLayerOnFeatures(e){const{layer:r}=this;for(const t of e.features)t.layer=r,t.sourceLayer=r}};e([t()],s.prototype,"updating",null),e([t({constructOnly:!0})],s.prototype,"schedule",void 0),e([t({constructOnly:!0})],s.prototype,"layer",void 0),e([t({constructOnly:!0})],s.prototype,"viewSpatialReference",void 0),e([t({constructOnly:!0})],s.prototype,"renderSpatialReference",void 0),e([t({constructOnly:!0})],s.prototype,"viewingMode",void 0),e([t({constructOnly:!0})],s.prototype,"renderer",void 0),e([t()],s.prototype,"_workerUpdating",void 0),s=e([o("esri.views.3d.layers.graphics.pipeline.Feature3DPipelineWorkerHandle")],s);class d extends n{constructor(e,r){super("Feature3DPipelineWorker","setup",{},e,{strategy:"dedicated",client:r})}}function c({id:e,lij:r,extent:t}){return{id:e,lij:r,extent:t}}const u={result:void 0};export{s as Feature3DPipelineWorkerHandle};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
class e{constructor(e,n){this._renderCommands=e,this._pipelineStateCommands=n}append(e){this.appendRenderCommands(e._renderCommands),this.appendPipelineStateCommands(e._pipelineStateCommands)}appendRenderCommands(e){this._renderCommands.append(e)}appendPipelineStateCommand(e){this._pipelineStateCommands.push(e)}appendPipelineStateCommands(e){const{_pipelineStateCommands:n}=this;for(const
|
|
5
|
+
class e{constructor(e,n){this._renderCommands=e,this._pipelineStateCommands=n}append(e){this.appendRenderCommands(e._renderCommands),this.appendPipelineStateCommands(e._pipelineStateCommands)}appendRenderCommands(e){this._renderCommands.append(e)}appendPipelineStateCommand(e){this._pipelineStateCommands.push(e)}appendPipelineStateCommands(e){const{_pipelineStateCommands:n}=this;for(const a of e)n.push(a)}async execute(){for(const e of this._pipelineStateCommands)e();await this._renderCommands.dispatch()}}export{e as PipelineCommand};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{baseObjectMemory as t}from"../../../../../../core/memoryEstimations.js";class
|
|
5
|
+
import{baseObjectMemory as t}from"../../../../../../core/memoryEstimations.js";import{generateId as e}from"../utils.js";class i{constructor(t,i){this.tile=t,this._tileIndices=i,this.id=e(`featureData-${t.id}-`)}get featureCount(){return this._tileIndices?.length??this.tile.featureCount}get usedMemory(){return t+(this._tileIndices?.byteLength??0)}get extent(){return this.tile.descriptor.extent}readObjectIds(t,e){const{_tileIndices:i,tile:r}=this;return r.readObjectIds(t,i,e)}readCoordinates(t,e){const{_tileIndices:i,tile:r}=this;return r.readCoordinates(t,i,e)}subset(t){const{_tileIndices:e,tile:r}=this;if(null==e)return new i(r,t);const s=new Uint32Array(t.length);for(let i=0;i<s.length;++i)s[i]=e[t[i]];return new i(r,s)}}export{i as FeatureData};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{create as e}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBuffer as r}from"../../../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as t}from"../../../../../../geometry/projection/projectVectorToVector.js";import{center as o}from"../../../../../../geometry/support/aaBoundingRect.js";function n(e
|
|
5
|
+
import{create as e}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBuffer as r}from"../../../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as t}from"../../../../../../geometry/projection/projectVectorToVector.js";import{center as o}from"../../../../../../geometry/support/aaBoundingRect.js";function n(e){const{featureCount:r}=e;if(0===r)return new Uint32Array;const t=new Uint32Array(r);return e.readObjectIds(t),t}function a(e){const{featureCount:r}=e;if(0===r)return new Float64Array;const t=new Float64Array(3*r);return e.readCoordinates(t),t}function i(e,t){const{featureCount:o}=e;if(0===o)return new Float64Array;const n=a(e),i=t.viewSpatialReference,c=t.renderSpatialReference,f=new Float64Array(3*o);if(!r(n,i,0,f,c,0,o))throw new Error("Failed to project coordinates");return f}function c(r,n){const a=n.viewSpatialReference,i=n.renderSpatialReference,{extent:c}=r,f=o(c),u=e();return t([f[0],f[1],0],a,u,i),u}export{i as computeRenderCoordinates,c as computeTileCenterRenderCoordinates,a as readMapCoordinates,n as readObjectIds};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../../chunks/tslib.es6.js";import{nullUid as
|
|
5
|
+
import{_ as e}from"../../../../../../chunks/tslib.es6.js";import{nullUid as t}from"../../../../../../core/uid.js";import{property as r}from"../../../../../../core/accessorSupport/decorators/property.js";import"../../../../../../core/has.js";import"../../../../../../core/Logger.js";import"../../../../../../core/RandomLCG.js";import{subclass as i}from"../../../../../../core/accessorSupport/decorators/subclass.js";import{glLayout as s}from"../../../../support/buffer/glUtil.js";import{ShaderOutput as n}from"../../../../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as o}from"../../../../webgl-engine/effects/RenderPlugin.js";import{GLMaterials as a}from"../../../../webgl-engine/lib/GLMaterials.js";import{IntersectorType as l}from"../../../../webgl-engine/lib/IntersectorInterfaces.js";import{BoundingVolume as c}from"../../../../webgl-engine/lib/Object3D.js";import{RenderSlot as u}from"../../../../webgl-engine/lib/RenderSlot.js";import{DrawParameters as m}from"../../../../webgl-engine/materials/DrawParameters.js";import{HUDMaterial as d}from"../../../../webgl-engine/materials/HUDMaterial.js";let h=class extends o{constructor(e){super(e),this._glMaterials=null,this._produces=new Map,this._renderGeometries=new Map,this._vaoCache=null,this._drawParameters=new m,this._bufferWriter=null,this.slicePlaneEnabled=!1,this.isGround=!1,this.type=e.material instanceof d?l.HUD:l.OBJECT,this.layerUid=e.layerUid}get produces(){return this._produces}get numFeatures(){const e=6;let t=0;return this._renderGeometries.forEach((r=>t+=r.numElements/e)),t}get usedMemory(){let e=0;return this._renderGeometries.forEach((t=>{e+=t.vao.usedMemory})),e}intersect(e,r,i,s,n,o){const{material:a,_bufferWriter:l,layerUid:u}=this,m=this._renderGeometries;if(0!==m.size&&null!=l.intersect)for(const[d,h]of m){const{buffer:r,localOrigin:n,items:o}=h;l.intersect(r.data,a.parameters,n,e,i,s,((r,i,s,n,l,m)=>{const d=o.objectIds[s];o.visibilities[s]&&e.handleObjectIntersection({object:{id:t,graphicUid:d,layerUid:u,boundingVolumeWorldSpace:new c,geometries:[{material:a}]},geometryId:0,primIndex:s},r,i,n,null,l,m)}))}}initialize(){this._bufferWriter=this.material.createBufferWriter(),this.material.produces.forEach(((e,t)=>{this._produces.set(t,(t=>t!==n.Highlight&&t!==n.ShadowHighlight&&e(t)))}))}destroy(){this._glMaterials.dispose();const e=this._renderGeometries.keys();for(const t of e)this.removeRenderGeometry(t)}acquireTechniques(e){const t=this.material;if(!t.shouldRender(e))return null;const{output:r,bind:i}=e,s=t.produces.get(i.slot);if(!s?.(r))return null;if(r===n.Highlight||r===n.ShadowHighlight)return null;const o=this._glMaterials.load(e.rctx,i.slot,r);return o?.beginSlot(i)}render(e,t){const r=this._renderGeometries;if(0===r.size)return;const{bind:i}=e,s=i.slot===u.OCCLUDER_MATERIAL||i.slot===u.TRANSPARENT_OCCLUDER_MATERIAL?i.slot:null,n=e.rctx;n.runAppleAmdDriverHelper(),n.bindTechnique(t,i,this.material.parameters);const o=t.program;for(const[a,l]of r){const{vao:e,localOrigin:r,drawCalls:a}=l;this._drawParameters.origin=r,o.bindDraw(i,this.material.parameters,this._drawParameters),t.ensureAttributeLocations(e),n.bindVAO(e),n.setPipelineState(t.getPipeline(!1,s));for(const i of a)n.drawArrays(t.primitiveType,i.start,i.count)}}initializeRenderContext(e,t){this._glMaterials=new a(this.material,e.materials),this._vaoCache=e.renderContext.rctx.getVaoCache(this.material.vertexAttributeLocations,s(this._bufferWriter.vertexBufferLayout))}uninitializeRenderContext(){}addRenderGeometry(e,t,r,i){this.removeRenderGeometry(e);const{data:s,elementCount:n}=t,o=this._vaoCache.newVao(s.byteLength);o.vertexBuffers.get("geometry").setSubData(new Uint8Array(s),0,0,s.byteLength);const a={localOrigin:i,numElements:n,buffer:t,items:r,vao:o,drawCalls:this._produceDrawCalls(r)};return this._renderGeometries.set(e,a),a}updateRenderGeometryVisibility(e,t){const r=this._renderGeometries.get(e);if(null==r)return;const{items:i}=r;if(i.visibilities.length!==t.length)throw new Error("Unexpected mismatch between old and new visibiltiy flag buffer length.");i.visibilities=t,r.drawCalls=this._produceDrawCalls(i)}removeRenderGeometry(e){const t=this._renderGeometries.get(e);null!=t&&(this._vaoCache.deleteVao(t.vao),this._renderGeometries.delete(e))}hasHighlightOptions(e){return!1}_produceDrawCalls(e){const{visibilities:t,ranges:r}=e,i=[];if(p(r)){if(0===r.numItems)return[];const e=r.numVertices;let s=null;for(let n=0;n<r.numItems;++n){t[n]?null==s?(s={start:n*e,count:e},i.push(s)):s.count+=e:s=null}}else{const e=r.counts,s=e.length;if(0===s)return[];let n=null,o=0;for(let r=0;r<s;++r){const s=t[r],a=e[r];s?null==n?(n={start:o,count:a},i.push(n)):n.count+=a:n=null,o+=a}}return i}};function p(e){return"numItems"in e}e([r({constructOnly:!0})],h.prototype,"material",void 0),h=e([i("esri.views.3d.layers.graphics.pipeline.rendering.DirectRenderer")],h);export{h as DirectRenderer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../../chunks/tslib.es6.js";import r from"../../../../../../core/Accessor.js";import{makeHandle as t}from"../../../../../../core/handleUtils.js";import{releaseMaybe as s}from"../../../../../../core/maybe.js";import{
|
|
5
|
+
import{_ as e}from"../../../../../../chunks/tslib.es6.js";import r from"../../../../../../core/Accessor.js";import"../../../../../../core/has.js";import{makeHandle as t}from"../../../../../../core/handleUtils.js";import{releaseMaybe as s}from"../../../../../../core/maybe.js";import{createAbortError as i}from"../../../../../../core/promiseUtils.js";import{property as o}from"../../../../../../core/accessorSupport/decorators/property.js";import"../../../../../../core/Logger.js";import"../../../../../../core/RandomLCG.js";import{subclass as n}from"../../../../../../core/accessorSupport/decorators/subclass.js";import{ONES as a}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as d}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ViewingMode as l}from"../../../../../ViewingMode.js";import{namedAnchorToHUDMaterialAnchorPos as c}from"../../placementUtils.js";import{DirectRenderer as m}from"./DirectRenderer.js";import{LodRenderer as u}from"./LodRenderer.js";import{defaultBoundingBox as h,createTexture as p,requiresHalfTexelOffset as f}from"../../../../support/engineContent/sdfPrimitives.js";import{CullFaceOptions as y}from"../../../../webgl-engine/lib/basicInterfaces.js";import{DefaultMaterial as g}from"../../../../webgl-engine/materials/DefaultMaterial.js";import{HUDMaterial as w}from"../../../../webgl-engine/materials/HUDMaterial.js";import{schematicMRRFactors as R}from"../../../../webgl-engine/materials/pbrUtils.js";let v=class extends r{constructor(e){super(),this.view=null,this.layerUid=null,this._materials=new Map,this._directRenderers=new Map,this._lodRenderers=new Map,this.totalFeatures=0,this.view=e.view,this.layerUid=e.layerUid}initialize(){}destroy(){this.removeAllHandles(),this._lodRenderers.forEach((e=>e.destroy()))}async createMaterial(e,r){const{view:i}=this,{sharedSymbolResources:o}=i;if(null==o)throw new Error("No shared symbol resources found!");const{textures:n}=o,a=i.state.viewingMode===l.Global;let d=null;switch(r){case"default":d=_(o,{physicalBasedRenderingEnabled:!0,slicePlaneEnabled:!1,castShadows:!0,isPrimitive:!0,screenSizePerspectiveEnabled:!0,doublePrecisionRequiresObfuscation:i._stage.renderView.renderingContext.driverTest.doublePrecisionRequiresObfuscation.result},a);break;case"hud":{const[e,r]=b(n,a);this.addHandles([t((()=>s(r)))]),d=e}break;default:throw new Error(`unable to create unknown material type ${r}`)}this._materials.set(e,d)}async createDirectRenderer(e){if(this._directRenderers.has(e))return;const r=this._materials.get(e);if(null==r)throw new Error(`material not found ${e}`);const{view:t}=this,s=new m({material:r,layerUid:this.layerUid});this._directRenderers.set(e,s),t._stage.addRenderPlugin(s),t._stage.renderView.renderer.updateHasFlags()}async createLoDRenderer(e,r,t){const s=new u({view:this.view,layerUid:this.layerUid}),o=e=>this._materials.get(e);if(await s.doLoad(r,o,t),t?.aborted)throw s.destroy(),i();this._lodRenderers.set(e,s)}async executeRenderCommands(e){for(const r of e)switch(r.id){case"add-direct-renderer-geometry":this._addDirectRendererGeometry(r);break;case"update-direct-renderer-visibility":this._updateDirectRendererVisibility(r);break;case"remove-direct-renderer-geometry":this._removeDirectRendererGeometry(r);break;case"add-lod-instances":this._addLodInstances(r);break;case"remove-lod-instances":this._removeLodInstances(r)}e.length>0&&this._updateFeatureCount()}_updateFeatureCount(){let e=0;for(const r of this._directRenderers.values())e+=r.numFeatures;for(const r of this._lodRenderers.values())e+=r.numFeatures;this._set("totalFeatures",e)}get usedMemory(){let e=0;for(const r of this._directRenderers.values())e+=r.usedMemory;for(const r of this._lodRenderers.values())e+=r.usedMemory;return e}_addDirectRendererGeometry({renderGeometryId:e,materialId:r,renderGeometryBuffer:t,renderGeometryBufferItems:s,localOrigin:i}){const o=this._directRenderers.get(r);null!=o?(o.addRenderGeometry(e,t,s,i),this.view._stage.renderView.requestRender()):console.error("no renderer assigned to provided material")}_updateDirectRendererVisibility(e){const{materialId:r,renderGeometryId:t,visibility:s}=e,i=this._directRenderers.get(r);null!=i?(i.updateRenderGeometryVisibility(t,s),this.view._stage.renderView.requestRender()):console.error("no renderer assigned to provided material")}_removeDirectRendererGeometry({renderGeometryId:e,materialId:r}){const t=this._directRenderers.get(r);null!=t?t.removeRenderGeometry(e):console.error("no renderer assigned to provided material")}_addLodInstances({lodRendererId:e,renderGeometryId:r,data:t}){const s=this._lodRenderers.get(e);if(null==s)throw new Error("no lod renderer assigned to provided lod renderer Id");s.addInstances(r,t)}_removeLodInstances({lodRendererId:e,renderGeometryId:r}){const t=this._lodRenderers.get(e);if(null==t)throw new Error("no lod renderer assigned to provided lod renderer Id");t.removeInstances(r)}};function b(e,r){const t={anchorPosition:c.center,occlusionTest:!0,hasSlicePlane:!1,color:[1,0,0,1],outlineColor:[0,0,0,1],outlineSize:1,distanceFieldBoundingBox:h},s=null;if(null!=e){const r=e.fromData("circle-icon",(()=>p("circle")));t.textureId=r.texture.id,t.textureIsSignedDistanceField=!0,t.sampleSignedDistanceFieldTexelCenter=f("circle")}return[new w(t,r),s]}function _(e,r,t){const s={usePBR:r.physicalBasedRenderingEnabled,isSchematic:!0,mrrFactors:R,ambient:a,diffuse:a,hasSlicePlane:r.slicePlaneEnabled,castShadows:r.castShadows,offsetTransparentBackfaces:!r.isPrimitive};return I(s),r.screenSizePerspectiveEnabled&&(s.screenSizePerspective=e.screenSizePerspectiveSettings),s.externalColor=d,s.isInstanced=!0,new g(s,{spherical:t,doublePrecisionRequiresObfuscation:!0})}function I(e){const r=e.opacity??1,t=r<1;return e.transparent=t,e.opacity=r,e.cullFace=t?y.None:y.Back,e}e([o({readOnly:!0})],v.prototype,"totalFeatures",void 0),v=e([n("esri.views.3d.layers.graphics.pipeline.rendering.FeaturePipelineRenderManager")],v);export{v as FeaturePipelineRenderManager,_ as createDefaultMaterial,b as createHudMaterial};
|