@arcgis/core 5.0.0-next.41 → 5.0.0-next.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/arcade/featureset/sources/FeatureLayerOGC.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/00ff4ca88c9d291d82c3.js +1 -0
- package/assets/esri/core/workers/chunks/04a0685ee53ef74883aa.js +1 -0
- package/assets/esri/core/workers/chunks/{c320a29df40e85fb4a8e.js → 15a0750c10b510564a42.js} +1 -1
- package/assets/esri/core/workers/chunks/{816227de5bd42b437df4.js → 233f9eb617f3d72995b5.js} +1 -1
- package/assets/esri/core/workers/chunks/{fb9643b74cf35221ff98.js → 249504f7d356be80d214.js} +1 -1
- package/assets/esri/core/workers/chunks/{9d95f38da21f97214f83.js → 324d66962aeec17d3e28.js} +10 -10
- package/assets/esri/core/workers/chunks/385cfd3087f00dbd1146.js +1 -0
- package/assets/esri/core/workers/chunks/{4f4d51181ae7db9fbe6d.js → 4404b6f931f681cca342.js} +1 -1
- package/assets/esri/core/workers/chunks/555a0ea44ba77819d493.js +1 -0
- package/assets/esri/core/workers/chunks/6e8925412fb90f88d688.js +1 -0
- package/assets/esri/core/workers/chunks/83da9ee6544ee9d3c124.js +1 -0
- package/assets/esri/core/workers/chunks/{da517b4b07d4d27ce94c.js → 8e26831f71634288f834.js} +1 -1
- package/assets/esri/core/workers/chunks/{c367c7e553be3682f2db.js → 93c5f097bb7b380bb175.js} +1 -1
- package/assets/esri/core/workers/chunks/9c7682b300b877f60095.js +1 -0
- package/assets/esri/core/workers/chunks/{f3b3b193959db809c8c6.js → ab520fd1ae917daf07d8.js} +1 -1
- package/assets/esri/core/workers/chunks/{2c9865e34f32fb5683e5.js → af8d6e6949930d0e6c7b.js} +1 -1
- package/assets/esri/core/workers/chunks/c9942ca57f542582ab4d.js +1 -0
- package/assets/esri/core/workers/chunks/d5fd6d0eaf96edfab123.js +1 -0
- package/assets/esri/core/workers/chunks/da2ba40bc017bff0fe49.js +1 -0
- package/assets/esri/core/workers/chunks/e5a6a646f27715152714.js +1 -0
- package/assets/esri/core/workers/chunks/e8a9971c8354569cb81d.js +1 -0
- package/assets/esri/core/workers/chunks/ed550bf27f2bbf8d30fa.js +1 -0
- package/assets/esri/core/workers/chunks/ee186ddbb1eb5144a790.js +1 -0
- package/assets/esri/core/workers/chunks/{1357cc637524cd254974.js → ffcdc7ae03b0570e0db8.js} +1 -1
- package/assets/esri/themes/base/widgets/_Attribution.scss +1 -1
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/config.js +1 -1
- package/core/PooledArray.js +1 -1
- package/geometry/FlatGeometry.js +1 -1
- package/geometry/support/MeshMaterialMetallicRoughness.js +1 -1
- package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
- package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
- package/interfaces.d.ts +31 -35
- package/kernel.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/sources/support/clientSideDefaults.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/symbols/LabelSymbol3D.js +1 -1
- package/symbols/MeshSymbol3D.js +1 -1
- package/views/2d/ViewStateManager.js +1 -1
- package/views/2d/engine/webgl/cpuMapped/MappedMesh.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/typed/TypedShaderProgram.js +1 -1
- package/views/2d/engine/webgl/textureUtils.js +1 -1
- package/views/2d/layers/CatalogDynamicGroupLayerView2D.js +1 -1
- package/views/2d/layers/CatalogFootprintLayerView2D.js +1 -1
- package/views/2d/layers/CatalogLayerView2D.js +1 -1
- package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/3d/glTF/LoaderResult.js +1 -1
- package/views/3d/glTF/internal/Resource.js +1 -1
- package/views/3d/glTF/loader.js +1 -1
- package/views/3d/layers/CatalogDynamicGroupLayerView3D.js +1 -1
- package/views/3d/layers/CatalogFootprintLayerView3D.js +1 -1
- package/views/3d/layers/CatalogLayerView3D.js +1 -1
- package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
- package/views/3d/layers/i3s/I3SGraphicsMap.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/support/buffer/glUtil.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatFadeTexture.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatOrderTexture.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatTextureAtlas.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentData.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/TextureBackedBuffer.glsl.js +10 -10
- package/views/3d/webgl-engine/lib/edgeRendering/bufferLayouts.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/edgeProcessing.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultLayouts.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeUtil.glsl.js +9 -9
- package/views/SceneView.js +1 -1
- package/views/VideoView.js +1 -1
- package/views/View2D.js +1 -1
- package/views/layers/BuildingComponentSublayerView.js +1 -1
- package/views/layers/CatalogDynamicGroupLayerView.js +1 -1
- package/views/layers/CatalogFootprintLayerView.js +1 -1
- package/views/layers/CatalogLayerView.js +1 -1
- package/views/layers/FeatureLayerView.js +1 -1
- package/views/layers/HighlightLayerViewMixin.d.ts +2 -2
- package/views/layers/HighlightLayerViewMixin.js +5 -0
- package/views/layers/ImageryTileLayerView.js +1 -1
- package/views/layers/ImageryTileLayerViewMixin.js +5 -0
- package/views/layers/OGCFeatureLayerView.js +1 -1
- package/views/layers/SceneLayerView.js +1 -1
- package/views/layers/StreamLayerView.js +1 -1
- package/views/webgl/ShaderBuilder.js +1 -1
- package/views/webgl/Util.js +1 -1
- package/views/webgl/VertexElementDescriptor.js +1 -1
- package/webscene/support/SlideEnvironment.js +1 -1
- package/widgets/AreaMeasurement2D.js +1 -1
- package/widgets/AreaMeasurement3D.js +1 -1
- package/widgets/Attachments.js +1 -1
- package/widgets/BasemapGallery/BasemapGalleryViewModel.js +1 -1
- package/widgets/BasemapGallery.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/VersionManagement/VersionManagementViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/0a5427127634738aa239.js +0 -1
- package/assets/esri/core/workers/chunks/110429583b28c28c36ee.js +0 -1
- package/assets/esri/core/workers/chunks/145c6a7cdcc9893efb27.js +0 -1
- package/assets/esri/core/workers/chunks/1bacdd17e199e22b5cd1.js +0 -1
- package/assets/esri/core/workers/chunks/1d566539ff6fb6ac798c.js +0 -1
- package/assets/esri/core/workers/chunks/5dc0d853c21ccb6054c7.js +0 -1
- package/assets/esri/core/workers/chunks/613cbac9cb925cd20b48.js +0 -1
- package/assets/esri/core/workers/chunks/800c91302eaad7f00877.js +0 -1
- package/assets/esri/core/workers/chunks/926c2a0e21b7aa1a86e4.js +0 -1
- package/assets/esri/core/workers/chunks/c4de24582c29fda5a033.js +0 -1
- package/assets/esri/core/workers/chunks/d786b17cc9062b1450ac.js +0 -1
- package/assets/esri/core/workers/chunks/d9958654c6438f28237b.js +0 -1
- package/assets/esri/core/workers/chunks/e6fa6f9c278589c8a713.js +0 -1
- package/assets/esri/core/workers/chunks/e7f4d135ef9665de1468.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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{estimateNumberArrayMemory as i}from"../../../core/memoryEstimations.js";import{throwIfAborted as s}from"../../../core/promiseUtils.js";import{initial as o,watch as a}from"../../../core/reactiveUtils.js";import{generateUID as n}from"../../../core/uid.js";import{property as l,subclass as d}from"../../../core/accessorSupport/decorators.js";import{h as u}from"../../../chunks/vec32.js";import{create as h,ZEROS as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBuffer as c}from"../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as g}from"../../../geometry/projection/projectVectorToVector.js";import{extentContainsCoords3D as m,extentContainsCoords2D as y}from"../../../geometry/support/contains.js";import{newDoubleArray as f,doubleArrayFrom as _}from"../../../geometry/support/DoubleArray.js";import{getGeometryZScaler as b}from"../../../geometry/support/zscale.js";import{fallbackObjectIDAttribute as v}from"../../../layers/LayerConstants.js";import{estimateSize as I}from"../../../layers/graphics/dehydratedFeatures.js";import{ImmutableDehydratedPoint as x}from"../../../layers/graphics/dehydratedPoint.js";import{hydrateGraphic as E}from"../../../layers/graphics/hydratedFeatures.js";import w from"../../../layers/graphics/controllers/I3SOnDemandController.js";import O from"../../../layers/support/FeatureFilter.js";import j from"../../../rest/support/Query.js";import{isBasemapLayerView as N}from"../../../support/basemapUtils.js";import{isGraphic as C}from"../../../support/guards.js";import{I3SPointsWorkerHandle as D}from"./I3SPointsWorkerHandle.js";import{LayerView3D as F}from"./LayerView3D.js";import{Graphics3DFeatureProcessor as S}from"./graphics/Graphics3DFeatureProcessor.js";import{QueryEngine as G}from"./graphics/QueryEngine.js";import{QueryEngineContext as A}from"./graphics/QueryEngineContext.js";import{createInteractiveEditSession as V,normalizeEditResultsEvent as P,processAttributeEdits as L}from"./i3s/featureEditing.js";import{getCachedAttributeValue as R}from"./i3s/I3SBinaryReader.js";import{I3SGraphicsMap as H}from"./i3s/I3SGraphicsMap.js";import{I3SOverrides as M}from"./i3s/I3SOverrides.js";import{checkRecyclable as U,checkSpatialReferences as Q,containsDraco as q,whenGraphicAttributes as T}from"./i3s/I3SUtil.js";import{attributeLookup as B}from"./support/attributeUtils.js";import{DefinitionExpressionSceneLayerView as k}from"./support/DefinitionExpressionSceneLayerView.js";import{defineFieldProperties as z}from"./support/fieldProperties.js";import{normalizeHighlightTarget as W,emptyHighlightHandle as K,isObjectId as Z}from"./support/highlightUtils.js";import{LayerViewPerformanceInfo as $}from"./support/LayerViewPerformanceInfo.js";import{PopupSceneLayerView as Y}from"./support/PopupSceneLayerView.js";import{SceneLayerViewRequiredFields as J}from"./support/SceneLayerViewRequiredFields.js";import{TemporalSceneLayerView as X}from"./support/TemporalSceneLayerView.js";import{debugFlags as ee}from"../support/debugFlags.js";import{compute as te}from"../support/orientedBoundingBox.js";import{updatingProgress as re}from"../support/updatingProperties.js";import{Vertices as ie}from"../webgl-engine/lib/Attribute.js";import se from"../../layers/SceneLayerView.js";import{hasPopupTemplate as oe}from"../../layers/support/popupUtils.js";import{getHighlightName as ae}from"../../support/highlightOptionsUtils.js";import{hasLayerBasedScaleVisibility as ne,isInEffectiveScaleRange as le}from"../../support/layerViewUtils.js";import{TaskPriority as de}from"../../support/Scheduler.js";const ue=z();class he{constructor(e,t,r,i){this.graphics=e,this.featureIds=t,this.attributeInfo=r,this.node=i}get usedMemory(){return this.graphics.reduce((e,t)=>I(t)+e,i(this.featureIds)+1024)}}let pe=class extends(X(k(Y(F(se))))){constructor(){super(...arguments),this.type="scene-layer-graphics-3d",this._queryEngine=null,this._memCache=null,this._interactiveEditingSessions=new Map,this._pendingEditsQueue=Promise.resolve(),this.loadedGraphics=new H((e,t,r)=>ye(e,t,r),e=>this.processor.graphicsCore.recreateGraphics(e)),this.holeFilling="always",this.progressiveLoadFactor=1,this.supportsHeightUnitConversion=!0,this._coordinatesOutsideExtentErrors=0,this._maxCoordinatesOutsideExtentErrors=20}tryRecycleWith(e,t){return e.url===this.layer.url&&this._i3sOverrides.isEmpty?e.load(t).then(()=>{s(t),U(this.layer,e,this._i3sOverrides),this.layer=e,this._i3sOverrides.destroy();const i=this.view.resourceController?.memoryController;this._i3sOverrides=new M({view:this.view,layer:e,memoryController:i}),r(this._queryEngine),this._setupQueryEngine(),this.processor.resetObjectStates()}):null}initialize(){this.addResolvingPromise(this.layer.indexInfo);const e=this.view.resourceController?.memoryController;this._i3sOverrides=new M({view:this.view,layer:this.layer,memoryController:e}),Q(this.layer,this.view.spatialReference,this.view.viewingMode),this._fieldsHelper=new J({layerView:this}),this._updatingHandles.add(()=>this.layer.rangeInfos,e=>this._rangeInfosChanged(e),o),this._updatingHandles.add(()=>this.layer.renderer,(e,t)=>this._rendererChange(e,t)),this._updatingHandles.add(()=>[this.parsedDefinitionExpression,this.layer.excludeObjectIds],()=>this._filterChange()),this._set("processor",new S({owner:this,preferredUpdatePolicy:0,scaleVisibilityEnabled:!ne(),filterVisibilityEnabled:!0,timeExtentEnabled:!1,frustumVisibilityEnabled:!1,elevationAlignmentEnabled:!0,elevationFeatureExpressionEnabled:!1,setUidToIdOnAdd:!1,dataExtent:this.layer.fullExtent,updateClippingExtent:e=>this._updateClippingExtent(e)})),this.processor.elevationAlignment?.events.on("invalidate-elevation",({extent:e,spatialReference:t})=>this._controller.updateElevationChanged(e,t)),this.supportsHeightUnitConversion&&(this._verticalScale=b("point",this.layer.spatialReference,this.view.spatialReference)),this.addResolvingPromise(this.processor.when()),this._memCache=this.view.resourceController.memoryController.newCache(`psl-${this.uid}`),this._controller=new w({layerView:this}),q(this.layer.geometryDefinitions)&&(this._workerHandle=new D(e=>this.view.resourceController.immediate.schedule(e))),this.addHandles(this.layer.on("apply-edits",e=>this._updatingHandles.addPromise(e.result))),this.addHandles([this.layer.on("edits",e=>{const t=this._pendingEditsQueue.then(()=>this._handleEdits(e)).then();this._pendingEditsQueue=t,this._updatingHandles.addPromise(t)}),a(()=>ee.I3S_TREE_SHOW_TILES,e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then(({I3STreeDebugger:t})=>{!this._treeDebugger&&ee.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))})}else e||!this._treeDebugger||ee.I3S_TREE_SHOW_TILES||(this._treeDebugger.destroy(),this._treeDebugger=null)},o)]),this.when(()=>{this._setupQueryEngine(),this._updatingHandles.add(()=>this.maximumNumberOfFeatures,e=>this._controller.featureTarget=e,o),this._updatingHandles.add(()=>this.suspended,e=>{e&&this._removeAllNodeData()})})}destroy(){this._treeDebugger=r(this._treeDebugger),this._i3sOverrides=r(this._i3sOverrides),this._set("processor",r(this.processor)),this._controller=r(this._controller),this._queryEngine=r(this._queryEngine),this._workerHandle=r(this._workerHandle),this._memCache=r(this._memCache),this.loadedGraphics.clear(),this._fieldsHelper=r(this._fieldsHelper)}get i3slayer(){return this.layer}get layerViewUid(){return this.uid}get updatingProgressValue(){return this._controller?.updatingProgress??1}get visibleAtCurrentScale(){return ne()?le(this.layer.effectiveScaleRange,this.view.scale):!this.processor?.scaleVisibilitySuspended}get requiredFields(){return this._fieldsHelper?.requiredFields??[]}get maximumNumberOfFeatures(){const e=this.processor?.graphicsCore?.displayFeatureLimit;return e?.maximumNumberOfFeatures??0}set maximumNumberOfFeatures(e){null!=e?(this._override("maximumNumberOfFeatures",e),this._controller.fixedFeatureTarget=!0):(this._clearOverride("maximumNumberOfFeatures"),this._controller.fixedFeatureTarget=!1)}get maximumNumberOfFeaturesExceeded(){return!this.suspended&&(!!this._controller?.useMaximumNumberOfFeatures&&!this._controller.leavesReached)}get _excludeObjectIds(){return new Set(this.layer.excludeObjectIds)}get lodFactor(){return"Labels"===this.layer.semantic?1:this.view.qualitySettings.sceneService.pointLoDFactor}get hasM(){return!1}get hasZ(){return!0}get contentVisible(){return!this.suspended&&!!this._controller?.rootNodeVisible}get legendEnabled(){return this.contentVisible&&!0===this.i3slayer?.legendEnabled}get _graphicOrigin(){return this.layer.graphicOrigin}async whenGraphicAttributes(e,t){return T(this.layer,e,this._getObjectIdField(),t,()=>[...this.loadedGraphics.nodes()])}getHit(e){if(!this.loadedGraphics)return null;const t=E(this.loadedGraphics.find(t=>t.uid===e),this.layer,this._graphicOrigin),r=this._getObjectIdField();return null==t?.attributes?.[r]?null:{type:"graphic",graphic:t,layer:t.layer}}whenGraphicBounds(e,t){return this.processor.whenGraphicBounds(e,t)}computeAttachmentOrigin(e,t){return this.processor.computeAttachmentOrigin(e,t)}isUpdating(){return!!(this._controller?.updating||this.processor?.updating||this._fieldsHelper?.updating||this.layerFilterUpdating)}highlight(e,t){const r=ae(t),i=this.layer.objectIdField,s=W(e);if(0===s.length)return K;if(C(s[0])){const e=s;if(null!=B(this.layer.fieldsIndex,e[0].attributes,i)){const t=e.map(e=>B(this.layer.fieldsIndex,e.attributes,i));return this.processor.highlightByObjectIds(t,i,r)}return this.processor.highlightByGraphics(e,r)}return Z(s[0])?this.processor.highlightByObjectIds(s,i,r):K}get updatePolicy(){return this.processor.graphicsCore.effectiveUpdatePolicy}createInteractiveEditSession(e){return V(this._attributeEditingContext,e)}async _decompressBinaryPointData(e,t){const r={geometryBuffer:e.geometryBuffer};null==this._workerHandle&&(this._workerHandle=new D(e=>this.view.resourceController.immediate.schedule(e)));const i=await this._workerHandle.invoke(r,t);if(null==i)throw new Error("Failed to decompress Draco point data");return{positionData:i.positions,featureIds:i.featureIds}}async addNode(e,r,i){if(!me(r)&&!ge(r))throw new Error;if(this.loadedGraphics.hasNode(e.index))return void t.getLogger(this).error("I3S node "+e.id+" already added");const s=null!=this.layer.fullExtent?_e(this.layer.fullExtent.clone(),.5):null,{featureIds:o,pointPositions:a}=me(r)?await this._extractBinaryPointPositions(e,r,i):this._extractLegacyPointPositions(r),n=new Array;this._validatePositions(e,o,a,s,n);const l=this._controller.crsVertex,d=this.view.spatialReference;c(a,l,0,a,d,0,o.length);const u=me(r)?e.level:0,h=this._createGraphics(o,a,e.index,u),p=new he(h,o,r.attributeDataInfo,e);if(await this._i3sOverrides.applyAttributeOverrides(p.featureIds,r.attributeDataInfo,i),e.numFeatures=p.graphics.length,this._updateNodeMemory(e),fe(p),n.length>0&&(this._computeObb(e,n,l),this._controller.updateVisibility(e.index)),!this._controller.isGeometryVisible(e))return void this._cacheNodeData(p);if(null!=this._verticalScale)for(const t of p.graphics)this._verticalScale(t.geometry);const g=this.view.stage.renderView.olidRenderHelper;if(g){const e=N(this.view,this.uid);for(let t=0;t<p.featureIds.length;t++){const r=p.featureIds[t];g.setUidToObjectAndLayerId(r,p.graphics[t].uid,this.layer.id,this.uid,this.layer.popupEnabled&&!e&&oe(this.layer,this.view.popup?.defaultPopupTemplateEnabled),p.node.resources.attributes,t)}}this.loadedGraphics.addNode(e.index,p),this._controller.updateLoadStatus(e.index,!0),this._filterNode(p),this._treeDebugger&&this._treeDebugger.update()}_computeObb(e,t,r){const i=this._controller.crsIndex,s=i.isGeographic?this.view.renderSpatialReference:i;c(t,r,0,t,s,0),e.serviceObbInIndexSR=te(new ie(t,3)),i.isGeographic&&(g(e.serviceObbInIndexSR.center,s,ve,i),e.serviceObbInIndexSR.center=ve)}isNodeLoaded(e){return this.loadedGraphics.hasNode(e)}isNodeReloading(){return!1}updateNodeState(){}getNodeComponentHandle(){}async _extractBinaryPointPositions(e,t,r){const i=await this._decompressBinaryPointData(t,r),s=i.positionData,o=3,a=s.length/o,n=f(3*a),l=null!=e.serviceObbInIndexSR?e.serviceObbInIndexSR.center:p,d=Math.abs(l[2])*2**-20;for(let u=0;u<a;u++){const e=u*o;n[e]=s[e]+l[0],n[e+1]=s[e+1]+l[1],n[e+2]=s[e+2]+l[2],Math.abs(n[e+2])<d&&(n[e+2]=0)}return{featureIds:i.featureIds?_(i.featureIds):[],pointPositions:n}}_extractLegacyPointPositions(e){const t=e.pointData.length,r=f(3*t),i=new Array;for(let s=0;s<t;s++){const t=e.pointData[s],o=t.featureDataPosition,a=o.length,n=t.geometries?.[0]??be[a],l=t.featureIds[0];if("Embedded"!==n.type||"points"!==n.params.type||a<2||a>3)continue;const d=n.params.vertexAttributes?.position??[0,0,0],u=3*i.length;r[u]=o[0]+d[0],r[u+1]=o[1]+d[1],r[u+2]=3===a?o[2]+d[2]:NaN,i.push(l)}return{featureIds:i,pointPositions:r}}_validatePositions(e,r,i,s,o){if(null==s&&e.serviceObbInIndexSR)return;const a=r.length,n=3;for(let l=0;l<a;l++){const r=l*n;u(ve,i[r],i[r+1],i[r+2]);const a=!Number.isNaN(i[2]);null==s||(a?m(s,ve):y(s,ve))||(this._coordinatesOutsideExtentErrors<this._maxCoordinatesOutsideExtentErrors&&t.getLogger(this).error("Service Error: Coordinates outside of layer extent"),this._coordinatesOutsideExtentErrors+1===this._maxCoordinatesOutsideExtentErrors&&t.getLogger(this).error("Maximum number of errors reached. Further errors are ignored."),this._coordinatesOutsideExtentErrors++),e.serviceObbInIndexSR||o.push(ve[0],ve[1],ve[2])}}_createGraphics(e,t,r,i){const s=e.length,o=3,a=this._getObjectIdField(),l=this.processor.graphicsCore,d=new Array,u=this.view.spatialReference;for(let h=0;h<s;h++){const s=e[h],p={};null!=s&&(p[a]=s);const c=s??n(),g=h*o,m=isNaN(t[g+2])?void 0:t[g+2],y=new x(u,t[g],t[g+1],m),f=this.loadedGraphics.get(c);if(null!=f)(null==f.level||f.level<i)&&(Ie.property="geometry",Ie.graphic=f,Ie.oldValue=f.geometry,Ie.newValue=y,f.geometry=y,f.level=i,l.graphicUpdateHandler(Ie),xe()),d.push(f);else{const e=n();d.push({objectId:c,uid:e,geometry:y,attributes:p,visible:!0,nodeIndex:r,level:i})}}return d}_updateNodeMemory(e){e.memory=4096+(e.numFeatures??0)*this.processor.graphicsCore.usedMemoryPerGraphic}_cacheNodeData(e){this._memCache.put(this._getMemCacheKey(e.node),e)}_getMemCacheKey(e){return`${e.index}`}_removeAllNodeData(){this.loadedGraphics.forEachNode((e,t)=>{if(e){const t=e.node;this._updateNodeMemory(t),this._cacheNodeData(e)}this._controller.updateLoadStatus(t,!1)}),this._treeDebugger&&this._treeDebugger.update(),this.loadedGraphics.clear()}removeNode(e){const t=this._removeNodeStageData(e);t&&(this._updateNodeMemory(t.node),this._cacheNodeData(t))}_removeNodeStageData(e){const t=this.loadedGraphics.getNode(e);return null==t?null:(this._controller.updateLoadStatus(e,!1),this.loadedGraphics.removeNode(e),this._treeDebugger&&this._treeDebugger.update(),t)}async loadCachedNodeData(e){return this._memCache?.pop(this._getMemCacheKey(e))}async addCachedNodeData(e,r,i,s){this.loadedGraphics.hasNode(e.index)?t.getLogger(this).error("I3S node "+e.id+" already added"):(await this._i3sOverrides.applyAttributeOverrides(r.featureIds,i,s),r.attributeInfo=i,this.loadedGraphics.addNode(e.index,r),this._controller.updateLoadStatus(e.index,!0),this._updateNodeMemory(e),fe(r),this._filterNode(r),this._treeDebugger&&this._treeDebugger.update())}getLoadedNodeIds(){const e=[];return this.loadedGraphics.forEachNode(t=>e.push(t.node.id)),e.sort()}getVisibleNodes(){const e=new Array;return this.loadedGraphics.forEachNode(t=>e.push(t.node)),e}getLoadedNodeIndices(e){this.loadedGraphics.forEachNode((t,r)=>e.push(r))}getLoadedAttributes(e){const t=this.loadedGraphics.getNode(e);if(null!=t?.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this.loadedGraphics.getNode(e);if(null!=t?.attributeInfo)return t.attributeInfo.attributeData}_setAttributeData(e,t){const r=this.loadedGraphics.getNode(e);null!=r?.attributeInfo&&(r.attributeInfo.attributeData=t,this._attributeValuesChanged(r))}async updateAttributes(e,t,r){const i=this.loadedGraphics.getNode(e);null!=i&&(await this._i3sOverrides.applyAttributeOverrides(i.featureIds,t,r),i.attributeInfo=t,this._attributeValuesChanged(i))}_attributeValuesChanged(e){fe(e),this._filterNode(e);const{processor:t}=this,{graphicsCore:r}=t;if(r.labelsEnabled){const t=e.node.index,i=new Array;e.graphics.forEach(e=>e.nodeIndex===t&&i.push(e.uid)),r.updateLabelingInfo(i)}t.refreshFilter()}_updateClippingExtent(e){return this._controller&&this._controller.updateClippingArea(e),!1}_getObjectIdField(){return this.layer.objectIdField||v}_getGlobalIdField(){return this.layer.globalIdField}async _rendererChange(e,t){const{layer:{fieldsIndex:r}}=this,i=new Set;let s,o;e?(await e.collectRequiredFields(i,r),s=Array.from(i).sort()):s=[],i.clear(),t?(await t.collectRequiredFields(i,r),o=Array.from(i).sort()):o=[],s.length===o.length&&s.every((e,t)=>s[t]===o[t])||this._reloadAllNodes()}_rangeInfosChanged(e){null!=e&&e.length>0&&t.getLogger(this).warn("Unsupported property: rangeInfos are currently only serialized to and from web scenes but do not affect rendering.")}_filterChange(){this.loadedGraphics.forEachNode(e=>this._filterNode(e))}_reloadAllNodes(){this._removeAllNodeData(),this._controller&&this._controller.restartNodeLoading()}_filterNode(e){const t=this.parsedDefinitionExpression,r=this._excludeObjectIds,i=this._getObjectIdField();for(const s of e.graphics){const e=s.visible,o=this._evaluateClause(t,s),a=!r.has(s.attributes[i]);s.visible=o&&a,e!==s.visible&&(Ie.graphic=s,Ie.property="visible",Ie.oldValue=e,Ie.newValue=s.visible,this.processor.graphicsCore.graphicUpdateHandler(Ie),xe())}}createQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference};return this.filter?.createQuery(e)??new j(e)}queryFeatures(e,t){return this._queryEngine.executeQuery(this._ensureQuery(e),t?.signal)}queryObjectIds(e,t){return this._queryEngine.executeQueryForIds(this._ensureQuery(e),t?.signal)}queryFeatureCount(e,t){return this._queryEngine.executeQueryForCount(this._ensureQuery(e),t?.signal)}queryExtent(e,t){return this._queryEngine.executeQueryForExtent(this._ensureQuery(e),t?.signal)}_ensureQuery(e){return this._addDefinitionExpressionToQuery(null==e?this.createQuery():j.from(e))}_setupQueryEngine(){const{layer:e,view:t,hasM:r,hasZ:i}=this,{spatialReference:s,resourceController:o}=t,a=new A(s,e,o,()=>this.processor.featureStore,i,r);this._queryEngine=new G({context:a,priority:de.FEATURE_QUERY_ENGINE})}get usedMemory(){return this.processor?.graphicsCore?.usedMemory??0}get unloadedMemory(){return.8*((this._controller?.unloadedMemoryEstimate??0)+(this.processor?.graphicsCore?.unprocessedMemoryEstimate??0))}get ignoresMemoryFactor(){return this._controller&&this._controller.fixedFeatureTarget}async _handleEdits(e){const t=this._attributeEditingContext,r=await P(t,e);L(t,r)}get _attributeEditingContext(){const e=this._getObjectIdField(),t=this._getGlobalIdField();return{sessions:this._interactiveEditingSessions,fieldsIndex:this.layer.fieldsIndex,objectIdField:e,globalIdField:t,forEachNode:e=>this.loadedGraphics.forEachNode(t=>e(t.node,t.featureIds)),attributeStorageInfo:this.i3slayer.attributeStorageInfo??[],i3sOverrides:this._i3sOverrides,getAttributeData:e=>this.getAttributeData(e),setAttributeData:(t,r,i)=>{this._setAttributeData(t,r);const s=this.loadedGraphics.getNode(t);if(null!=i){const t=this.loadedGraphics.get(i.attributes[e]);null!=t&&this.processor.graphicsCore.recreateGraphics([t])}else null!=s&&this.processor.graphicsCore.recreateGraphics(s.graphics)},clearMemCache:()=>{}}}get performanceInfo(){return new $(this.usedMemory,this.loadedGraphics.length,-1,this.maximumNumberOfFeatures,this.loadedGraphics.nodeCount,this.processor.graphicsCore.performanceInfo)}get test(){}};e([l()],pe.prototype,"processor",void 0),e([l({type:O})],pe.prototype,"filter",void 0),e([l()],pe.prototype,"loadedGraphics",void 0),e([l()],pe.prototype,"i3slayer",null),e([l()],pe.prototype,"layerViewUid",null),e([l()],pe.prototype,"_controller",void 0),e([l()],pe.prototype,"updating",void 0),e([l()],pe.prototype,"suspended",void 0),e([l(re)],pe.prototype,"updatingProgress",void 0),e([l()],pe.prototype,"updatingProgressValue",null),e([l({readOnly:!0})],pe.prototype,"visibleAtCurrentScale",null),e([l(ue.requiredFields)],pe.prototype,"requiredFields",null),e([l(ue.availableFields)],pe.prototype,"availableFields",void 0),e([l()],pe.prototype,"_fieldsHelper",void 0),e([l({type:Number})],pe.prototype,"maximumNumberOfFeatures",null),e([l({readOnly:!0})],pe.prototype,"maximumNumberOfFeaturesExceeded",null),e([l()],pe.prototype,"_excludeObjectIds",null),e([l({readOnly:!0})],pe.prototype,"lodFactor",null),e([l({readOnly:!0})],pe.prototype,"hasM",null),e([l({readOnly:!0})],pe.prototype,"hasZ",null),e([l()],pe.prototype,"contentVisible",null),e([l({readOnly:!0})],pe.prototype,"legendEnabled",null),e([l()],pe.prototype,"_graphicOrigin",null),pe=e([d("esri.views.3d.layers.SceneLayerGraphicsView3D")],pe);const ce=pe;function ge(e){return"pointData"in e}function me(e){return"geometryBuffer"in e&&null!==e.geometryBuffer}function ye(e,t,r){const i=t.attributeInfo;if(null==i?.loadedAttributes||null==i.attributeData)return!1;let s=!1;for(const{name:o}of i.loadedAttributes)if(i.attributeData[o]){const t=R(i.attributeData[o],r);t!==e.attributes[o]&&(e.attributes[o]=t,s=!0)}return s}function fe(e){const t=e.attributeInfo;if(null==t?.loadedAttributes||null==t.attributeData)return;const r=e.node.index;for(let i=0;i<e.graphics.length;i++){const s=e.graphics[i];if(s.nodeIndex===r){s.attributes||(s.attributes={});for(const{name:e}of t.loadedAttributes)t.attributeData[e]&&(s.attributes[e]=R(t.attributeData[e],i))}}}function _e(e,t){return e.xmin-=t,e.ymin-=t,e.xmax+=t,e.ymax+=t,null!=e.zmin&&null!=e.zmax&&(e.zmin-=t,e.zmax+=t),null!=e.mmin&&null!=e.mmax&&(e.mmin-=t,e.mmax+=t),e}const be={2:{type:"Embedded",params:{type:"points",vertexAttributes:{position:[0,0]}}},3:{type:"Embedded",params:{type:"points",vertexAttributes:{position:[0,0,0]}}}},ve=h(),Ie={graphic:null,property:null,oldValue:null,newValue:null};function xe(){Ie.graphic=null,Ie.property=null,Ie.oldValue=null,Ie.newValue=null}export{ce as default};
|
|
5
|
+
import{__decorate as e}from"tslib";import"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{estimateNumberArrayMemory as i}from"../../../core/memoryEstimations.js";import{throwIfAborted as s}from"../../../core/promiseUtils.js";import{initial as o,watch as a}from"../../../core/reactiveUtils.js";import{generateUID as n}from"../../../core/uid.js";import{property as l,subclass as d}from"../../../core/accessorSupport/decorators.js";import{h as u}from"../../../chunks/vec32.js";import{create as h,ZEROS as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBuffer as c}from"../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as g}from"../../../geometry/projection/projectVectorToVector.js";import{extentContainsCoords3D as m,extentContainsCoords2D as y}from"../../../geometry/support/contains.js";import{newDoubleArray as f,doubleArrayFrom as _}from"../../../geometry/support/DoubleArray.js";import{getGeometryZScaler as b}from"../../../geometry/support/zscale.js";import{fallbackObjectIDAttribute as v}from"../../../layers/LayerConstants.js";import{estimateSize as I}from"../../../layers/graphics/dehydratedFeatures.js";import{ImmutableDehydratedPoint as x}from"../../../layers/graphics/dehydratedPoint.js";import{hydrateGraphic as E}from"../../../layers/graphics/hydratedFeatures.js";import w from"../../../layers/graphics/controllers/I3SOnDemandController.js";import O from"../../../layers/support/FeatureFilter.js";import j from"../../../rest/support/Query.js";import{isBasemapLayerView as N}from"../../../support/basemapUtils.js";import{isGraphic as C}from"../../../support/guards.js";import{I3SPointsWorkerHandle as D}from"./I3SPointsWorkerHandle.js";import{LayerView3D as F}from"./LayerView3D.js";import{Graphics3DFeatureProcessor as S}from"./graphics/Graphics3DFeatureProcessor.js";import{QueryEngine as G}from"./graphics/QueryEngine.js";import{QueryEngineContext as A}from"./graphics/QueryEngineContext.js";import{createInteractiveEditSession as V,normalizeEditResultsEvent as P,processAttributeEdits as L}from"./i3s/featureEditing.js";import{getCachedAttributeValue as R}from"./i3s/I3SBinaryReader.js";import{I3SGraphicsMap as H}from"./i3s/I3SGraphicsMap.js";import{I3SOverrides as M}from"./i3s/I3SOverrides.js";import{checkRecyclable as U,checkSpatialReferences as Q,containsDraco as q,whenGraphicAttributes as T}from"./i3s/I3SUtil.js";import{attributeLookup as B}from"./support/attributeUtils.js";import{DefinitionExpressionSceneLayerView as k}from"./support/DefinitionExpressionSceneLayerView.js";import{defineFieldProperties as z}from"./support/fieldProperties.js";import{normalizeHighlightTarget as W,emptyHighlightHandle as K,isObjectId as Z}from"./support/highlightUtils.js";import{LayerViewPerformanceInfo as $}from"./support/LayerViewPerformanceInfo.js";import{PopupSceneLayerView as Y}from"./support/PopupSceneLayerView.js";import{SceneLayerViewRequiredFields as J}from"./support/SceneLayerViewRequiredFields.js";import{TemporalSceneLayerView as X}from"./support/TemporalSceneLayerView.js";import{debugFlags as ee}from"../support/debugFlags.js";import{compute as te}from"../support/orientedBoundingBox.js";import{updatingProgress as re}from"../support/updatingProperties.js";import{Vertices as ie}from"../webgl-engine/lib/Attribute.js";import se from"../../layers/SceneLayerView.js";import{hasPopupTemplate as oe}from"../../layers/support/popupUtils.js";import{getHighlightName as ae}from"../../support/highlightOptionsUtils.js";import{hasLayerBasedScaleVisibility as ne,isInEffectiveScaleRange as le}from"../../support/layerViewUtils.js";import{TaskPriority as de}from"../../support/Scheduler.js";const ue=z();class he{constructor(e,t,r,i){this.graphics=e,this.featureIds=t,this.attributeInfo=r,this.node=i}get usedMemory(){return this.graphics.reduce((e,t)=>I(t)+e,i(this.featureIds)+1024)}}let pe=class extends(X(k(Y(F(se))))){constructor(){super(...arguments),this.type="scene-layer-graphics-3d",this._queryEngine=null,this._memCache=null,this._interactiveEditingSessions=new Map,this._pendingEditsQueue=Promise.resolve(),this.loadedGraphics=new H((e,t,r)=>ye(e,t,r),e=>this.processor.graphicsCore.recreateGraphics(e),this.logError),this.holeFilling="always",this.progressiveLoadFactor=1,this.supportsHeightUnitConversion=!0,this._coordinatesOutsideExtentErrors=0,this._maxCoordinatesOutsideExtentErrors=20}tryRecycleWith(e,t){return e.url===this.layer.url&&this._i3sOverrides.isEmpty?e.load(t).then(()=>{s(t),U(this.layer,e,this._i3sOverrides),this.layer=e,this._i3sOverrides.destroy();const i=this.view.resourceController?.memoryController;this._i3sOverrides=new M({view:this.view,layer:e,memoryController:i}),r(this._queryEngine),this._setupQueryEngine(),this.processor.resetObjectStates()}):null}initialize(){this.addResolvingPromise(this.layer.indexInfo);const e=this.view.resourceController?.memoryController;this._i3sOverrides=new M({view:this.view,layer:this.layer,memoryController:e}),Q(this.layer,this.view.spatialReference,this.view.viewingMode),this._fieldsHelper=new J({layerView:this}),this._updatingHandles.add(()=>this.layer.rangeInfos,e=>this._rangeInfosChanged(e),o),this._updatingHandles.add(()=>this.layer.renderer,(e,t)=>this._rendererChange(e,t)),this._updatingHandles.add(()=>[this.parsedDefinitionExpression,this.layer.excludeObjectIds],()=>this._filterChange()),this._set("processor",new S({owner:this,preferredUpdatePolicy:0,scaleVisibilityEnabled:!ne(),filterVisibilityEnabled:!0,timeExtentEnabled:!1,frustumVisibilityEnabled:!1,elevationAlignmentEnabled:!0,elevationFeatureExpressionEnabled:!1,setUidToIdOnAdd:!1,dataExtent:this.layer.fullExtent,updateClippingExtent:e=>this._updateClippingExtent(e)})),this.processor.elevationAlignment?.events.on("invalidate-elevation",({extent:e,spatialReference:t})=>this._controller.updateElevationChanged(e,t)),this.supportsHeightUnitConversion&&(this._verticalScale=b("point",this.layer.spatialReference,this.view.spatialReference)),this.addResolvingPromise(this.processor.when()),this._memCache=this.view.resourceController.memoryController.newCache(`psl-${this.uid}`),this._controller=new w({layerView:this}),q(this.layer.geometryDefinitions)&&(this._workerHandle=new D(e=>this.view.resourceController.immediate.schedule(e))),this.addHandles(this.layer.on("apply-edits",e=>this._updatingHandles.addPromise(e.result))),this.addHandles([this.layer.on("edits",e=>{const t=this._pendingEditsQueue.then(()=>this._handleEdits(e)).then();this._pendingEditsQueue=t,this._updatingHandles.addPromise(t)}),a(()=>ee.I3S_TREE_SHOW_TILES,e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then(({I3STreeDebugger:t})=>{!this._treeDebugger&&ee.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))})}else e||!this._treeDebugger||ee.I3S_TREE_SHOW_TILES||(this._treeDebugger.destroy(),this._treeDebugger=null)},o)]),this.when(()=>{this._setupQueryEngine(),this._updatingHandles.add(()=>this.maximumNumberOfFeatures,e=>this._controller.featureTarget=e,o),this._updatingHandles.add(()=>this.suspended,e=>{e&&this._removeAllNodeData()})})}destroy(){this._treeDebugger=r(this._treeDebugger),this._i3sOverrides=r(this._i3sOverrides),this._set("processor",r(this.processor)),this._controller=r(this._controller),this._queryEngine=r(this._queryEngine),this._workerHandle=r(this._workerHandle),this._memCache=r(this._memCache),this.loadedGraphics.clear(),this._fieldsHelper=r(this._fieldsHelper)}get i3slayer(){return this.layer}get layerViewUid(){return this.uid}get updatingProgressValue(){return this._controller?.updatingProgress??1}get visibleAtCurrentScale(){return ne()?le(this.layer.effectiveScaleRange,this.view.scale):!this.processor?.scaleVisibilitySuspended}get requiredFields(){return this._fieldsHelper?.requiredFields??[]}get maximumNumberOfFeatures(){const e=this.processor?.graphicsCore?.displayFeatureLimit;return e?.maximumNumberOfFeatures??0}set maximumNumberOfFeatures(e){null!=e?(this._override("maximumNumberOfFeatures",e),this._controller.fixedFeatureTarget=!0):(this._clearOverride("maximumNumberOfFeatures"),this._controller.fixedFeatureTarget=!1)}get maximumNumberOfFeaturesExceeded(){return!this.suspended&&(!!this._controller?.useMaximumNumberOfFeatures&&!this._controller.leavesReached)}get _excludeObjectIds(){return new Set(this.layer.excludeObjectIds)}get lodFactor(){return"Labels"===this.layer.semantic?1:this.view.qualitySettings.sceneService.pointLoDFactor}get hasM(){return!1}get hasZ(){return!0}get contentVisible(){return!this.suspended&&!!this._controller?.rootNodeVisible}get legendEnabled(){return this.contentVisible&&!0===this.i3slayer?.legendEnabled}get _graphicOrigin(){return this.layer.graphicOrigin}async whenGraphicAttributes(e,t){return T(this.layer,e,this._getObjectIdField(),t,()=>[...this.loadedGraphics.nodes()])}getHit(e){if(!this.loadedGraphics)return null;const t=E(this.loadedGraphics.find(t=>t.uid===e),this.layer,this._graphicOrigin),r=this._getObjectIdField();return null==t?.attributes?.[r]?null:{type:"graphic",graphic:t,layer:t.layer}}whenGraphicBounds(e,t){return this.processor.whenGraphicBounds(e,t)}computeAttachmentOrigin(e,t){return this.processor.computeAttachmentOrigin(e,t)}isUpdating(){return!!(this._controller?.updating||this.processor?.updating||this._fieldsHelper?.updating||this.layerFilterUpdating)}highlight(e,t){const r=ae(t),i=this.layer.objectIdField,s=W(e);if(0===s.length)return K;if(C(s[0])){const e=s;if(null!=B(this.layer.fieldsIndex,e[0].attributes,i)){const t=e.map(e=>B(this.layer.fieldsIndex,e.attributes,i));return this.processor.highlightByObjectIds(t,i,r)}return this.processor.highlightByGraphics(e,r)}return Z(s[0])?this.processor.highlightByObjectIds(s,i,r):K}get updatePolicy(){return this.processor.graphicsCore.effectiveUpdatePolicy}createInteractiveEditSession(e){return V(this._attributeEditingContext,e)}async _decompressBinaryPointData(e,t){const r={geometryBuffer:e.geometryBuffer};null==this._workerHandle&&(this._workerHandle=new D(e=>this.view.resourceController.immediate.schedule(e)));const i=await this._workerHandle.invoke(r,t);if(null==i)throw new Error("Failed to decompress Draco point data");return{positionData:i.positions,featureIds:i.featureIds}}async addNode(e,r,i){if(!me(r)&&!ge(r))throw new Error;if(this.loadedGraphics.hasNode(e.index))return void t.getLogger(this).error("I3S node "+e.id+" already added");const s=null!=this.layer.fullExtent?_e(this.layer.fullExtent.clone(),.5):null,{featureIds:o,pointPositions:a}=me(r)?await this._extractBinaryPointPositions(e,r,i):this._extractLegacyPointPositions(r),n=new Array;this._validatePositions(e,o,a,s,n);const l=this._controller.crsVertex,d=this.view.spatialReference;c(a,l,0,a,d,0,o.length);const u=me(r)?e.level:0,h=this._createGraphics(o,a,e.index,u),p=new he(h,o,r.attributeDataInfo,e);if(await this._i3sOverrides.applyAttributeOverrides(p.featureIds,r.attributeDataInfo,i),e.numFeatures=p.graphics.length,this._updateNodeMemory(e),fe(p),n.length>0&&(this._computeObb(e,n,l),this._controller.updateVisibility(e.index)),!this._controller.isGeometryVisible(e))return void this._cacheNodeData(p);if(null!=this._verticalScale)for(const t of p.graphics)this._verticalScale(t.geometry);const g=this.view.stage.renderView.olidRenderHelper;if(g){const e=N(this.view,this.uid);for(let t=0;t<p.featureIds.length;t++){const r=p.featureIds[t];g.setUidToObjectAndLayerId(r,p.graphics[t].uid,this.layer.id,this.uid,this.layer.popupEnabled&&!e&&oe(this.layer,this.view.popup?.defaultPopupTemplateEnabled),p.node.resources.attributes,t)}}this.loadedGraphics.addNode(e.index,p),this._controller.updateLoadStatus(e.index,!0),this._filterNode(p),this._treeDebugger&&this._treeDebugger.update()}_computeObb(e,t,r){const i=this._controller.crsIndex,s=i.isGeographic?this.view.renderSpatialReference:i;c(t,r,0,t,s,0),e.serviceObbInIndexSR=te(new ie(t,3)),i.isGeographic&&(g(e.serviceObbInIndexSR.center,s,ve,i),e.serviceObbInIndexSR.center=ve)}isNodeLoaded(e){return this.loadedGraphics.hasNode(e)}isNodeReloading(){return!1}updateNodeState(){}getNodeComponentHandle(){}async _extractBinaryPointPositions(e,t,r){const i=await this._decompressBinaryPointData(t,r),s=i.positionData,o=3,a=s.length/o,n=f(3*a),l=null!=e.serviceObbInIndexSR?e.serviceObbInIndexSR.center:p,d=Math.abs(l[2])*2**-20;for(let u=0;u<a;u++){const e=u*o;n[e]=s[e]+l[0],n[e+1]=s[e+1]+l[1],n[e+2]=s[e+2]+l[2],Math.abs(n[e+2])<d&&(n[e+2]=0)}return{featureIds:i.featureIds?_(i.featureIds):[],pointPositions:n}}_extractLegacyPointPositions(e){const t=e.pointData.length,r=f(3*t),i=new Array;for(let s=0;s<t;s++){const t=e.pointData[s],o=t.featureDataPosition,a=o.length,n=t.geometries?.[0]??be[a],l=t.featureIds[0];if("Embedded"!==n.type||"points"!==n.params.type||a<2||a>3)continue;const d=n.params.vertexAttributes?.position??[0,0,0],u=3*i.length;r[u]=o[0]+d[0],r[u+1]=o[1]+d[1],r[u+2]=3===a?o[2]+d[2]:NaN,i.push(l)}return{featureIds:i,pointPositions:r}}_validatePositions(e,r,i,s,o){if(null==s&&e.serviceObbInIndexSR)return;const a=r.length,n=3;for(let l=0;l<a;l++){const r=l*n;u(ve,i[r],i[r+1],i[r+2]);const a=!Number.isNaN(i[2]);null==s||(a?m(s,ve):y(s,ve))||(this._coordinatesOutsideExtentErrors<this._maxCoordinatesOutsideExtentErrors&&t.getLogger(this).error("Service Error: Coordinates outside of layer extent"),this._coordinatesOutsideExtentErrors+1===this._maxCoordinatesOutsideExtentErrors&&t.getLogger(this).error("Maximum number of errors reached. Further errors are ignored."),this._coordinatesOutsideExtentErrors++),e.serviceObbInIndexSR||o.push(ve[0],ve[1],ve[2])}}_createGraphics(e,t,r,i){const s=e.length,o=3,a=this._getObjectIdField(),l=this.processor.graphicsCore,d=new Array,u=this.view.spatialReference;for(let h=0;h<s;h++){const s=e[h],p={};null!=s&&(p[a]=s);const c=s??n(),g=h*o,m=isNaN(t[g+2])?void 0:t[g+2],y=new x(u,t[g],t[g+1],m),f=this.loadedGraphics.get(c);if(null!=f)(null==f.level||f.level<i)&&(Ie.property="geometry",Ie.graphic=f,Ie.oldValue=f.geometry,Ie.newValue=y,f.geometry=y,f.level=i,l.graphicUpdateHandler(Ie),xe()),d.push(f);else{const e=n();d.push({objectId:c,uid:e,geometry:y,attributes:p,visible:!0,nodeIndex:r,level:i})}}return d}_updateNodeMemory(e){e.memory=4096+(e.numFeatures??0)*this.processor.graphicsCore.usedMemoryPerGraphic}_cacheNodeData(e){this._memCache.put(this._getMemCacheKey(e.node),e)}_getMemCacheKey(e){return`${e.index}`}_removeAllNodeData(){this.loadedGraphics.forEachNode((e,t)=>{if(e){const t=e.node;this._updateNodeMemory(t),this._cacheNodeData(e)}this._controller.updateLoadStatus(t,!1)}),this._treeDebugger&&this._treeDebugger.update(),this.loadedGraphics.clear()}removeNode(e){const t=this._removeNodeStageData(e);t&&(this._updateNodeMemory(t.node),this._cacheNodeData(t))}_removeNodeStageData(e){const t=this.loadedGraphics.getNode(e);return null==t?null:(this._controller.updateLoadStatus(e,!1),this.loadedGraphics.removeNode(e),this._treeDebugger&&this._treeDebugger.update(),t)}async loadCachedNodeData(e){return this._memCache?.pop(this._getMemCacheKey(e))}async addCachedNodeData(e,r,i,s){this.loadedGraphics.hasNode(e.index)?t.getLogger(this).error("I3S node "+e.id+" already added"):(await this._i3sOverrides.applyAttributeOverrides(r.featureIds,i,s),r.attributeInfo=i,this.loadedGraphics.addNode(e.index,r),this._controller.updateLoadStatus(e.index,!0),this._updateNodeMemory(e),fe(r),this._filterNode(r),this._treeDebugger&&this._treeDebugger.update())}getLoadedNodeIds(){const e=[];return this.loadedGraphics.forEachNode(t=>e.push(t.node.id)),e.sort()}getVisibleNodes(){const e=new Array;return this.loadedGraphics.forEachNode(t=>e.push(t.node)),e}getLoadedNodeIndices(e){this.loadedGraphics.forEachNode((t,r)=>e.push(r))}getLoadedAttributes(e){const t=this.loadedGraphics.getNode(e);if(null!=t?.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this.loadedGraphics.getNode(e);if(null!=t?.attributeInfo)return t.attributeInfo.attributeData}_setAttributeData(e,t){const r=this.loadedGraphics.getNode(e);null!=r?.attributeInfo&&(r.attributeInfo.attributeData=t,this._attributeValuesChanged(r))}async updateAttributes(e,t,r){const i=this.loadedGraphics.getNode(e);null!=i&&(await this._i3sOverrides.applyAttributeOverrides(i.featureIds,t,r),i.attributeInfo=t,this._attributeValuesChanged(i))}_attributeValuesChanged(e){fe(e),this._filterNode(e);const{processor:t}=this,{graphicsCore:r}=t;if(r.labelsEnabled){const t=e.node.index,i=new Array;e.graphics.forEach(e=>e.nodeIndex===t&&i.push(e.uid)),r.updateLabelingInfo(i)}t.refreshFilter()}_updateClippingExtent(e){return this._controller&&this._controller.updateClippingArea(e),!1}_getObjectIdField(){return this.layer.objectIdField||v}_getGlobalIdField(){return this.layer.globalIdField}async _rendererChange(e,t){const{layer:{fieldsIndex:r}}=this,i=new Set;let s,o;e?(await e.collectRequiredFields(i,r),s=Array.from(i).sort()):s=[],i.clear(),t?(await t.collectRequiredFields(i,r),o=Array.from(i).sort()):o=[],s.length===o.length&&s.every((e,t)=>s[t]===o[t])||this._reloadAllNodes()}_rangeInfosChanged(e){null!=e&&e.length>0&&t.getLogger(this).warn("Unsupported property: rangeInfos are currently only serialized to and from web scenes but do not affect rendering.")}_filterChange(){this.loadedGraphics.forEachNode(e=>this._filterNode(e))}_reloadAllNodes(){this._removeAllNodeData(),this._controller&&this._controller.restartNodeLoading()}_filterNode(e){const t=this.parsedDefinitionExpression,r=this._excludeObjectIds,i=this._getObjectIdField();for(const s of e.graphics){const e=s.visible,o=this._evaluateClause(t,s),a=!r.has(s.attributes[i]);s.visible=o&&a,e!==s.visible&&(Ie.graphic=s,Ie.property="visible",Ie.oldValue=e,Ie.newValue=s.visible,this.processor.graphicsCore.graphicUpdateHandler(Ie),xe())}}createQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference};return this.filter?.createQuery(e)??new j(e)}queryFeatures(e,t){return this._queryEngine.executeQuery(this._ensureQuery(e),t?.signal)}queryObjectIds(e,t){return this._queryEngine.executeQueryForIds(this._ensureQuery(e),t?.signal)}queryFeatureCount(e,t){return this._queryEngine.executeQueryForCount(this._ensureQuery(e),t?.signal)}queryExtent(e,t){return this._queryEngine.executeQueryForExtent(this._ensureQuery(e),t?.signal)}_ensureQuery(e){return this._addDefinitionExpressionToQuery(null==e?this.createQuery():j.from(e))}_setupQueryEngine(){const{layer:e,view:t,hasM:r,hasZ:i}=this,{spatialReference:s,resourceController:o}=t,a=new A(s,e,o,()=>this.processor.featureStore,i,r);this._queryEngine=new G({context:a,priority:de.FEATURE_QUERY_ENGINE})}get usedMemory(){return this.processor?.graphicsCore?.usedMemory??0}get unloadedMemory(){return.8*((this._controller?.unloadedMemoryEstimate??0)+(this.processor?.graphicsCore?.unprocessedMemoryEstimate??0))}get ignoresMemoryFactor(){return this._controller&&this._controller.fixedFeatureTarget}async _handleEdits(e){const t=this._attributeEditingContext,r=await P(t,e);L(t,r)}get _attributeEditingContext(){const e=this._getObjectIdField(),t=this._getGlobalIdField();return{sessions:this._interactiveEditingSessions,fieldsIndex:this.layer.fieldsIndex,objectIdField:e,globalIdField:t,forEachNode:e=>this.loadedGraphics.forEachNode(t=>e(t.node,t.featureIds)),attributeStorageInfo:this.i3slayer.attributeStorageInfo??[],i3sOverrides:this._i3sOverrides,getAttributeData:e=>this.getAttributeData(e),setAttributeData:(t,r,i)=>{this._setAttributeData(t,r);const s=this.loadedGraphics.getNode(t);if(null!=i){const t=this.loadedGraphics.get(i.attributes[e]);null!=t&&this.processor.graphicsCore.recreateGraphics([t])}else null!=s&&this.processor.graphicsCore.recreateGraphics(s.graphics)},clearMemCache:()=>{}}}get performanceInfo(){return new $(this.usedMemory,this.loadedGraphics.length,-1,this.maximumNumberOfFeatures,this.loadedGraphics.nodeCount,this.processor.graphicsCore.performanceInfo)}get test(){}};e([l()],pe.prototype,"processor",void 0),e([l({type:O})],pe.prototype,"filter",void 0),e([l()],pe.prototype,"loadedGraphics",void 0),e([l()],pe.prototype,"i3slayer",null),e([l()],pe.prototype,"layerViewUid",null),e([l()],pe.prototype,"_controller",void 0),e([l()],pe.prototype,"updating",void 0),e([l()],pe.prototype,"suspended",void 0),e([l(re)],pe.prototype,"updatingProgress",void 0),e([l()],pe.prototype,"updatingProgressValue",null),e([l({readOnly:!0})],pe.prototype,"visibleAtCurrentScale",null),e([l(ue.requiredFields)],pe.prototype,"requiredFields",null),e([l(ue.availableFields)],pe.prototype,"availableFields",void 0),e([l()],pe.prototype,"_fieldsHelper",void 0),e([l({type:Number})],pe.prototype,"maximumNumberOfFeatures",null),e([l({readOnly:!0})],pe.prototype,"maximumNumberOfFeaturesExceeded",null),e([l()],pe.prototype,"_excludeObjectIds",null),e([l({readOnly:!0})],pe.prototype,"lodFactor",null),e([l({readOnly:!0})],pe.prototype,"hasM",null),e([l({readOnly:!0})],pe.prototype,"hasZ",null),e([l()],pe.prototype,"contentVisible",null),e([l({readOnly:!0})],pe.prototype,"legendEnabled",null),e([l()],pe.prototype,"_graphicOrigin",null),pe=e([d("esri.views.3d.layers.SceneLayerGraphicsView3D")],pe);const ce=pe;function ge(e){return"pointData"in e}function me(e){return"geometryBuffer"in e&&null!==e.geometryBuffer}function ye(e,t,r){const i=t.attributeInfo;if(null==i?.loadedAttributes||null==i.attributeData)return!1;let s=!1;for(const{name:o}of i.loadedAttributes)if(i.attributeData[o]){const t=R(i.attributeData[o],r);t!==e.attributes[o]&&(e.attributes[o]=t,s=!0)}return s}function fe(e){const t=e.attributeInfo;if(null==t?.loadedAttributes||null==t.attributeData)return;const r=e.node.index;for(let i=0;i<e.graphics.length;i++){const s=e.graphics[i];if(s.nodeIndex===r){s.attributes||(s.attributes={});for(const{name:e}of t.loadedAttributes)t.attributeData[e]&&(s.attributes[e]=R(t.attributeData[e],i))}}}function _e(e,t){return e.xmin-=t,e.ymin-=t,e.xmax+=t,e.ymax+=t,null!=e.zmin&&null!=e.zmax&&(e.zmin-=t,e.zmax+=t),null!=e.mmin&&null!=e.mmax&&(e.mmin-=t,e.mmax+=t),e}const be={2:{type:"Embedded",params:{type:"points",vertexAttributes:{position:[0,0]}}},3:{type:"Embedded",params:{type:"points",vertexAttributes:{position:[0,0,0]}}}},ve=h(),Ie={graphic:null,property:null,oldValue:null,newValue:null};function xe(){Ie.graphic=null,Ie.property=null,Ie.oldValue=null,Ie.newValue=null}export{ce as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../../core/has.js";import{clone as t}from"../../../../core/lang.js";import{getMetersPerVerticalUnitForSR as e}from"../../../../core/units.js";import{e as r}from"../../../../chunks/earcut.js";import{normalFromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as n,invertOrIdentity as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{h as l,a as c,f as p,i as m,n as h,p as u,d,e as g}from"../../../../chunks/vec32.js";import{ONES as f,create as y}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as b}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{create as _,fromBuffer as x,intersectsClippingArea as j}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as S}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as w,getZeroIndexArray as P}from"../../../../geometry/support/Indices.js";import{t as v}from"../../../../chunks/vec3.js";import{SnappingCandidateVertex as C,SnappingCandidateEdge as E}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as A}from"../../../../renderers/support/renderingInfoUtils.js";import{needsElevationUpdates3D as D,SampleElevationInfo as I}from"./elevationAlignmentUtils.js";import{Object3DEdgeState as L,Graphics3DObject3DGraphicLayer as U}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as z}from"./Graphics3DSymbolLayer.js";import{computeCentroid as O}from"./graphicUtils.js";import{geometryAsPolygon as M}from"./polygonUtils.js";import{createMaterial as G}from"../support/edgeUtils.js";import{encodeNaNUInt8 as V}from"../support/symbolColorUtils.js";import{debugFlags as T}from"../../support/debugFlags.js";import{SamplePosition as B}from"../../support/ElevationProvider.js";import{polygonToRenderInfo as R}from"../../support/renderInfoUtils/polygon.js";import{Attribute as F}from"../../webgl-engine/lib/Attribute.js";import{Geometry as H}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as k}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{compressNormals as N,compressNormal as W}from"../../webgl-engine/lib/Normals.js";import{Object3D as q}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as Z}from"../../webgl-engine/materials/DefaultMaterial.js";const J=["polygon","extent"];class K extends z{constructor(t,e,r,s){super(t,e,r,s,mt(e)),this.ensureDrapedStatus(!1)}async doLoad(){const t=this.symbolLayer,e=t?.material,r=this.symbolLayer.material?.color?.a,s=this.needsDrivenTransparentPass||null!=r&&1!==r,o=e?.emissive,n=!this._hasDrivenColorOrOpacity&&(null==r||0===r),i={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,ambient:f,diffuse:f,opacity:n?0:1,layerOpacity:this._getLayerOpacity(),drivenOpacity:s,hasSymbolColors:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:t.castShadows,emissiveStrength:o?.strength??0,emissiveSource:1,offsetTransparentBackfaces:!0,normalType:1},a=new Z(i,this._context),l=new Z({...i,cullFace:2},this._context);this._materials[0]=a,this._materials[1]=l,this._updateTransparentDepedentMaterialParameters()}destroy(){super.destroy(),this._materials.length=0}createGraphics3DGraphic(t){const e=t.graphic;if(!this._validateGeometry(e.geometry,J,this.symbolLayer.type))return null;const r=this._getDrivenUInt8ColorWithNaNSupport(t.renderingInfo,this._materialColor,!1);V(r,r);const s=this.createElevationContextForGraphic(e);return this._createAs3DShape(e,t.renderingInfo,r,s,e.uid)}layerOpacityChanged(t,e){const r=this._getLayerOpacity();this._materials[0]?.setParameters({layerOpacity:r}),this._materials[1]?.setParameters({layerOpacity:r}),this._updateTransparentDepedentMaterialParameters(),t?.forEach(t=>e(t)?.layerOpacityChanged(r,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(t,e){return this.updateGraphics3DGraphicElevationInfo(t,e,D)}slicePlaneEnabledChanged(t,e){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[1]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),t?.forEach(t=>{const r=e(t);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)}),!0}physicalBasedRenderingChanged(){const t={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0};return this._materials[0]?.setParameters(t),this._materials[1]?.setParameters(t),!0}_getExtrusionSize(t){let e;return e=t.size&&this._drivenProperties.size?A(t.size,2)??0:this._getSymbolSize(),e/=this._context.renderCoordsHelper.unitInMeters,e}applyRendererDiff(t,e){return this._drivenPropertiesChanged(e)?0:1}async queryForSnapping(r,s,o,n){const i=this._getExtrusionSize(o)*this._context.renderCoordsHelper.unitInMeters/e(s),{objectId:a,target:l}=r,c=t(l);switch(c.z=(c.z??0)+i,r.type){case"edge":{const{start:e,end:s}=r,o=t(e),n=t(s);return o.z=(o.z??0)+i,n.z=(n.z??0)+i,[new E(a,c,1/0,o,n)]}case"vertex":return[new C(a,c,1/0),new E(a,l,1/0,l,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(t,e,i,l,c){const p=M(t.geometry);if(null==p)return null;if(0===p.rings.length||!p.rings.some(t=>t.length>0))return this._logGeometryValidationWarnings(p.rings,"rings","ExtrudeSymbol3DLayer"),null;const m=R(p,this._context.elevationProvider,this._context.renderCoordsHelper,l);this._logGeometryCreationWarnings(m,p.rings,"rings","ExtrudeSymbol3DLayer");const h=O(p);if(null==h)return null;const u=new Array,d=new Array,g=_(),f=a(),P=y(),C=1===this._context.renderCoordsHelper.viewingMode;C||this._context.renderCoordsHelper.worldUpAtPosition(null,P),b(p.spatialReference,[h.x,h.y,0],f,this._context.renderCoordsHelper.spatialReference);const E=a();n(E,f);const A=o();s(A,E);const{polygons:I,mapPositions:z,position:V}=m,T=new Map,B=this._materials[0];for(const s of I){const t=s.count;if(this._context.clippingExtent&&(x(s.mapPositions,g),!j(g,this._context.clippingExtent)))continue;const o=r(s.mapPositions,s.holeIndices,3);if(0===o.length)continue;const n=o.length,a=6*t,l=w(a+n),p=w(n),m=S(3*a),h=S(3*a),y=S(3*a),b=S(a);X(V,z,o,s,m,y,h,b,l,p,this._getExtrusionSize(e),P,C),v(m,m,E);const _=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerViewUid:this._context.layerViewUid}),A=new jt(m,y,N(h),b),D=Q(B,l,l.length-p.length,A,i,_),I=t,L=t,U=2*s.count,O=new St(I,L,U,n/3);pt(D,O,f),T.set(D,O),u.push(D,Q(this._materials[1],p,0,A,i,_)),d.push(A.heights)}if(0===u.length)return null;const F=new q({geometries:u,layerViewUid:this._context.layerViewUid,graphicUid:c,isElevationSource:!0});F.transformation=f;const H=G(this.symbolLayer,{opacity:this._getLayerOpacity()}),k=H?new L(this._materials[0],H,this._context.slicePlaneEnabled):null,W=new U(this,F,null,(t,e,r,s,o)=>ct(t,e,r,s,o,d,T),l,k);return W.alignedSampledElevation=m.sampledElevation,W.needsElevationUpdates=D(l.mode),W}get _materialColor(){return this.symbolLayer.material?.color}_updateTransparentDepedentMaterialParameters(){const t=this._materials[0];t&&t.setParameters({cullFace:t.transparent?0:2})}}function Q(t,e,r,s,o,n){const i=P(e.length),a=[["position",new F(s.positions,e,3,!0)],["normalCompressed",new F(s.normals,e,2,!0)],["symbolColor",new F(o,i,4,!0)]];return new H(t,a,s.elevation,0,n,r)}function X(t,e,r,s,o,n,i,a,l,c,p,m,h){const u=r.length/3;let d=2*s.count;Y(t,e,s.index,s.count,r,0,u,o,n,i,a,l,c,d,p,m,h);let g=0,f=2*s.count;d=0;const y=s.pathLengths[0];et(o,n,a,i,g,y,s.count,f,l,d,p),f+=4*y,d+=2*y,g+=y;for(let b=1;b<s.pathLengths.length;++b){const t=s.pathLengths[b];et(o,n,a,i,g,t,s.count,f,l,d,p),f+=4*t,d+=2*t,g+=t}}function Y(t,e,r,s,o,n,i,a,l,c,p,m,u,g,f,y,b){d(ut,y),l??=[],c??=[],p??=[];const _=f>0?1:-1;let x=3*r,j=0,S=3*j,w=s,P=3*w;for(let d=0;d<s;++d){const r=t[x],s=t[x+1],o=t[x+2];b&&(ut[0]=r,ut[1]=s,ut[2]=o,h(ut,ut)),a[S+0]=r,a[S+1]=s,a[S+2]=o;const n=e[x+0],i=e[x+1],m=e[x+2];l[S+0]=n,l[S+1]=i,l[S+2]=m,c[S+0]=-_*ut[0],c[S+1]=-_*ut[1],c[S+2]=-_*ut[2],p[j]=0,a[P+0]=r+f*ut[0],a[P+1]=s+f*ut[1],a[P+2]=o+f*ut[2],l[P+0]=n,l[P+1]=i,l[P+2]=m,p[w]=f,S+=3,P+=3,x+=3,j+=1,w+=1}x=3*n,S=0,P=3*g;const v=f<0?ft:gt,C=f<0?gt:ft;for(let h=0;h<i;++h)u[S]=o[x+v[0]],u[S+1]=o[x+v[1]],u[S+2]=o[x+v[2]],m[P]=o[x+C[0]]+s,m[P+1]=o[x+C[1]]+s,m[P+2]=o[x+C[2]]+s,S+=3,P+=3,x+=3}function $(t,e,r,s,o,n,i){s[n]=s[i],i*=3,t[n*=3]=t[i],t[n+1]=t[i+1],t[n+2]=t[i+2],e[n]=e[i],e[n+1]=e[i+1],e[n+2]=e[i+2],r[n]=o[0],r[n+1]=o[1],r[n+2]=o[2]}const tt=y();function et(t,e,r,s,o,n,i,a,l,c,p){e??=[],r??=[],s??=[];let m=o,h=o+1,u=o+i,d=o+i+1,g=a,f=a+1,y=a+2*n,b=a+2*n+1;p<0&&(m=o+i+1,d=o);let _=3*c;for(let x=0;x<n;++x)x===n-1&&(h=o,p>0?d=o+i:m=o+i),at(t,m,h,u,tt),$(t,e,s,r,tt,g,m),$(t,e,s,r,tt,f,h),$(t,e,s,r,tt,y,u),$(t,e,s,r,tt,b,d),l[_]=g,l[_+1]=y,l[_+2]=b,l[_+3]=g,l[_+4]=b,l[_+5]=f,_+=6,m++,h++,u++,d++,g+=2,f+=2,y+=2,b+=2}const rt=y(),st=y(),ot=y(),nt=y(),it=y();function at(t,e,r,s,o){e*=3,r*=3,s*=3,l(rt,t[e++],t[e++],t[e++]),l(st,t[r++],t[r++],t[r++]),l(ot,t[s++],t[s++],t[s++]),g(nt,st,rt),g(it,ot,rt),p(o,it,nt),h(o,o)}const lt=y();function ct(t,e,r,s,o,n,c){const p=t.stageObject,m=p.geometries,h=m.length,d="absolute-height"!==e.mode;let g=0;const f=p.transformation,y=i(a(),f);for(let i=0;i<h;i+=2){const t=m[i];if(!k(t))continue;const e=t.getMutableAttribute("position").data,a=n[i/2],h=new B(t.mapPositions),b=e.length/3;let _=!1,x=0;{let t=0;for(let n=0;n<b;n++){lt[0]=e[t],lt[1]=e[t+1],lt[2]=e[t+2],s(h,dt),d&&(x+=dt.sampledElevation),T.TESTS_DISABLE_OPTIMIZATIONS?(l(ht,h.array[h.offset],h.array[h.offset+1],dt.z+a[t/3]),null!=r&&o.toRenderCoords(ht,r,ht),u(ht,ht,y)):(l(ht,e[t],e[t+1],e[t+2]),u(ht,ht,f),o.setAltitude(ht,dt.z+a[t/3]),u(ht,ht,y)),e[t]=ht[0],e[t+1]=ht[1],e[t+2]=ht[2];const n=yt/o.unitInMeters;(Math.abs(lt[0]-e[t])>=n||Math.abs(lt[1]-e[t+1])>=n||Math.abs(lt[2]-e[t+2])>=n)&&(_=!0),h.offset+=3,t+=3}}if(_){const e=c.get(t);e&&pt(t,e,f),p.geometryVertexAttributeUpdated(m[i],"normalCompressed"),t.invalidateBoundingInfo(),p.geometryVertexAttributeUpdated(m[i],"position"),m[i+1].invalidateBoundingInfo(),p.geometryVertexAttributeUpdated(m[i+1],"position")}g+=x/b}return g/h}function pt(t,e,r){const s=t.getMutableAttribute("position"),o=t.getMutableAttribute("normalCompressed").data,n=s.data,i=t.attributes.get("position").indices,{topVertexStart:a,topVertexCount:d,topFaceStart:g,topFaceCount:f}=e,y=g+f,b=a+d,_=bt,x=_t,j=xt,S=ut,w=ht;l(w,0,0,0);const P=(t,e)=>{const s=3*t;l(e,n[s+0],n[s+1],n[s+2]),u(e,e,r)};for(let l=g;l<y;++l){const t=3*l;P(i[t+0],_[0]),P(i[t+1],_[1]),P(i[t+2],_[2]),c(x,_[1],_[0]),c(j,_[2],_[0]),p(S,x,j),m(w,w,S)}h(w,w);for(let l=a;l<b;++l){const t=w[0],e=w[1],r=w[2];W(o,l,t,e,r)}}function mt(t){return 1===(t.material?.color?.a??0)}const ht=y(),ut=y(),dt=new I,gt=[0,2,1],ft=[0,1,2],yt=.01,bt=[y(),y(),y()],_t=y(),xt=y();class jt{constructor(t,e,r,s){this.positions=t,this.elevation=e,this.normals=r,this.heights=s}}class St{constructor(t,e,r,s){this.topVertexStart=t,this.topVertexCount=e,this.topFaceStart=r,this.topFaceCount=s}}export{K as Graphics3DExtrudeSymbolLayer,X as extrudePolygon};
|
|
5
|
+
import"../../../../core/has.js";import{clone as t}from"../../../../core/lang.js";import{getMetersPerVerticalUnitForSR as e}from"../../../../core/units.js";import{e as r}from"../../../../chunks/earcut.js";import{normalFromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as n,invertOrIdentity as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{h as l,a as c,f as p,i as m,n as h,p as u,d,e as g}from"../../../../chunks/vec32.js";import{ONES as f,create as y}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as b}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{create as _,fromBuffer as x,intersectsClippingArea as j}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as S}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as w,getZeroIndexArray as P}from"../../../../geometry/support/Indices.js";import{t as v}from"../../../../chunks/vec3.js";import{SnappingCandidateVertex as C,SnappingCandidateEdge as E}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as A}from"../../../../renderers/support/renderingInfoUtils.js";import{needsElevationUpdates3D as D,SampleElevationInfo as I}from"./elevationAlignmentUtils.js";import{Object3DEdgeState as L,Graphics3DObject3DGraphicLayer as U}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as z}from"./Graphics3DSymbolLayer.js";import{computeCentroid as O}from"./graphicUtils.js";import{geometryAsPolygon as M}from"./polygonUtils.js";import{createMaterial as G}from"../support/edgeUtils.js";import{encodeNaNUInt8 as V}from"../support/symbolColorUtils.js";import{debugFlags as T}from"../../support/debugFlags.js";import{SamplePosition as B}from"../../support/ElevationProvider.js";import{polygonToRenderInfo as F}from"../../support/renderInfoUtils/polygon.js";import{Attribute as R}from"../../webgl-engine/lib/Attribute.js";import{Geometry as H}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as k}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{compressNormals as N,compressNormal as W}from"../../webgl-engine/lib/Normals.js";import{Object3D as q}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as Z}from"../../webgl-engine/materials/DefaultMaterial.js";const J=["polygon","extent"];class K extends z{constructor(t,e,r,s){super(t,e,r,s,mt(e)),this.ensureDrapedStatus(!1)}async doLoad(){const t=this.symbolLayer,e=t?.material,r=this.symbolLayer.material?.color?.a,s=this.needsDrivenTransparentPass||null!=r&&1!==r,o=e?.emissive,n=!this._hasDrivenColorOrOpacity&&(null==r||0===r),i={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,ambient:f,diffuse:f,opacity:n?0:1,layerOpacity:this._getLayerOpacity(),drivenOpacity:s,hasSymbolColors:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:t.castShadows,emissiveStrengthFromSymbol:o?.strength??0,emissiveSource:1,offsetTransparentBackfaces:!0,normalType:1},a=new Z(i,this._context),l=new Z({...i,cullFace:2},this._context);this._materials[0]=a,this._materials[1]=l,this._updateTransparentDepedentMaterialParameters()}destroy(){super.destroy(),this._materials.length=0}createGraphics3DGraphic(t){const e=t.graphic;if(!this._validateGeometry(e.geometry,J,this.symbolLayer.type))return null;const r=this._getDrivenUInt8ColorWithNaNSupport(t.renderingInfo,this._materialColor,!1);V(r,r);const s=this.createElevationContextForGraphic(e);return this._createAs3DShape(e,t.renderingInfo,r,s,e.uid)}layerOpacityChanged(t,e){const r=this._getLayerOpacity();this._materials[0]?.setParameters({layerOpacity:r}),this._materials[1]?.setParameters({layerOpacity:r}),this._updateTransparentDepedentMaterialParameters(),t?.forEach(t=>e(t)?.layerOpacityChanged(r,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(t,e){return this.updateGraphics3DGraphicElevationInfo(t,e,D)}slicePlaneEnabledChanged(t,e){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[1]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),t?.forEach(t=>{const r=e(t);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)}),!0}physicalBasedRenderingChanged(){const t={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0};return this._materials[0]?.setParameters(t),this._materials[1]?.setParameters(t),!0}_getExtrusionSize(t){let e;return e=t.size&&this._drivenProperties.size?A(t.size,2)??0:this._getSymbolSize(),e/=this._context.renderCoordsHelper.unitInMeters,e}applyRendererDiff(t,e){return this._drivenPropertiesChanged(e)?0:1}async queryForSnapping(r,s,o,n){const i=this._getExtrusionSize(o)*this._context.renderCoordsHelper.unitInMeters/e(s),{objectId:a,target:l}=r,c=t(l);switch(c.z=(c.z??0)+i,r.type){case"edge":{const{start:e,end:s}=r,o=t(e),n=t(s);return o.z=(o.z??0)+i,n.z=(n.z??0)+i,[new E(a,c,1/0,o,n)]}case"vertex":return[new C(a,c,1/0),new E(a,l,1/0,l,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(t,e,i,l,c){const p=M(t.geometry);if(null==p)return null;if(0===p.rings.length||!p.rings.some(t=>t.length>0))return this._logGeometryValidationWarnings(p.rings,"rings","ExtrudeSymbol3DLayer"),null;const m=F(p,this._context.elevationProvider,this._context.renderCoordsHelper,l);this._logGeometryCreationWarnings(m,p.rings,"rings","ExtrudeSymbol3DLayer");const h=O(p);if(null==h)return null;const u=new Array,d=new Array,g=_(),f=a(),P=y(),C=1===this._context.renderCoordsHelper.viewingMode;C||this._context.renderCoordsHelper.worldUpAtPosition(null,P),b(p.spatialReference,[h.x,h.y,0],f,this._context.renderCoordsHelper.spatialReference);const E=a();n(E,f);const A=o();s(A,E);const{polygons:I,mapPositions:z,position:V}=m,T=new Map,B=this._materials[0];for(const s of I){const t=s.count;if(this._context.clippingExtent&&(x(s.mapPositions,g),!j(g,this._context.clippingExtent)))continue;const o=r(s.mapPositions,s.holeIndices,3);if(0===o.length)continue;const n=o.length,a=6*t,l=w(a+n),p=w(n),m=S(3*a),h=S(3*a),y=S(3*a),b=S(a);X(V,z,o,s,m,y,h,b,l,p,this._getExtrusionSize(e),P,C),v(m,m,E);const _=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerViewUid:this._context.layerViewUid}),A=new jt(m,y,N(h),b),D=Q(B,l,l.length-p.length,A,i,_),I=t,L=t,U=2*s.count,O=new St(I,L,U,n/3);pt(D,O,f),T.set(D,O),u.push(D,Q(this._materials[1],p,0,A,i,_)),d.push(A.heights)}if(0===u.length)return null;const R=new q({geometries:u,layerViewUid:this._context.layerViewUid,graphicUid:c,isElevationSource:!0});R.transformation=f;const H=G(this.symbolLayer,{opacity:this._getLayerOpacity()}),k=H?new L(this._materials[0],H,this._context.slicePlaneEnabled):null,W=new U(this,R,null,(t,e,r,s,o)=>ct(t,e,r,s,o,d,T),l,k);return W.alignedSampledElevation=m.sampledElevation,W.needsElevationUpdates=D(l.mode),W}get _materialColor(){return this.symbolLayer.material?.color}_updateTransparentDepedentMaterialParameters(){const t=this._materials[0];t&&t.setParameters({cullFace:t.transparent?0:2})}}function Q(t,e,r,s,o,n){const i=P(e.length),a=[["position",new R(s.positions,e,3,!0)],["normalCompressed",new R(s.normals,e,2,!0)],["symbolColor",new R(o,i,4,!0)]];return new H(t,a,s.elevation,0,n,r)}function X(t,e,r,s,o,n,i,a,l,c,p,m,h){const u=r.length/3;let d=2*s.count;Y(t,e,s.index,s.count,r,0,u,o,n,i,a,l,c,d,p,m,h);let g=0,f=2*s.count;d=0;const y=s.pathLengths[0];et(o,n,a,i,g,y,s.count,f,l,d,p),f+=4*y,d+=2*y,g+=y;for(let b=1;b<s.pathLengths.length;++b){const t=s.pathLengths[b];et(o,n,a,i,g,t,s.count,f,l,d,p),f+=4*t,d+=2*t,g+=t}}function Y(t,e,r,s,o,n,i,a,l,c,p,m,u,g,f,y,b){d(ut,y),l??=[],c??=[],p??=[];const _=f>0?1:-1;let x=3*r,j=0,S=3*j,w=s,P=3*w;for(let d=0;d<s;++d){const r=t[x],s=t[x+1],o=t[x+2];b&&(ut[0]=r,ut[1]=s,ut[2]=o,h(ut,ut)),a[S+0]=r,a[S+1]=s,a[S+2]=o;const n=e[x+0],i=e[x+1],m=e[x+2];l[S+0]=n,l[S+1]=i,l[S+2]=m,c[S+0]=-_*ut[0],c[S+1]=-_*ut[1],c[S+2]=-_*ut[2],p[j]=0,a[P+0]=r+f*ut[0],a[P+1]=s+f*ut[1],a[P+2]=o+f*ut[2],l[P+0]=n,l[P+1]=i,l[P+2]=m,p[w]=f,S+=3,P+=3,x+=3,j+=1,w+=1}x=3*n,S=0,P=3*g;const v=f<0?ft:gt,C=f<0?gt:ft;for(let h=0;h<i;++h)u[S]=o[x+v[0]],u[S+1]=o[x+v[1]],u[S+2]=o[x+v[2]],m[P]=o[x+C[0]]+s,m[P+1]=o[x+C[1]]+s,m[P+2]=o[x+C[2]]+s,S+=3,P+=3,x+=3}function $(t,e,r,s,o,n,i){s[n]=s[i],i*=3,t[n*=3]=t[i],t[n+1]=t[i+1],t[n+2]=t[i+2],e[n]=e[i],e[n+1]=e[i+1],e[n+2]=e[i+2],r[n]=o[0],r[n+1]=o[1],r[n+2]=o[2]}const tt=y();function et(t,e,r,s,o,n,i,a,l,c,p){e??=[],r??=[],s??=[];let m=o,h=o+1,u=o+i,d=o+i+1,g=a,f=a+1,y=a+2*n,b=a+2*n+1;p<0&&(m=o+i+1,d=o);let _=3*c;for(let x=0;x<n;++x)x===n-1&&(h=o,p>0?d=o+i:m=o+i),at(t,m,h,u,tt),$(t,e,s,r,tt,g,m),$(t,e,s,r,tt,f,h),$(t,e,s,r,tt,y,u),$(t,e,s,r,tt,b,d),l[_]=g,l[_+1]=y,l[_+2]=b,l[_+3]=g,l[_+4]=b,l[_+5]=f,_+=6,m++,h++,u++,d++,g+=2,f+=2,y+=2,b+=2}const rt=y(),st=y(),ot=y(),nt=y(),it=y();function at(t,e,r,s,o){e*=3,r*=3,s*=3,l(rt,t[e++],t[e++],t[e++]),l(st,t[r++],t[r++],t[r++]),l(ot,t[s++],t[s++],t[s++]),g(nt,st,rt),g(it,ot,rt),p(o,it,nt),h(o,o)}const lt=y();function ct(t,e,r,s,o,n,c){const p=t.stageObject,m=p.geometries,h=m.length,d="absolute-height"!==e.mode;let g=0;const f=p.transformation,y=i(a(),f);for(let i=0;i<h;i+=2){const t=m[i];if(!k(t))continue;const e=t.getMutableAttribute("position").data,a=n[i/2],h=new B(t.mapPositions),b=e.length/3;let _=!1,x=0;{let t=0;for(let n=0;n<b;n++){lt[0]=e[t],lt[1]=e[t+1],lt[2]=e[t+2],s(h,dt),d&&(x+=dt.sampledElevation),T.TESTS_DISABLE_OPTIMIZATIONS?(l(ht,h.array[h.offset],h.array[h.offset+1],dt.z+a[t/3]),null!=r&&o.toRenderCoords(ht,r,ht),u(ht,ht,y)):(l(ht,e[t],e[t+1],e[t+2]),u(ht,ht,f),o.setAltitude(ht,dt.z+a[t/3]),u(ht,ht,y)),e[t]=ht[0],e[t+1]=ht[1],e[t+2]=ht[2];const n=yt/o.unitInMeters;(Math.abs(lt[0]-e[t])>=n||Math.abs(lt[1]-e[t+1])>=n||Math.abs(lt[2]-e[t+2])>=n)&&(_=!0),h.offset+=3,t+=3}}if(_){const e=c.get(t);e&&pt(t,e,f),p.geometryVertexAttributeUpdated(m[i],"normalCompressed"),t.invalidateBoundingInfo(),p.geometryVertexAttributeUpdated(m[i],"position"),m[i+1].invalidateBoundingInfo(),p.geometryVertexAttributeUpdated(m[i+1],"position")}g+=x/b}return g/h}function pt(t,e,r){const s=t.getMutableAttribute("position"),o=t.getMutableAttribute("normalCompressed").data,n=s.data,i=t.attributes.get("position").indices,{topVertexStart:a,topVertexCount:d,topFaceStart:g,topFaceCount:f}=e,y=g+f,b=a+d,_=bt,x=_t,j=xt,S=ut,w=ht;l(w,0,0,0);const P=(t,e)=>{const s=3*t;l(e,n[s+0],n[s+1],n[s+2]),u(e,e,r)};for(let l=g;l<y;++l){const t=3*l;P(i[t+0],_[0]),P(i[t+1],_[1]),P(i[t+2],_[2]),c(x,_[1],_[0]),c(j,_[2],_[0]),p(S,x,j),m(w,w,S)}h(w,w);for(let l=a;l<b;++l){const t=w[0],e=w[1],r=w[2];W(o,l,t,e,r)}}function mt(t){return 1===(t.material?.color?.a??0)}const ht=y(),ut=y(),dt=new I,gt=[0,2,1],ft=[0,1,2],yt=.01,bt=[y(),y(),y()],_t=y(),xt=y();class jt{constructor(t,e,r,s){this.positions=t,this.elevation=e,this.normals=r,this.heights=s}}class St{constructor(t,e,r,s){this.topVertexStart=t,this.topVertexCount=e,this.topFaceStart=r,this.topFaceCount=s}}export{K as Graphics3DExtrudeSymbolLayer,X as extrudePolygon};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import{linearize as t}from"../../../../colorUtils.js";import"../../../../core/has.js";import{deg2rad as r}from"../../../../core/mathUtils.js";import{releaseMaybe as o}from"../../../../core/maybe.js";import{isPromiseLike as n}from"../../../../core/promiseUtils.js";import{normalFromMat4 as a,fromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as l,multiply as c,invert as u,getTranslation as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f,IDENTITY as p,clone as h}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as d}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{h as g,i as x,j as _,p as y,t as T,n as b,c as v,e as w,f as C,g as j}from"../../../../chunks/vec32.js";import{create as M,fromValues as A,ONES as R,ZEROS as P}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as S}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as I}from"../../../../geometry/projectionUtils.js";import{computeTranslationToOriginAndRotation as B}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as U}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as E}from"../../../../geometry/projection/projectVectorToVector.js";import{fromBuffer as O,create as F,intersectsClippingArea as V}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as $}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as G,getContinuousIndexArray as D}from"../../../../geometry/support/Indices.js";import L from"../../../../geometry/support/MeshComponent.js";import N from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import H from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as k,isAbsoluteVertexSpace as z}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as q,isPlateCarree as W}from"../../../../geometry/support/spatialReferenceUtils.js";import{t as Y}from"../../../../chunks/vec3.js";import{transformNormal as J,transformVectorENUPlateCarree as K,transformVectorWMPlateCarree as Q,projectNormalToPCPF as X,transformTangent as Z,projectTangentToPCPF as ee}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as te}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{getEmissiveMode as re}from"../../../../symbols/support/materialUtils.js";import{isEncodedMeshTexture as oe}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as ne}from"../../glTF/internal/TextureTransformUtils.js";import{defaultSymbolLayerMemoryComplexity as ae}from"./defaultSymbolComplexity.js";import{perObjectElevationAligner as se}from"./ElevationAligners.js";import{needsElevationUpdates3D as ie,evaluateElevationInfoAtPoint as le}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as ce}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as ue}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as me,nanFallbackColor as fe}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as pe,MeshFastUpdateProcessor as he}from"./MeshFastUpdateProcessor.js";import{SymbolComplexity as de}from"./SymbolComplexity.js";import{hasEdges as ge,createMaterial as xe}from"../support/edgeUtils.js";import{debugFlags as _e}from"../../support/debugFlags.js";import{Attribute as ye}from"../../webgl-engine/lib/Attribute.js";import{Geometry as Te}from"../../webgl-engine/lib/Geometry.js";import{ManagedTexture as be}from"../../webgl-engine/lib/ManagedTexture.js";import{Object3D as ve}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as we}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as Ce}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as je,advancedMRRFactors as Me,schematicMRRFactors as Ae}from"../../webgl-engine/materials/pbrUtils.js";const Re=["mesh"];class Pe extends me{constructor(e,t,r,o){super(e,t,r,o,We(t)),this._materialInfoCache=new pe,this._fastUpdateProcessor=new he,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){_e.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new Ce({color:[1,0,1,1]}),this._debugTangentNormalMaterial=new Ce({color:[1,.5,0,1]}),this._debugFaceNormalMaterial=new Ce({color:[0,1,1,1]})),this.updateComplexity()}destroy(){super.destroy(),this._textures.forEach(e=>e.unload()),this._context.stage.removeTextures(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy()}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Re,"fill on mesh-3d"))return null;const r=this.createElevationContextForGraphic(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters(e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTextureAlphaMode(t,e)}),e?.forEach(e=>t(e)?.layerOpacityChanged(r,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,ie)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters(({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),e?.forEach(e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters(({material:t})=>t.setParameters({usePBR:e})),!0}updateTransform(e,t,r,o){if(!e.fastTransformUpdatesAllowed)return!1;const n=e.fastTransformUpdatesEnabled;switch(o){case 0:if(n)return!0;break;case 1:if(!n)return!0;break;default:if(!n)return!!this.updateTransform(e,t,r,0)&&(e.autoDisableFastTransformUpdates(()=>this.updateTransform(e,t,r,1)),!0)}const a=this._context.renderCoordsHelper.spatialReference,s=tt,{origin:i,transform:l}=r;if(!B(t,g(Ke,i.x,i.y,i.z??0),s,a))return!1;switch(o){case 0:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case 1:this._fastUpdateProcessor.disable(e,this._materialInfoCache);break;case 2:e.updateFastLocalOrigin(s,l,this._context.localOriginFactory)}const{elevationContext:c}=e;c.centerInElevationSR=this._getCenterInElevationSR(s);const{elevationProvider:u,renderCoordsHelper:m}=this._context,f=(e,t)=>le(e,u,c,m,t);return e.alignedSampledElevation=se(e,c,u.spatialReference,f,m,s),e.updateTransform(s,l,this._context.isAsync),e.updateAutoDisableFastTransformUpdates(()=>this.updateTransform(e,t,r,1)),!0}computeComplexity(){if(!this._textures||0===this._textures.size)return super.computeComplexity();let e=0;for(const o of this._textures.values())e+=o.usedMemory;const t={...ae(this.symbol,this.symbolLayer),resourceBytes:e},r=ge(this.symbolLayer)?2:0;return new de({drawCallsPerFeature:r,memory:t})}_requiresSymbolVertexColors(){return this._hasDrivenColorOrOpacity}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,n=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:n,uid:`vc:${o},vt:${n},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:n,colorTexture:a,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,f=ke(n),p=ke(a),h=ze(s),d=ke(i),g=ze(l);if(o.color=n,o.colorTexture=a,o.normalTexture=i,o.uid=`${o.uid},cmuid:${f},ctmuid:${p},cttuid:${h},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof N){const{metallic:e,roughness:r,metallicRoughnessTexture:n,metallicRoughnessTextureTransform:a,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:f}=t.material,p=ke(n),h=ze(a),d=ke(i),g=ke(c),x=ze(u),_=ke(m),y=ze(f);o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${p},mrtt:${h},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${y}`,o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=n,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=$e(s),o.normalTextureTransform=$e(l),o.emissiveTextureTransform=$e(u),o.occlusionTextureTransform=$e(f),o.metallicRoughnessTextureTransform=$e(a)}return o}_getInternalTexture(e,t=!1,r=1){const a=He(e);if(!a)return null;const s=`${e.contentHash}/${r}`;let i=this._textures.get(s);if(i){const e=this._context.stage.renderView.textures;let t=null;const r=e.acquire(i.id);return null==r||n(r)||(i.events.on("unloaded",()=>t=o(t)),t=r),i}let l=null;const c=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,u={wrap:Ge(e.wrap),noUnpackFlip:!0,maxAnisotropy:c,mipmap:c>1};return oe(a)?(l=a.data,u.preMultiplyAlpha=!1,u.encoding=a.encoding):(l=a,u.preMultiplyAlpha=1!==r,u.compressionOptions=t?{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}:void 0),i=new be(l,u),this._textures.set(s,i),i.events.on("loaded",()=>this.updateComplexity()),i.load(this._context.stage.renderView.renderingContext),this._context.stage.addTexture(i),i.events.on("unloaded",()=>{this._textures.delete(s)}),i}_setInternalMaterialTextureParameters(r,o){if(null!=r.colorTexture){const e=1!==o.textureAlphaMode,t=this._getInternalTexture(r.colorTexture,e,o.textureAlphaMode);t?(o.textureId=t.id,o.textureAlphaPremultiplied=!!t.parameters.preMultiplyAlpha):o.textureId=void 0}if(r.normalTexture&&(o.normalTextureId=this._getInternalTexture(r.normalTexture)?.id),r.emissiveColor){const n=e.toUnitRGB(r.emissiveColor);o.emissiveBaseColor=A(t(n[0]),t(n[1]),t(n[2]))}r.emissiveTexture&&(o.emissiveTextureId=this._getInternalTexture(r.emissiveTexture)?.id),r.occlusionTexture&&(o.occlusionTextureId=this._getInternalTexture(r.occlusionTexture,!0)?.id),r.metallicRoughnessTexture&&(o.metallicRoughnessTextureId=this._getInternalTexture(r.metallicRoughnessTexture,!0)?.id)}_setInternalMaterialParameters(e,t,r){null!=e.color&&Ne(e.color,t,r),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=ne(e.colorTextureTransform),t.normalTextureTransformMatrix=ne(e.normalTextureTransform);const o=null!=e.normalTextureTransform?.scale?e.normalTextureTransform?.scale:d;t.scale=[o[0],o[1]],t.occlusionTextureTransformMatrix=ne(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=ne(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=ne(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t,r=this._materialColor){const o=this._drivenProperties.color,n=this._drivenProperties.opacity;if(o)t.externalColor=S;else{const o=r??null;if(o){const r=e.toUnitRGBA(o);n&&(r[3]=1),t.externalColor=r}else t.externalColor=fe}t.colorMixMode=this.symbolLayer.material?.colorMixMode??"multiply",t.castShadows=!!this.symbolLayer.castShadows,t.emissiveStrength=this.symbolLayer?.material?.emissive?.strength??1,t.emissiveSource=re(this.symbolLayer?.material?.emissive?.source??"emissive")}_getOrCreateMaterial(t,r){const o=r.material?.color,n=r.material?.colorTexture,a=r.material?.alphaMode,s="blend"===a,i=!("opaque"===a)&&(Le(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:P,diffuse:R,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:0,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||u.isComponentTransparent};f.mrrFactors=m?Ae:[l.metallic,l.roughness,Me[2]],r.material&&(f.doubleSided=r.material.doubleSided,f.cullFace=r.material.doubleSided?0:2,f.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(f),this._setMaterialTextureAlphaMode(f,u),this._setInternalMaterialParameters(l,f,u);const p=new we(f,this._context);return u.material=p,this._materialInfoCache.set(l.uid,u),p}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchColor(e,t)}_preparePatchColor(e,t){if(!t.material||"partial"!==t.material.type)return;const r=t.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const o=r.color.newValue;delete r.color,e.symbolLayerStatePatches.push(()=>{this._updateMaterialParameters(e=>{const t=e.material.parameters;this._setExternalMaterialParameters(t,o),this._setMaterialTextureAlphaMode(t,e),e.material.setParameters({externalColor:t.externalColor})})})}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTextureAlphaMode(e,t){if("auto"===t.alphaMode){const r=this.needsDrivenTransparentPass||t.isComponentTransparent||(e.layerOpacity??1)<1||(e.opacity??1)<1||(e.externalColor?.[3]??1)<1;e.textureAlphaMode=r?3:1}else e.textureAlphaMode="opaque"===t.alphaMode?1:"mask"===t.alphaMode?2:0}_createFaceDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,n=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),s=[],l=[],c=t[0].transformation,u=a(i(),c);for(let a=0;a<r;a++){const e=t[a].attributes.get("position");if(!e)continue;const r=e.data,o=e.indices;for(let t=0;t<o.length;t+=3)Ve(r,o,t,Ze),Fe(r,o,t,Ke,Qe,Xe),x(Ke,Ke,Qe),x(Ke,Ke,Xe),_(Ke,Ke,1/3),y(Ke,Ke,c),s.push(...Ke),T(Ze,Ze,u),b(Ze,Ze),v(Ke,Ke,Ze,n),s.push(...Ke),l.push(l.length),l.push(l.length)}return s.length?new Te(this._debugFaceNormalMaterial,[["position",new ye(s,l,3,!0)]],null,2):null}_createPerVertexDebugVectors(e,t,r,o,n){const l=t.length,c=e.spatialReference.isGeographic?20015077/180:1,u=.1*n*Math.max(e.extent.width*c,e.extent.height*c,e.extent.zmax-e.extent.zmin),m=[],f=[],p=t[0].transformation,h=a(i(),p);"tangent"===r&&s(h,p);for(let a=0;a<l;a++){const e=t[a],o=e.attributes.get("position"),n=e.attributes.get(r);if(!o||!n)continue;const s=o.data,i=o.indices,l=n.data,c=n.indices;for(let t=0;t<i.length;t++){const e=3*i[t],r=c[t]*n.stride;g(Ke,s[e+0],s[e+1],s[e+2]),y(Ke,Ke,p),m.push(...Ke),g(Qe,l[r+0],l[r+1],l[r+2]),T(Qe,Qe,h),b(Qe,Qe),v(Ke,Ke,Qe,u),m.push(...Ke),f.push(f.length),f.push(f.length)}}return m.length?new Te(o,[["position",new ye(m,f,3,!0)]],null,2):null}_createAs3DShape(e,t,r,o){const n=e.geometry;if("mesh"!==n.type)return null;const a=this._createGeometryInfo(n,t,o);if(null==a)return null;const{geometries:s,objectTransformation:i}=a;if(_e.DRAW_MESH_GEOMETRY_NORMALS){const e=this._createPerVertexDebugVectors(n,s,"normal",this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(n,s,"tangent",this._debugTangentNormalMaterial,.5),r=this._createFaceDebugNormals(n,s);e&&s.push(e),t&&s.push(t),r&&s.push(r)}const l=this._context.layerViewUid,c=new ve({geometries:s,layerViewUid:l,graphicUid:o,isElevationSource:!0});c.transformation=i;const u=xe(this.symbolLayer,{opacity:this._getLayerOpacity()}),m=u?new ue(s[0].material,u,this._context.slicePlaneEnabled):null,f=new ce(this,c,null,se,r,m);this._fastUpdateProcessor.onAddGraphic(),f.needsElevationUpdates=ie(r.mode),f.useObjectOriginAsAttachmentOrigin=!0,f.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(n),r.centerInElevationSR=this._getCenterInElevationSR(c.transformation);const{elevationProvider:p,renderCoordsHelper:h}=this._context,d=(e,t)=>le(e,p,r,h,t);return f.alignedSampledElevation=se(f,r,p.spatialReference,d,h),f}_fastTransformUpdatesAllowed(e){const{vertexSpace:t,spatialReference:r}=e;if(!k(t))return!1;const{type:o}=t,{view:n}=this._context.graphicsCoreOwner,{viewingMode:a}=n.state,s=n.spatialReference;return 1===a&&"local"===o||2===a&&q(s,r)&&"georeferenced"===o&&!r.isGeographic}_getElevationSR(){return this._context.elevationProvider.spatialReference??null}_getCenterInElevationSR(e){const t=M(),r=g(nt,e[12],e[13],e[14]);return E(r,this._context.renderCoordsHelper.spatialReference,t,this._getElevationSR()),t}_passthroughReprojectionInfo(e){return 0===e.reprojection&&!!e.objectTransformation}_createPositionBuffer(e,t){const r=e.vertexAttributes.position;let o,n=r;if(0===t.reprojection)return{position:n,georeferencedPositionBuffer:o};const a=1===t.reprojection?t.transformBeforeProject:null;a&&(n=Y(new Float64Array(n.length),n,a));const{normal:s,tangent:i}=e.vertexAttributes;this._passthroughReprojectionInfo(t)||!s&&!i||(o=n);const l=n===r||n===o?new Float64Array(n.length):n;return U(n,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:o}}_createNormalBuffer(e,t,r,o){const n=e.vertexAttributes.normal;if(null==n)return null;let a=n;const s=1===o.reprojection?o.transformBeforeProject:null;s&&(a=J(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(0===o.reprojection)return a;if("local"===i){if(!W(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return K(a,0,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Q(a,0,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return X(a,r,e.spatialReference,t,c,l)}_createTangentBuffer(e,t,r,o){const n=e.vertexAttributes.tangent;if(null==n)return null;let a=n;const s=1===o.reprojection?o.transformBeforeProject:null;s&&(a=Z(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(0===o.reprojection)return a;if("local"===i){if(!W(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return K(a,1,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Q(a,1,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return ee(a,r,e.spatialReference,t,c,l)}_createSymbolColorBuffer(e){return this._requiresSymbolVertexColors()?new Uint8Array(this._getDrivenUInt8ColorWithNaNSupport(e,this._materialColor,!0)):null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,n=e.vertexAttributes.uv,a=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(n&&n.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),{position:i,georeferencedPositionBuffer:l}=this._createPositionBuffer(e,s),c=qe(e),u=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,l,s),p=this._createTangentBuffer(e,i,l,s),h=n,{transformation:d,position:g,normal:x,tangent:_}=this._passthroughReprojectionInfo(s)?{transformation:s.objectTransformation,position:i,normal:m,tangent:p}:this._transformOriginLocal(e,i,m,p);return{positionBuffer:g,normalBuffer:x,tangentBuffer:_,uvBuffer:h,colorBuffer:c,symbolColorBuffer:u,objectTransformation:d,geometryTransformation:0===s.reprojection&&s.geometryTransformation?s.geometryTransformation:f()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?q(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?0:1:0;if(z(t))return{reprojection:r};const o=t.origin,n=f(),a=e.transform?.localMatrix??p;if(0===r){B(e.spatialReference,o,n,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:n,geometryTransformation:h(a)}}const s=l(f(),o);return c(s,s,a),{reprojection:r,transformBeforeProject:s}}_transformOriginLocal(e,t,r,o){const n=this._context.renderCoordsHelper.spatialReference,a=e.origin;Je[0]=a.x,Je[1]=a.y,Je[2]=a.z??0;const s=f();B(e.spatialReference,Je,s,n),u(et,s);const{position:i,normal:l,tangent:c}=e.vertexAttributes,m=t===i?new Float64Array(t.length):t;Y(m,t,et);const p=r?r===l?new Float32Array(r.length):r:null,h=o?o===c?new Float32Array(o.length):o:null;return r&&p&&J(r,p,et),o&&h&&Z(o,h,et),{transformation:s,position:m,normal:p,tangent:h}}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=te(e,r??e.spatialReference);return!!o&&(O(o,rt),!V(rt,this._context.clippingExtent))}_createGeometryInfo(e,t,r){if(!I(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(!this._validateVertexSpace(e))return null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:n,uvBuffer:a,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:c,objectTransformation:u,geometryTransformation:f}=o,p=e.components??ot,h=new Array;let d=!1;const g=m(Ke,u),x=this._context.localOriginFactory.getOrigin(g);for(const m of p){if(!this._validateFaces(e,m))return null;const t=Ie(e,m);if(0===t.length)continue;const o=Be(n,l,m,t);o.didFlipNormals&&(d=!0);const u=[["position",new ye(n,t,3,!0)],["normal",new ye(o.normals,o.indices,3,!0)]];s&&u.push(["color",new ye(s,t,4,!0)]),i&&u.push(["symbolColor",new ye(i,G(t.length),4,!0)]),a&&u.push(["uv0",new ye(a,t,2,!0)]),c&&u.push(["tangent",new ye(c,t,4,!0)]);const p=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerViewUid:this._context.layerViewUid}),g=this._getOrCreateMaterial(e,m),_=new Te(g,u,null,0,p);_.transformation=f,_.localOrigin=x,h.push(_)}return d&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:h,objectTransformation:u}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial((e,t)=>{t.setParameters(e.parameters)})}_validateVertexSpace(e){const{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:r}=e;return 2!==t||"local"!==r.type||(this.logger.warn("Displaying a mesh with a local vertex space in a view in local viewing mode is not supported."),!1)}test(){return{...super.test(),materials:this._materialInfoCache.materials}}get _materialColor(){return this.symbolLayer.material?.color}}class Se{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}function Ie(e,t){return t.faces??D(e.vertexAttributes.position.length/3)}function Be(e,t,r,o){switch(r.shading||"flat"){default:case"source":return Ee(e,t,r,o);case"flat":return Ue(e,o);case"smooth":return Oe(e,o)}}function Ue(e,t){const r=$(t.length),o=new Array(3*t.length);for(let n=0;n<t.length;n+=3){const a=Ve(e,t,n,Ze);for(let e=0;e<3;e++)r[n+e]=a[e],o[n+e]=n/3}return new Se(r,o,!1)}function Ee(e,t,r,o){if(null==t)return Ue(e,o);let n=!1;if(!r.trustSourceNormals)for(let a=0;a<o.length;a+=3){Ve(e,o,a,Ze);for(let e=0;e<3;e++){const r=3*o[a+e];Ke[0]=t[r],Ke[1]=t[r+1],Ke[2]=t[r+2],j(Ze,Ke)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],n=!0)}}return new Se(t,o,n)}function Oe(e,t){const r={};for(let a=0;a<t.length;a+=3){const o=Ve(e,t,a,Ze);for(let e=0;e<3;e++){const n=t[a+e];let s=r[n];s||(s={normal:M(),count:0},r[n]=s),x(s.normal,s.normal,o),s.count++}}const o=$(3*t.length),n=new Array(3*t.length);for(let a=0;a<t.length;a++){const e=r[t[a]];1!==e.count&&(b(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*a+t]=e.normal[t];n[a]=a}return new Se(o,n,!1)}function Fe(e,t,r,o,n,a){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],n[0]=e[i],n[1]=e[i+1],n[2]=e[i+2],a[0]=e[l],a[1]=e[l+1],a[2]=e[l+2]}function Ve(e,t,r,o){return Fe(e,t,r,Ke,Qe,Xe),w(Qe,Qe,Ke),w(Xe,Xe,Ke),C(Ke,Qe,Xe),b(o,Ke),o}function $e(e){if(!e)return null;const{scale:t,offset:o,rotation:n}=e;return{scale:t,offset:o,rotation:r(n)}}function Ge(e="repeat"){if("string"==typeof e){const t=De(e);return{s:t,t}}return{s:De(e.horizontal),t:De(e.vertical)}}function De(e){switch(e){case"clamp":return 33071;case"mirror":return 33648;default:return 10497}}function Le(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}function Ne(t,r,o){r.diffuse=e.toUnitRGB(t),r.opacity="opaque"===o.alphaMode?1:t.a}function He(e){return e.data??e.url}function ke(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}function ze(e){const{offset:t,scale:r,rotation:o}=e??Ye;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}function qe(e){return e.vertexAttributes.color}function We(e){return 1===(e.material?.color?.a??0)}const Ye=new H,Je=M(),Ke=M(),Qe=M(),Xe=M(),Ze=M(),et=f(),tt=f(),rt=F(),ot=[new L],nt=M();export{Pe as Graphics3DMeshFillSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import{linearize as t}from"../../../../colorUtils.js";import"../../../../core/has.js";import{deg2rad as r}from"../../../../core/mathUtils.js";import{releaseMaybe as o}from"../../../../core/maybe.js";import{isPromiseLike as n}from"../../../../core/promiseUtils.js";import{normalFromMat4 as a,fromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as l,multiply as c,invert as u,getTranslation as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f,IDENTITY as p,clone as h}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as d}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{h as g,i as x,j as _,p as y,t as T,n as b,c as v,e as w,f as C,g as j}from"../../../../chunks/vec32.js";import{create as M,fromValues as R,ONES as A,ZEROS as P}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as S}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as I}from"../../../../geometry/projectionUtils.js";import{computeTranslationToOriginAndRotation as B}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as U}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as E}from"../../../../geometry/projection/projectVectorToVector.js";import{fromBuffer as F,create as O,intersectsClippingArea as V}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as $}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as G,getContinuousIndexArray as D}from"../../../../geometry/support/Indices.js";import L from"../../../../geometry/support/MeshComponent.js";import N from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import H from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as k,isAbsoluteVertexSpace as z}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as q,isPlateCarree as W}from"../../../../geometry/support/spatialReferenceUtils.js";import{t as Y}from"../../../../chunks/vec3.js";import{transformNormal as K,transformVectorENUPlateCarree as J,transformVectorWMPlateCarree as Q,projectNormalToPCPF as X,transformTangent as Z,projectTangentToPCPF as ee}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as te}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{getEmissiveMode as re}from"../../../../symbols/support/materialUtils.js";import{isEncodedMeshTexture as oe}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as ne}from"../../glTF/internal/TextureTransformUtils.js";import{defaultSymbolLayerMemoryComplexity as ae}from"./defaultSymbolComplexity.js";import{perObjectElevationAligner as se}from"./ElevationAligners.js";import{needsElevationUpdates3D as ie,evaluateElevationInfoAtPoint as le}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as ce}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as ue}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as me,nanFallbackColor as fe}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as pe,MeshFastUpdateProcessor as he}from"./MeshFastUpdateProcessor.js";import{SymbolComplexity as de}from"./SymbolComplexity.js";import{hasEdges as ge,createMaterial as xe}from"../support/edgeUtils.js";import{debugFlags as _e}from"../../support/debugFlags.js";import{Attribute as ye}from"../../webgl-engine/lib/Attribute.js";import{Geometry as Te}from"../../webgl-engine/lib/Geometry.js";import{ManagedTexture as be}from"../../webgl-engine/lib/ManagedTexture.js";import{Object3D as ve}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as we}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as Ce}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as je,advancedMRRFactors as Me,schematicMRRFactors as Re}from"../../webgl-engine/materials/pbrUtils.js";const Ae=["mesh"];class Pe extends me{constructor(e,t,r,o){super(e,t,r,o,We(t)),this._materialInfoCache=new pe,this._fastUpdateProcessor=new he,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){_e.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new Ce({color:[1,0,1,1]}),this._debugTangentNormalMaterial=new Ce({color:[1,.5,0,1]}),this._debugFaceNormalMaterial=new Ce({color:[0,1,1,1]})),this.updateComplexity()}destroy(){super.destroy(),this._textures.forEach(e=>e.unload()),this._context.stage.removeTextures(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy()}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Ae,"fill on mesh-3d"))return null;const r=this.createElevationContextForGraphic(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters(e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTextureAlphaMode(t,e)}),e?.forEach(e=>t(e)?.layerOpacityChanged(r,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,ie)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters(({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),e?.forEach(e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters(({material:t})=>t.setParameters({usePBR:e})),!0}updateTransform(e,t,r,o){if(!e.fastTransformUpdatesAllowed)return!1;const n=e.fastTransformUpdatesEnabled;switch(o){case 0:if(n)return!0;break;case 1:if(!n)return!0;break;default:if(!n)return!!this.updateTransform(e,t,r,0)&&(e.autoDisableFastTransformUpdates(()=>this.updateTransform(e,t,r,1)),!0)}const a=this._context.renderCoordsHelper.spatialReference,s=tt,{origin:i,transform:l}=r;if(!B(t,g(Je,i.x,i.y,i.z??0),s,a))return!1;switch(o){case 0:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case 1:this._fastUpdateProcessor.disable(e,this._materialInfoCache);break;case 2:e.updateFastLocalOrigin(s,l,this._context.localOriginFactory)}const{elevationContext:c}=e;c.centerInElevationSR=this._getCenterInElevationSR(s);const{elevationProvider:u,renderCoordsHelper:m}=this._context,f=(e,t)=>le(e,u,c,m,t);return e.alignedSampledElevation=se(e,c,u.spatialReference,f,m,s),e.updateTransform(s,l,this._context.isAsync),e.updateAutoDisableFastTransformUpdates(()=>this.updateTransform(e,t,r,1)),!0}computeComplexity(){if(!this._textures||0===this._textures.size)return super.computeComplexity();let e=0;for(const o of this._textures.values())e+=o.usedMemory;const t={...ae(this.symbol,this.symbolLayer),resourceBytes:e},r=ge(this.symbolLayer)?2:0;return new de({drawCallsPerFeature:r,memory:t})}_requiresSymbolVertexColors(){return this._hasDrivenColorOrOpacity}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,n=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:n,uid:`vc:${o},vt:${n},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:n,colorTexture:a,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,f=ke(n),p=ke(a),h=ze(s),d=ke(i),g=ze(l);if(o.color=n,o.colorTexture=a,o.normalTexture=i,o.uid=`${o.uid},cmuid:${f},ctmuid:${p},cttuid:${h},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof N){const{metallic:e,roughness:r,metallicRoughnessTexture:n,metallicRoughnessTextureTransform:a,emissiveColor:i,emissiveStrength:c,emissiveTexture:u,emissiveTextureTransform:m,occlusionTexture:f,occlusionTextureTransform:p}=t.material,h=ke(n),d=ze(a),g=ke(i),x=ke(u),_=ze(m),y=ke(f),T=ze(p);o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${h},mrtt:${d},emuid:${g},ems:${c},etmuid:${x},ett:${_},otmuid:${y},ott:${T}`,o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=n,o.emissiveColor=i,o.emissiveStrength=c,o.emissiveTexture=u,o.occlusionTexture=f,o.colorTextureTransform=$e(s),o.normalTextureTransform=$e(l),o.emissiveTextureTransform=$e(m),o.occlusionTextureTransform=$e(p),o.metallicRoughnessTextureTransform=$e(a)}return o}_getInternalTexture(e,t=!1,r=1){const a=He(e);if(!a)return null;const s=`${e.contentHash}/${r}`;let i=this._textures.get(s);if(i){const e=this._context.stage.renderView.textures;let t=null;const r=e.acquire(i.id);return null==r||n(r)||(i.events.on("unloaded",()=>t=o(t)),t=r),i}let l=null;const c=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,u={wrap:Ge(e.wrap),noUnpackFlip:!0,maxAnisotropy:c,mipmap:c>1};return oe(a)?(l=a.data,u.preMultiplyAlpha=!1,u.encoding=a.encoding):(l=a,u.preMultiplyAlpha=1!==r,u.compressionOptions=t?{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}:void 0),i=new be(l,u),this._textures.set(s,i),i.events.on("loaded",()=>this.updateComplexity()),i.load(this._context.stage.renderView.renderingContext),this._context.stage.addTexture(i),i.events.on("unloaded",()=>{this._textures.delete(s)}),i}_setInternalMaterialTextureParameters(r,o){if(null!=r.colorTexture){const e=1!==o.textureAlphaMode,t=this._getInternalTexture(r.colorTexture,e,o.textureAlphaMode);t?(o.textureId=t.id,o.textureAlphaPremultiplied=!!t.parameters.preMultiplyAlpha):o.textureId=void 0}if(r.normalTexture&&(o.normalTextureId=this._getInternalTexture(r.normalTexture)?.id),r.emissiveColor){const n=e.toUnitRGB(r.emissiveColor);o.emissiveBaseColor=R(t(n[0]),t(n[1]),t(n[2]))}r.emissiveStrength&&(o.emissiveStrengthKHR=r.emissiveStrength),r.emissiveTexture&&(o.emissiveTextureId=this._getInternalTexture(r.emissiveTexture)?.id),r.occlusionTexture&&(o.occlusionTextureId=this._getInternalTexture(r.occlusionTexture,!0)?.id),r.metallicRoughnessTexture&&(o.metallicRoughnessTextureId=this._getInternalTexture(r.metallicRoughnessTexture,!0)?.id)}_setInternalMaterialParameters(e,t,r){null!=e.color&&Ne(e.color,t,r),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=ne(e.colorTextureTransform),t.normalTextureTransformMatrix=ne(e.normalTextureTransform);const o=null!=e.normalTextureTransform?.scale?e.normalTextureTransform?.scale:d;t.scale=[o[0],o[1]],t.occlusionTextureTransformMatrix=ne(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=ne(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=ne(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t,r=this._materialColor){const o=this._drivenProperties.color,n=this._drivenProperties.opacity;if(o)t.externalColor=S;else{const o=r??null;if(o){const r=e.toUnitRGBA(o);n&&(r[3]=1),t.externalColor=r}else t.externalColor=fe}t.colorMixMode=this.symbolLayer.material?.colorMixMode??"multiply",t.castShadows=!!this.symbolLayer.castShadows,t.emissiveStrengthFromSymbol=this.symbolLayer?.material?.emissive?.strength??1,t.emissiveSource=re(this.symbolLayer?.material?.emissive?.source??"emissive")}_getOrCreateMaterial(t,r){const o=r.material?.color,n=r.material?.colorTexture,a=r.material?.alphaMode,s="blend"===a,i=!("opaque"===a)&&(Le(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:P,diffuse:A,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:0,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||u.isComponentTransparent};f.mrrFactors=m?Re:[l.metallic,l.roughness,Me[2]],r.material&&(f.doubleSided=r.material.doubleSided,f.cullFace=r.material.doubleSided?0:2,f.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(f),this._setMaterialTextureAlphaMode(f,u),this._setInternalMaterialParameters(l,f,u);const p=new we(f,this._context);return u.material=p,this._materialInfoCache.set(l.uid,u),p}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchColor(e,t)}_preparePatchColor(e,t){if(!t.material||"partial"!==t.material.type)return;const r=t.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const o=r.color.newValue;delete r.color,e.symbolLayerStatePatches.push(()=>{this._updateMaterialParameters(e=>{const t=e.material.parameters;this._setExternalMaterialParameters(t,o),this._setMaterialTextureAlphaMode(t,e),e.material.setParameters({externalColor:t.externalColor})})})}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTextureAlphaMode(e,t){if("auto"===t.alphaMode){const r=this.needsDrivenTransparentPass||t.isComponentTransparent||(e.layerOpacity??1)<1||(e.opacity??1)<1||(e.externalColor?.[3]??1)<1;e.textureAlphaMode=r?3:1}else e.textureAlphaMode="opaque"===t.alphaMode?1:"mask"===t.alphaMode?2:0}_createFaceDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,n=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),s=[],l=[],c=t[0].transformation,u=a(i(),c);for(let a=0;a<r;a++){const e=t[a].attributes.get("position");if(!e)continue;const r=e.data,o=e.indices;for(let t=0;t<o.length;t+=3)Ve(r,o,t,Ze),Oe(r,o,t,Je,Qe,Xe),x(Je,Je,Qe),x(Je,Je,Xe),_(Je,Je,1/3),y(Je,Je,c),s.push(...Je),T(Ze,Ze,u),b(Ze,Ze),v(Je,Je,Ze,n),s.push(...Je),l.push(l.length),l.push(l.length)}return s.length?new Te(this._debugFaceNormalMaterial,[["position",new ye(s,l,3,!0)]],null,2):null}_createPerVertexDebugVectors(e,t,r,o,n){const l=t.length,c=e.spatialReference.isGeographic?20015077/180:1,u=.1*n*Math.max(e.extent.width*c,e.extent.height*c,e.extent.zmax-e.extent.zmin),m=[],f=[],p=t[0].transformation,h=a(i(),p);"tangent"===r&&s(h,p);for(let a=0;a<l;a++){const e=t[a],o=e.attributes.get("position"),n=e.attributes.get(r);if(!o||!n)continue;const s=o.data,i=o.indices,l=n.data,c=n.indices;for(let t=0;t<i.length;t++){const e=3*i[t],r=c[t]*n.stride;g(Je,s[e+0],s[e+1],s[e+2]),y(Je,Je,p),m.push(...Je),g(Qe,l[r+0],l[r+1],l[r+2]),T(Qe,Qe,h),b(Qe,Qe),v(Je,Je,Qe,u),m.push(...Je),f.push(f.length),f.push(f.length)}}return m.length?new Te(o,[["position",new ye(m,f,3,!0)]],null,2):null}_createAs3DShape(e,t,r,o){const n=e.geometry;if("mesh"!==n.type)return null;const a=this._createGeometryInfo(n,t,o);if(null==a)return null;const{geometries:s,objectTransformation:i}=a;if(_e.DRAW_MESH_GEOMETRY_NORMALS){const e=this._createPerVertexDebugVectors(n,s,"normal",this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(n,s,"tangent",this._debugTangentNormalMaterial,.5),r=this._createFaceDebugNormals(n,s);e&&s.push(e),t&&s.push(t),r&&s.push(r)}const l=this._context.layerViewUid,c=new ve({geometries:s,layerViewUid:l,graphicUid:o,isElevationSource:!0});c.transformation=i;const u=xe(this.symbolLayer,{opacity:this._getLayerOpacity()}),m=u?new ue(s[0].material,u,this._context.slicePlaneEnabled):null,f=new ce(this,c,null,se,r,m);this._fastUpdateProcessor.onAddGraphic(),f.needsElevationUpdates=ie(r.mode),f.useObjectOriginAsAttachmentOrigin=!0,f.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(n),r.centerInElevationSR=this._getCenterInElevationSR(c.transformation);const{elevationProvider:p,renderCoordsHelper:h}=this._context,d=(e,t)=>le(e,p,r,h,t);return f.alignedSampledElevation=se(f,r,p.spatialReference,d,h),f}_fastTransformUpdatesAllowed(e){const{vertexSpace:t,spatialReference:r}=e;if(!k(t))return!1;const{type:o}=t,{view:n}=this._context.graphicsCoreOwner,{viewingMode:a}=n.state,s=n.spatialReference;return 1===a&&"local"===o||2===a&&q(s,r)&&"georeferenced"===o&&!r.isGeographic}_getElevationSR(){return this._context.elevationProvider.spatialReference??null}_getCenterInElevationSR(e){const t=M(),r=g(nt,e[12],e[13],e[14]);return E(r,this._context.renderCoordsHelper.spatialReference,t,this._getElevationSR()),t}_passthroughReprojectionInfo(e){return 0===e.reprojection&&!!e.objectTransformation}_createPositionBuffer(e,t){const r=e.vertexAttributes.position;let o,n=r;if(0===t.reprojection)return{position:n,georeferencedPositionBuffer:o};const a=1===t.reprojection?t.transformBeforeProject:null;a&&(n=Y(new Float64Array(n.length),n,a));const{normal:s,tangent:i}=e.vertexAttributes;this._passthroughReprojectionInfo(t)||!s&&!i||(o=n);const l=n===r||n===o?new Float64Array(n.length):n;return U(n,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:o}}_createNormalBuffer(e,t,r,o){const n=e.vertexAttributes.normal;if(null==n)return null;let a=n;const s=1===o.reprojection?o.transformBeforeProject:null;s&&(a=K(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(0===o.reprojection)return a;if("local"===i){if(!W(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return J(a,0,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Q(a,0,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return X(a,r,e.spatialReference,t,c,l)}_createTangentBuffer(e,t,r,o){const n=e.vertexAttributes.tangent;if(null==n)return null;let a=n;const s=1===o.reprojection?o.transformBeforeProject:null;s&&(a=Z(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(0===o.reprojection)return a;if("local"===i){if(!W(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return J(a,1,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Q(a,1,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return ee(a,r,e.spatialReference,t,c,l)}_createSymbolColorBuffer(e){return this._requiresSymbolVertexColors()?new Uint8Array(this._getDrivenUInt8ColorWithNaNSupport(e,this._materialColor,!0)):null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,n=e.vertexAttributes.uv,a=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(n&&n.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),{position:i,georeferencedPositionBuffer:l}=this._createPositionBuffer(e,s),c=qe(e),u=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,l,s),p=this._createTangentBuffer(e,i,l,s),h=n,{transformation:d,position:g,normal:x,tangent:_}=this._passthroughReprojectionInfo(s)?{transformation:s.objectTransformation,position:i,normal:m,tangent:p}:this._transformOriginLocal(e,i,m,p);return{positionBuffer:g,normalBuffer:x,tangentBuffer:_,uvBuffer:h,colorBuffer:c,symbolColorBuffer:u,objectTransformation:d,geometryTransformation:0===s.reprojection&&s.geometryTransformation?s.geometryTransformation:f()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?q(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?0:1:0;if(z(t))return{reprojection:r};const o=t.origin,n=f(),a=e.transform?.localMatrix??p;if(0===r){B(e.spatialReference,o,n,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:n,geometryTransformation:h(a)}}const s=l(f(),o);return c(s,s,a),{reprojection:r,transformBeforeProject:s}}_transformOriginLocal(e,t,r,o){const n=this._context.renderCoordsHelper.spatialReference,a=e.origin;Ke[0]=a.x,Ke[1]=a.y,Ke[2]=a.z??0;const s=f();B(e.spatialReference,Ke,s,n),u(et,s);const{position:i,normal:l,tangent:c}=e.vertexAttributes,m=t===i?new Float64Array(t.length):t;Y(m,t,et);const p=r?r===l?new Float32Array(r.length):r:null,h=o?o===c?new Float32Array(o.length):o:null;return r&&p&&K(r,p,et),o&&h&&Z(o,h,et),{transformation:s,position:m,normal:p,tangent:h}}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=te(e,r??e.spatialReference);return!!o&&(F(o,rt),!V(rt,this._context.clippingExtent))}_createGeometryInfo(e,t,r){if(!I(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(!this._validateVertexSpace(e))return null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:n,uvBuffer:a,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:c,objectTransformation:u,geometryTransformation:f}=o,p=e.components??ot,h=new Array;let d=!1;const g=m(Je,u),x=this._context.localOriginFactory.getOrigin(g);for(const m of p){if(!this._validateFaces(e,m))return null;const t=Ie(e,m);if(0===t.length)continue;const o=Be(n,l,m,t);o.didFlipNormals&&(d=!0);const u=[["position",new ye(n,t,3,!0)],["normal",new ye(o.normals,o.indices,3,!0)]];s&&u.push(["color",new ye(s,t,4,!0)]),i&&u.push(["symbolColor",new ye(i,G(t.length),4,!0)]),a&&u.push(["uv0",new ye(a,t,2,!0)]),c&&u.push(["tangent",new ye(c,t,4,!0)]);const p=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerViewUid:this._context.layerViewUid}),g=this._getOrCreateMaterial(e,m),_=new Te(g,u,null,0,p);_.transformation=f,_.localOrigin=x,h.push(_)}return d&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:h,objectTransformation:u}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial((e,t)=>{t.setParameters(e.parameters)})}_validateVertexSpace(e){const{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:r}=e;return 2!==t||"local"!==r.type||(this.logger.warn("Displaying a mesh with a local vertex space in a view in local viewing mode is not supported."),!1)}test(){return{...super.test(),materials:this._materialInfoCache.materials}}get _materialColor(){return this.symbolLayer.material?.color}}class Se{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}function Ie(e,t){return t.faces??D(e.vertexAttributes.position.length/3)}function Be(e,t,r,o){switch(r.shading||"flat"){default:case"source":return Ee(e,t,r,o);case"flat":return Ue(e,o);case"smooth":return Fe(e,o)}}function Ue(e,t){const r=$(t.length),o=new Array(3*t.length);for(let n=0;n<t.length;n+=3){const a=Ve(e,t,n,Ze);for(let e=0;e<3;e++)r[n+e]=a[e],o[n+e]=n/3}return new Se(r,o,!1)}function Ee(e,t,r,o){if(null==t)return Ue(e,o);let n=!1;if(!r.trustSourceNormals)for(let a=0;a<o.length;a+=3){Ve(e,o,a,Ze);for(let e=0;e<3;e++){const r=3*o[a+e];Je[0]=t[r],Je[1]=t[r+1],Je[2]=t[r+2],j(Ze,Je)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],n=!0)}}return new Se(t,o,n)}function Fe(e,t){const r={};for(let a=0;a<t.length;a+=3){const o=Ve(e,t,a,Ze);for(let e=0;e<3;e++){const n=t[a+e];let s=r[n];s||(s={normal:M(),count:0},r[n]=s),x(s.normal,s.normal,o),s.count++}}const o=$(3*t.length),n=new Array(3*t.length);for(let a=0;a<t.length;a++){const e=r[t[a]];1!==e.count&&(b(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*a+t]=e.normal[t];n[a]=a}return new Se(o,n,!1)}function Oe(e,t,r,o,n,a){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],n[0]=e[i],n[1]=e[i+1],n[2]=e[i+2],a[0]=e[l],a[1]=e[l+1],a[2]=e[l+2]}function Ve(e,t,r,o){return Oe(e,t,r,Je,Qe,Xe),w(Qe,Qe,Je),w(Xe,Xe,Je),C(Je,Qe,Xe),b(o,Je),o}function $e(e){if(!e)return null;const{scale:t,offset:o,rotation:n}=e;return{scale:t,offset:o,rotation:r(n)}}function Ge(e="repeat"){if("string"==typeof e){const t=De(e);return{s:t,t}}return{s:De(e.horizontal),t:De(e.vertical)}}function De(e){switch(e){case"clamp":return 33071;case"mirror":return 33648;default:return 10497}}function Le(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}function Ne(t,r,o){r.diffuse=e.toUnitRGB(t),r.opacity="opaque"===o.alphaMode?1:t.a}function He(e){return e.data??e.url}function ke(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}function ze(e){const{offset:t,scale:r,rotation:o}=e??Ye;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}function qe(e){return e.vertexAttributes.color}function We(e){return 1===(e.material?.color?.a??0)}const Ye=new H,Ke=M(),Je=M(),Qe=M(),Xe=M(),Ze=M(),et=f(),tt=f(),rt=O(),ot=[new L],nt=M();export{Pe 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import{throwIfAborted as t}from"../../../../core/promiseUtils.js";import{pt2px as s}from"../../../../core/screenUtils.js";import{identity as r,scale as i,translate as a,copy as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{b as l,q as c,d as h,A as d,i as m,h as u}from"../../../../chunks/vec32.js";import{fromArray as p,ONES as f,create as y,ZEROS as _,fromValues as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as b,ONES as v,create as P}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{computeTranslationToOriginAndRotation as x}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVector as R}from"../../../../geometry/projection/projectPointToVector.js";import{create as S,size as C,containsPoint as L,center as w}from"../../../../geometry/support/aaBoundingBox.js";import{getEmissiveMode as O}from"../../../../symbols/support/materialUtils.js";import{defaultPrimitive as U}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as j,objectSymbolLayerSizeWithResourceSize as E}from"../../../../symbols/support/symbolLayerUtils3D.js";import{estimateNumVerticesForLods as T,defaultSymbolLayerMemoryComplexity as G}from"./defaultSymbolComplexity.js";import{perLodInstanceElevationAligner as B}from"./ElevationAligners.js";import{needsElevationUpdates3D as z,SampleElevationInfo as D,evaluateElevationInfoAtPoint as V}from"./elevationAlignmentUtils.js";import{Graphics3DLodInstanceGraphicLayer as A}from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as F,nanFallbackColor as I}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as k,computeObjectScale as H,computeObjectRotation as M}from"./graphicUtils.js";import{makeLodResources as W}from"./lodResourceUtils.js";import{fetch as N}from"./objectResourceUtils.js";import{placePointOnGeometry as q,extendPointGraphicElevationContext as $}from"./pointUtils.js";import{isValidPrimitive as Z,primitiveLodResources as J}from"./primitiveObjectSymbolUtils.js";import{SymbolComplexity as K}from"./SymbolComplexity.js";import{getResourceUrlFromSymbolStyle as Q}from"./webStyleUtils.js";import{initFastSymbolUpdatesState as X,updateFastSymbolUpdatesState as Y,ConvertOptions as ee,evaluateModelTransformScale as te,evaluateModelTransform as se}from"../support/FastSymbolUpdates.js";import{VerticalOffsetParameters as re}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{LodRenderer as ie}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{DefaultMaterial as ae}from"../../webgl-engine/materials/DefaultMaterial.js";import{schematicMRRFactors as oe}from"../../webgl-engine/materials/pbrUtils.js";class ne{constructor(e,t,s,r,i,a,o,n,l,c,h=null){this.lodResources=e,this.lodRenderer=t,this.stageResources=s,this.resourceSize=r,this.isEsriSymbolResource=i,this.isWosr=a,this.resourceBoundingBox=o,this.symbolSize=n,this.extentPadding=l,this.physicalBasedRenderingEnabled=c,this.pivotOffset=h}}class le extends F{getCachedSize(){const[e,t,s]=null!=this._resources?this._resources.symbolSize:[1,1,1];return{width:e,depth:t,height:s}}constructor(e,t,s,r){super(e,t,s,r,de(t)),this._resources=null,this._instanceIndexToGraphicUid=new Map,this._hasLoadedPBRTextures=!1,this._disposeResourceHandles=new Array,this.skipHighSymbolLodsChanged=!1,this.ensureDrapedStatus(!1),this._hasLoadedPBRTextures=s.physicalBasedRenderingEnabled}async doLoad(e){if(!this._drivenProperties.size){const e=k(this.symbolLayer);if(e)throw new Error(e)}if(this._isPrimitive){const t=this.symbolLayer.resource,s=t&&Z(t?.primitive)?t.primitive:U;this._resources=await this._createResourcesForPrimitive(s,e)}else{const t=await Q(this.symbol.styleOrigin),s=t?.href??this.symbolLayer.resource?.href;this._resources=await this._createResourcesForUrl(s,e)}this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicalBasedRenderingChanged(),this.updateComplexity()}get extentPadding(){return null!=this._resources?this._resources.extentPadding:0}get _isPrimitive(){return null!=this._primitive}get lodRenderer(){return this._resources?.lodRenderer}get materials(){return this._resources?.stageResources.materials??[]}async _createResourcesForPrimitive(t,s){const r=this.symbolLayer,i=S(j(t)),a=p(C(i)),o=p(E(a,r)),n=l(o),c=!1,h=!1,d=r?.material,m={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,mrrFactors:oe,ambient:f,diffuse:f,opacity:1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:r.castShadows,emissiveStrength:d?.emissive?.strength??0,emissiveSource:1,offsetTransparentBackfaces:!1,drivenOpacity:this.needsDrivenTransparentPass},u=!!m.usePBR,y=this.symbol;"point-3d"===y.type&&y.verticalOffset&&(m.verticalOffset=new re(y.verticalOffset),m.castShadows=!1),this._context.screenSizePerspectiveEnabled&&(m.screenSizePerspective=this.view.screenSizePerspective.parameters),this._hasDrivenColorOrOpacity?m.externalColor=I:m.externalColor=e.toUnitRGBA(this._materialColor)??b,this._fastUpdates=X(this._context.renderer,this._fastVisualVariableConvertOptions(i,o,a,null)),m.instanced=!0,this._fastUpdates?(Object.assign(m,this._fastUpdates.materialParameters),m.instancedFeatureAttribute=!0):this._hasDrivenColorOrOpacity&&(m.instancedColor=!0);const _=new ae(m,this._context);_.setParameters({cullFace:me(_.transparent)});const g=J(t,_);if(!g)throw new Error(`Unknown object symbol primitive: ${t}`);const v=await this._createStageResources(g,u,s),P=await this._createLodRenderer(g,s);return new ne(g,P,v,a,c,h,i,o,n,u)}async _createResourcesForUrl(e,t){const r={instanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},i={spherical:this._context.spherical,materialParameters:r,cache:this._context.sharedResources.objectResourceCache,compressionOptions:{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}};this._fastUpdates=X(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(i.materialParameters,this._fastUpdates.materialParameters),i.materialParameters.instancedFeatureAttribute=!0):this._hasDrivenColorOrOpacity&&(i.materialParameters.instancedColor=!0);const a=this.symbol;if("point-3d"===a.type&&a.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=a.verticalOffset;i.materialParameters.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0},i.materialParameters.castShadows=!1}const o=this._context.physicalBasedRenderingEnabled;i.signal=t,i.usePBR=o,i.skipHighLods=this._context.skipHighSymbolLods;const n=this.symbolLayer.material;i.materialParameters.emissiveStrength=n?.emissive?.strength??1,i.materialParameters.emissiveSource=O(n?.emissive?.source??"emissive");const c=await N(e,i),h=c.isEsriSymbolResource,d=c.isWosr,m=W(c.lods),u=this._context,f=this._getExternalColorParameters(n),y=this.needsDrivenTransparentPass,_=m.getMaterials();_.forEach(e=>{e.setParameters({...f,drivenOpacity:y}),u.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:this.view.screenSizePerspective.parameters})});const g=c.referenceBoundingBox,b=p(C(g)),v=p(m.levels[0].pivotOffset),P=p(E(b,this.symbolLayer)),x=l(P),R=this._fastUpdates;Y(R,this._context.renderer,this._fastVisualVariableConvertOptions(g,P,b,v))&&_.forEach(e=>e.setParameters(R.materialParameters));const S=await this._createStageResources(m,o,t),L=await this._createLodRenderer(m,t);return new ne(m,L,S,b,h,d,g,P,x,o,v)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(e,s,r){const i=this._context.stage,a=e.getMaterials();s!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged();const o=e.getTextures();i.addTextures(o),this._addDisposeResource(()=>{o.forEach(e=>e.unload()),i.removeTextures(o)}),await Promise.all(o.map(e=>this._context.stage.schedule(()=>e.load(i.renderView.renderingContext),r))),t(r);const n=e.getEngineGeometries();return{materials:a,textures:o,geometries:n}}async _createLodRenderer(e,t){const s=this._context.stage,r={layerViewUid:this._context.layerViewUid,graphicUid:e=>this._instanceIndexToGraphicUid.get(e),notifyGraphicGeometryChanged:e=>this._context.notifyGraphicGeometryChanged(this._instanceIndexToGraphicUid.get(e)),notifyGraphicVisibilityChanged:e=>this._context.notifyGraphicVisibilityChanged(this._instanceIndexToGraphicUid.get(e))},i=this._fastUpdates,a=new ie({symbol:e,metadata:r,shaderTransformation:i?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,ye),o(s,se(i.materialParameters,ye,s))},scaleFactor:(e,t,s)=>{t.getFeatureAttribute(s,ye),te(e,i.materialParameters,ye)}}:null},this._context.scheduler);return a.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource(()=>{s.removeRenderPlugin(a),a.destroy()}),await s.addRenderPlugin(a,t),a}_getExternalColorParameters(t){const s={};if(s.externalColor=I,!this._drivenProperties.color&&null!=t?.color){const r=e.toUnitRGBA(t.color);this._drivenProperties.opacity&&(r[3]=NaN),s.externalColor=r}return s}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach(e=>e()),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const s=q(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for object symbol: ${t.geometry.type}`),null;const r=this.createElevationContextForGraphic(t),i=e.renderingInfo;return this._createAs3DShape(t,s,i,r,t.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(null==this._resources)return;const e=this._getLayerOpacity(),t=this._resources.stageResources.materials;for(let s=0;s<t.length;s++){const r=t[s];r.setParameters({layerOpacity:e}),this._isPrimitive&&r.setParameters({cullFace:me(r.transparent)})}}layerScreenSizePerspectiveChanged(){if(null==this._resources)return;const e=this._context.screenSizePerspectiveEnabled?this.view.screenSizePerspective.parameters:null;for(const t of this._resources.stageResources.materials)t.setParameters({screenSizePerspective:e})}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,z)}slicePlaneEnabledChanged(){if(null==this._resources)return!0;this._resources.lodRenderer.slicePlaneEnabled=this._context.slicePlaneEnabled;for(const e of this._resources.stageResources.materials)e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled});return!0}physicalBasedRenderingChanged(){if(null==this._resources)return!0;const{stageResources:e,isWosr:t}=this._resources;for(const s of e.materials)this._isPrimitive?s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}):t||s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!1});return!1!==this._hasLoadedPBRTextures||!0!==this._context.physicalBasedRenderingEnabled||(this._hasLoadedPBRTextures=!0,!1)}applyRendererDiff(e,t){if(null==this._resources)return 0;const{stageResources:{materials:s},lodRenderer:r,resourceBoundingBox:i,symbolSize:a,resourceSize:o,pivotOffset:n}=this._resources;for(const l in e.diff){if("visualVariables"!==l)return 0;if(!Y(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,a,o,n)))return 0;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return 2}computeComplexity(){if(null==this._resources)return super.computeComplexity();const e=this._resources.lodResources,t=T(e.levels),s=e.computeUsedMemory(),r={...G(this.symbol,this.symbolLayer),resourceBytes:s};return new K({verticesPerFeature:t,memory:r})}_hasLodRenderer(){return null!=this._resources}_createAs3DShape(e,t,s,r,i){if(!this._hasLodRenderer()||null==this._resources)return null;const a=this.getFastUpdateAttrValues(e),o=this._context.clippingExtent;if(R(t,ue,this._context.elevationProvider.spatialReference),null!=o&&!L(o,ue))return null;const n=he(r),l=this._computeGlobalTransform(t,r,fe,_e),c=this._computeLocalTransform(this._resources,this.symbolLayer,s,pe),h=this._resources.lodRenderer.instanceData,d=h.addInstance();this._instanceIndexToGraphicUid.set(d,i),h.setLocalTransform(d,c,!1),h.setGlobalTransform(d,l),a&&h.setFeatureAttribute(d,a),null==this._fastUpdates&&this._hasDrivenColorOrOpacity&&h.setColor(d,this._getDrivenUInt8ColorWithNaNSupport(s,this._materialColor,!this._isPrimitive));const m=this._context.stage.renderView.olidRenderHelper;if(m){const e=m.getObjectAndLayerIdColor({graphicUid:i,layerViewUid:this._context.layerViewUid});h.setObjectAndLayerIdColor(d,e)}const u=new A(this,d,B,r,this._context.stage.view.state.highlightOrderMap);return n&&(u.alignedSampledElevation=_e.sampledElevation),u.needsElevationUpdates=z(r.mode),$(u,t,this._context.elevationProvider),u}_computeGlobalTransform(e,t,s,r){return V(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),ue[0]=e.x,ue[1]=e.y,ue[2]=r.z,x(e.spatialReference,ue,s,this._context.renderCoordsHelper.spatialReference),s}_computeLocalTransform(e,t,s,i){return r(i),this._applyObjectRotation(s,!1,i),this._applyObjectRotation(t,!0,i),this._applyObjectScale(e,s,i),this._applyAnchor(e,t,i),i}_applyObjectScale(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=this._drivenProperties.size&&t.size?t.size:e.symbolSize,a=H(r,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);1===a[0]&&1===a[1]&&1===a[2]||i(s,s,a)}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchTransform(e,t),this._preparePatchColor(e,t)}updateGeometry(e,t){if(null==this._resources)return!0;const s=e.geometry;if(!s)return!1;const r=q(s);if(null==r)return!1;const i=this.getGeometryElevationMode(s),{elevationContext:a}=t;return a.mode===i&&(a.updateFeatureExpressionFeature(e,this._context.layer),this._computeGlobalTransform(r,a,fe,_e),he(a)&&(t.alignedSampledElevation=_e.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(t.instanceIndex,fe,!0),$(t,r,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!(t.heading||t.tilt||t.roll||t.width||t.height||t.depth||t.anchor||t.anchorPosition))return;if(null==this._resources)return;const s=(e,t,s)=>(null!=e&&"complete"===e.type?e.newValue:t)??s,r=s(t.heading,this.symbolLayer.heading,0),i=s(t.tilt,this.symbolLayer.tilt,0),a=s(t.roll,this.symbolLayer.roll,0),o=s(t.width,this.symbolLayer.width,void 0),n=s(t.height,this.symbolLayer.height,void 0),l=s(t.depth,this.symbolLayer.depth,void 0),c=s(t.anchor,this.symbolLayer.anchor,void 0),h=s(t.anchorPosition,this.symbolLayer.anchorPosition,void 0);delete t.heading,delete t.tilt,delete t.roll,delete t.width,delete t.height,delete t.depth,delete t.anchor,delete t.anchorPosition;const d={heading:r,tilt:i,roll:a,anchor:c,anchorPosition:h},m=this._resources;1===this.loadStatus&&e.symbolLayerStatePatches.push(()=>{m.symbolSize=p(E(m.resourceSize,{width:o,height:n,depth:l,isPrimitive:this._isPrimitive}))}),e.graphics3DGraphicPatches.push(({instanceIndex:e},t)=>{const s=this._computeLocalTransform(m,d,t,pe);m.lodRenderer.instanceData.setLocalTransform(e,s,!0)})}_preparePatchColor(t,s){if(!s.material||"partial"!==s.material.type)return;const r=s.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const i=r.color.newValue,a=null!=i?e.toUnitRGBA(i):v;delete r.color;const o=this._resources;if(null==o)return;const n=this._isPrimitive;t.graphics3DGraphicPatches.push(({instanceIndex:e})=>{if(this._hasDrivenColorOrOpacity)o.lodRenderer.instanceData.setColor(e,a);else{const e={externalColor:a};for(const t of o.stageResources.materials)t.setParameters(e),n&&t.setParameters({cullFace:me(t.transparent)})}})}_applyObjectRotation(e,t,s){if(!this._fastUpdates?.requiresShaderTransformation||!t)return M(e.heading,e.tilt,e.roll,s)}_applyAnchor(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=ce(e.resourceBoundingBox,e.pivotOffset,t);r&&a(s,s,r)}_fastVisualVariableConvertOptions(e,t,s,r){const i=null!=e?p(C(e)):f,a=null!=e?ce(e,r,this.symbolLayer):_,o=this._context.renderCoordsHelper.unitInMeters,n=H(null!=t?t:void 0,t,s,o),l=g(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return new ee({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:i,symbolSize:t??f,unitInMeters:o,anchor:a,scale:n,rotation:l,fallbackColor:this._getFallbackOpacityAndColor(),fallbackSize:n})}get _primitive(){const{resource:e}=this.symbolLayer;return null!=e?.href?null:e?.primitive??U}_getFallbackOpacityAndColor(){return e.toUnitRGBA(this._materialColor)??(this._isPrimitive?b:I)}get _materialColor(){return this.symbolLayer.material?.color}}function ce(e,t,s){const r=y();switch(s.anchor){case"center":h(r,w(e)),c(r,r);break;case"top":{const t=w(e);u(r,-t[0],-t[1],-e[5]);break}case"bottom":{const t=w(e);u(r,-t[0],-t[1],-e[2]);break}case"relative":{const t=w(e),i=C(e),a=s.anchorPosition,o=a?g(a.x,a.y,a.z):_;d(r,i,o),m(r,r,t),c(r,r);break}default:null!=t?c(r,t):h(r,_)}return r}function he(e){return"absolute-height"!==e.mode}function de(e){return 1===(e.material?.color?.a??0)&&null==e.resource?.href}function me(e){return e?0:2}const ue=y(),pe=n(),fe=n(),ye=P(),_e=new D;export{le as Graphics3DObjectSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import{throwIfAborted as t}from"../../../../core/promiseUtils.js";import{pt2px as s}from"../../../../core/screenUtils.js";import{identity as r,scale as i,translate as a,copy as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{b as l,q as c,d as h,A as d,i as m,h as u}from"../../../../chunks/vec32.js";import{fromArray as p,ONES as f,create as y,ZEROS as _,fromValues as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as b,ONES as v,create as P}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{computeTranslationToOriginAndRotation as x}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVector as R}from"../../../../geometry/projection/projectPointToVector.js";import{create as S,size as C,containsPoint as L,center as w}from"../../../../geometry/support/aaBoundingBox.js";import{getEmissiveMode as O}from"../../../../symbols/support/materialUtils.js";import{defaultPrimitive as U}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as j,objectSymbolLayerSizeWithResourceSize as E}from"../../../../symbols/support/symbolLayerUtils3D.js";import{estimateNumVerticesForLods as T,defaultSymbolLayerMemoryComplexity as G}from"./defaultSymbolComplexity.js";import{perLodInstanceElevationAligner as B}from"./ElevationAligners.js";import{needsElevationUpdates3D as z,SampleElevationInfo as D,evaluateElevationInfoAtPoint as V}from"./elevationAlignmentUtils.js";import{Graphics3DLodInstanceGraphicLayer as F}from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as A,nanFallbackColor as I}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as k,computeObjectScale as H,computeObjectRotation as M}from"./graphicUtils.js";import{makeLodResources as W}from"./lodResourceUtils.js";import{fetch as N}from"./objectResourceUtils.js";import{placePointOnGeometry as q,extendPointGraphicElevationContext as $}from"./pointUtils.js";import{isValidPrimitive as Z,primitiveLodResources as J}from"./primitiveObjectSymbolUtils.js";import{SymbolComplexity as K}from"./SymbolComplexity.js";import{getResourceUrlFromSymbolStyle as Q}from"./webStyleUtils.js";import{initFastSymbolUpdatesState as X,updateFastSymbolUpdatesState as Y,ConvertOptions as ee,evaluateModelTransformScale as te,evaluateModelTransform as se}from"../support/FastSymbolUpdates.js";import{VerticalOffsetParameters as re}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{LodRenderer as ie}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{DefaultMaterial as ae}from"../../webgl-engine/materials/DefaultMaterial.js";import{schematicMRRFactors as oe}from"../../webgl-engine/materials/pbrUtils.js";class ne{constructor(e,t,s,r,i,a,o,n,l,c,h=null){this.lodResources=e,this.lodRenderer=t,this.stageResources=s,this.resourceSize=r,this.isEsriSymbolResource=i,this.isWosr=a,this.resourceBoundingBox=o,this.symbolSize=n,this.extentPadding=l,this.physicalBasedRenderingEnabled=c,this.pivotOffset=h}}class le extends A{getCachedSize(){const[e,t,s]=null!=this._resources?this._resources.symbolSize:[1,1,1];return{width:e,depth:t,height:s}}constructor(e,t,s,r){super(e,t,s,r,de(t)),this._resources=null,this._instanceIndexToGraphicUid=new Map,this._hasLoadedPBRTextures=!1,this._disposeResourceHandles=new Array,this.skipHighSymbolLodsChanged=!1,this.ensureDrapedStatus(!1),this._hasLoadedPBRTextures=s.physicalBasedRenderingEnabled}async doLoad(e){if(!this._drivenProperties.size){const e=k(this.symbolLayer);if(e)throw new Error(e)}if(this._isPrimitive){const t=this.symbolLayer.resource,s=t&&Z(t?.primitive)?t.primitive:U;this._resources=await this._createResourcesForPrimitive(s,e)}else{const t=await Q(this.symbol.styleOrigin),s=t?.href??this.symbolLayer.resource?.href;this._resources=await this._createResourcesForUrl(s,e)}this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicalBasedRenderingChanged(),this.updateComplexity()}get extentPadding(){return null!=this._resources?this._resources.extentPadding:0}get _isPrimitive(){return null!=this._primitive}get lodRenderer(){return this._resources?.lodRenderer}get materials(){return this._resources?.stageResources.materials??[]}async _createResourcesForPrimitive(t,s){const r=this.symbolLayer,i=S(j(t)),a=p(C(i)),o=p(E(a,r)),n=l(o),c=!1,h=!1,d=r?.material,m={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,mrrFactors:oe,ambient:f,diffuse:f,opacity:1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:r.castShadows,emissiveStrengthFromSymbol:d?.emissive?.strength??0,emissiveSource:1,offsetTransparentBackfaces:!1,drivenOpacity:this.needsDrivenTransparentPass},u=!!m.usePBR,y=this.symbol;"point-3d"===y.type&&y.verticalOffset&&(m.verticalOffset=new re(y.verticalOffset),m.castShadows=!1),this._context.screenSizePerspectiveEnabled&&(m.screenSizePerspective=this.view.screenSizePerspective.parameters),this._hasDrivenColorOrOpacity?m.externalColor=I:m.externalColor=e.toUnitRGBA(this._materialColor)??b,this._fastUpdates=X(this._context.renderer,this._fastVisualVariableConvertOptions(i,o,a,null)),m.instanced=!0,this._fastUpdates?(Object.assign(m,this._fastUpdates.materialParameters),m.instancedFeatureAttribute=!0):this._hasDrivenColorOrOpacity&&(m.instancedColor=!0);const _=new ae(m,this._context);_.setParameters({cullFace:me(_.transparent)});const g=J(t,_);if(!g)throw new Error(`Unknown object symbol primitive: ${t}`);const v=await this._createStageResources(g,u,s),P=await this._createLodRenderer(g,s);return new ne(g,P,v,a,c,h,i,o,n,u)}async _createResourcesForUrl(e,t){const r={instanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},i={spherical:this._context.spherical,materialParameters:r,cache:this._context.sharedResources.objectResourceCache,compressionOptions:{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}};this._fastUpdates=X(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(i.materialParameters,this._fastUpdates.materialParameters),i.materialParameters.instancedFeatureAttribute=!0):this._hasDrivenColorOrOpacity&&(i.materialParameters.instancedColor=!0);const a=this.symbol;if("point-3d"===a.type&&a.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=a.verticalOffset;i.materialParameters.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0},i.materialParameters.castShadows=!1}const o=this._context.physicalBasedRenderingEnabled;i.signal=t,i.usePBR=o,i.skipHighLods=this._context.skipHighSymbolLods;const n=this.symbolLayer.material;i.materialParameters.emissiveStrengthFromSymbol=n?.emissive?.strength??1,i.materialParameters.emissiveSource=O(n?.emissive?.source??"emissive");const c=await N(e,i),h=c.isEsriSymbolResource,d=c.isWosr,m=W(c.lods),u=this._context,f=this._getExternalColorParameters(n),y=this.needsDrivenTransparentPass,_=m.getMaterials();_.forEach(e=>{e.setParameters({...f,drivenOpacity:y}),u.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:this.view.screenSizePerspective.parameters})});const g=c.referenceBoundingBox,b=p(C(g)),v=p(m.levels[0].pivotOffset),P=p(E(b,this.symbolLayer)),x=l(P),R=this._fastUpdates;Y(R,this._context.renderer,this._fastVisualVariableConvertOptions(g,P,b,v))&&_.forEach(e=>e.setParameters(R.materialParameters));const S=await this._createStageResources(m,o,t),L=await this._createLodRenderer(m,t);return new ne(m,L,S,b,h,d,g,P,x,o,v)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(e,s,r){const i=this._context.stage,a=e.getMaterials();s!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged();const o=e.getTextures();i.addTextures(o),this._addDisposeResource(()=>{o.forEach(e=>e.unload()),i.removeTextures(o)}),await Promise.all(o.map(e=>this._context.stage.schedule(()=>e.load(i.renderView.renderingContext),r))),t(r);const n=e.getEngineGeometries();return{materials:a,textures:o,geometries:n}}async _createLodRenderer(e,t){const s=this._context.stage,r={layerViewUid:this._context.layerViewUid,graphicUid:e=>this._instanceIndexToGraphicUid.get(e),notifyGraphicGeometryChanged:e=>this._context.notifyGraphicGeometryChanged(this._instanceIndexToGraphicUid.get(e)),notifyGraphicVisibilityChanged:e=>this._context.notifyGraphicVisibilityChanged(this._instanceIndexToGraphicUid.get(e))},i=this._fastUpdates,a=new ie({symbol:e,metadata:r,shaderTransformation:i?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,ye),o(s,se(i.materialParameters,ye,s))},scaleFactor:(e,t,s)=>{t.getFeatureAttribute(s,ye),te(e,i.materialParameters,ye)}}:null},this._context.scheduler);return a.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource(()=>{s.removeRenderPlugin(a),a.destroy()}),await s.addRenderPlugin(a,t),a}_getExternalColorParameters(t){const s={};if(s.externalColor=I,!this._drivenProperties.color&&null!=t?.color){const r=e.toUnitRGBA(t.color);this._drivenProperties.opacity&&(r[3]=NaN),s.externalColor=r}return s}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach(e=>e()),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const s=q(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for object symbol: ${t.geometry.type}`),null;const r=this.createElevationContextForGraphic(t),i=e.renderingInfo;return this._createAs3DShape(t,s,i,r,t.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(null==this._resources)return;const e=this._getLayerOpacity(),t=this._resources.stageResources.materials;for(let s=0;s<t.length;s++){const r=t[s];r.setParameters({layerOpacity:e}),this._isPrimitive&&r.setParameters({cullFace:me(r.transparent)})}}layerScreenSizePerspectiveChanged(){if(null==this._resources)return;const e=this._context.screenSizePerspectiveEnabled?this.view.screenSizePerspective.parameters:null;for(const t of this._resources.stageResources.materials)t.setParameters({screenSizePerspective:e})}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,z)}slicePlaneEnabledChanged(){if(null==this._resources)return!0;this._resources.lodRenderer.slicePlaneEnabled=this._context.slicePlaneEnabled;for(const e of this._resources.stageResources.materials)e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled});return!0}physicalBasedRenderingChanged(){if(null==this._resources)return!0;const{stageResources:e,isWosr:t}=this._resources;for(const s of e.materials)this._isPrimitive?s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}):t||s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!1});return!1!==this._hasLoadedPBRTextures||!0!==this._context.physicalBasedRenderingEnabled||(this._hasLoadedPBRTextures=!0,!1)}applyRendererDiff(e,t){if(null==this._resources)return 0;const{stageResources:{materials:s},lodRenderer:r,resourceBoundingBox:i,symbolSize:a,resourceSize:o,pivotOffset:n}=this._resources;for(const l in e.diff){if("visualVariables"!==l)return 0;if(!Y(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,a,o,n)))return 0;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return 2}computeComplexity(){if(null==this._resources)return super.computeComplexity();const e=this._resources.lodResources,t=T(e.levels),s=e.computeUsedMemory(),r={...G(this.symbol,this.symbolLayer),resourceBytes:s};return new K({verticesPerFeature:t,memory:r})}_hasLodRenderer(){return null!=this._resources}_createAs3DShape(e,t,s,r,i){if(!this._hasLodRenderer()||null==this._resources)return null;const a=this.getFastUpdateAttrValues(e),o=this._context.clippingExtent;if(R(t,ue,this._context.elevationProvider.spatialReference),null!=o&&!L(o,ue))return null;const n=he(r),l=this._computeGlobalTransform(t,r,fe,_e),c=this._computeLocalTransform(this._resources,this.symbolLayer,s,pe),h=this._resources.lodRenderer.instanceData,d=h.addInstance();this._instanceIndexToGraphicUid.set(d,i),h.setLocalTransform(d,c,!1),h.setGlobalTransform(d,l),a&&h.setFeatureAttribute(d,a),null==this._fastUpdates&&this._hasDrivenColorOrOpacity&&h.setColor(d,this._getDrivenUInt8ColorWithNaNSupport(s,this._materialColor,!this._isPrimitive));const m=this._context.stage.renderView.olidRenderHelper;if(m){const e=m.getObjectAndLayerIdColor({graphicUid:i,layerViewUid:this._context.layerViewUid});h.setObjectAndLayerIdColor(d,e)}const u=new F(this,d,B,r,this._context.stage.view.state.highlightOrderMap);return n&&(u.alignedSampledElevation=_e.sampledElevation),u.needsElevationUpdates=z(r.mode),$(u,t,this._context.elevationProvider),u}_computeGlobalTransform(e,t,s,r){return V(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),ue[0]=e.x,ue[1]=e.y,ue[2]=r.z,x(e.spatialReference,ue,s,this._context.renderCoordsHelper.spatialReference),s}_computeLocalTransform(e,t,s,i){return r(i),this._applyObjectRotation(s,!1,i),this._applyObjectRotation(t,!0,i),this._applyObjectScale(e,s,i),this._applyAnchor(e,t,i),i}_applyObjectScale(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=this._drivenProperties.size&&t.size?t.size:e.symbolSize,a=H(r,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);1===a[0]&&1===a[1]&&1===a[2]||i(s,s,a)}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchTransform(e,t),this._preparePatchColor(e,t)}updateGeometry(e,t){if(null==this._resources)return!0;const s=e.geometry;if(!s)return!1;const r=q(s);if(null==r)return!1;const i=this.getGeometryElevationMode(s),{elevationContext:a}=t;return a.mode===i&&(a.updateFeatureExpressionFeature(e,this._context.layer),this._computeGlobalTransform(r,a,fe,_e),he(a)&&(t.alignedSampledElevation=_e.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(t.instanceIndex,fe,!0),$(t,r,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!(t.heading||t.tilt||t.roll||t.width||t.height||t.depth||t.anchor||t.anchorPosition))return;if(null==this._resources)return;const s=(e,t,s)=>(null!=e&&"complete"===e.type?e.newValue:t)??s,r=s(t.heading,this.symbolLayer.heading,0),i=s(t.tilt,this.symbolLayer.tilt,0),a=s(t.roll,this.symbolLayer.roll,0),o=s(t.width,this.symbolLayer.width,void 0),n=s(t.height,this.symbolLayer.height,void 0),l=s(t.depth,this.symbolLayer.depth,void 0),c=s(t.anchor,this.symbolLayer.anchor,void 0),h=s(t.anchorPosition,this.symbolLayer.anchorPosition,void 0);delete t.heading,delete t.tilt,delete t.roll,delete t.width,delete t.height,delete t.depth,delete t.anchor,delete t.anchorPosition;const d={heading:r,tilt:i,roll:a,anchor:c,anchorPosition:h},m=this._resources;1===this.loadStatus&&e.symbolLayerStatePatches.push(()=>{m.symbolSize=p(E(m.resourceSize,{width:o,height:n,depth:l,isPrimitive:this._isPrimitive}))}),e.graphics3DGraphicPatches.push(({instanceIndex:e},t)=>{const s=this._computeLocalTransform(m,d,t,pe);m.lodRenderer.instanceData.setLocalTransform(e,s,!0)})}_preparePatchColor(t,s){if(!s.material||"partial"!==s.material.type)return;const r=s.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const i=r.color.newValue,a=null!=i?e.toUnitRGBA(i):v;delete r.color;const o=this._resources;if(null==o)return;const n=this._isPrimitive;t.graphics3DGraphicPatches.push(({instanceIndex:e})=>{if(this._hasDrivenColorOrOpacity)o.lodRenderer.instanceData.setColor(e,a);else{const e={externalColor:a};for(const t of o.stageResources.materials)t.setParameters(e),n&&t.setParameters({cullFace:me(t.transparent)})}})}_applyObjectRotation(e,t,s){if(!this._fastUpdates?.requiresShaderTransformation||!t)return M(e.heading,e.tilt,e.roll,s)}_applyAnchor(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=ce(e.resourceBoundingBox,e.pivotOffset,t);r&&a(s,s,r)}_fastVisualVariableConvertOptions(e,t,s,r){const i=null!=e?p(C(e)):f,a=null!=e?ce(e,r,this.symbolLayer):_,o=this._context.renderCoordsHelper.unitInMeters,n=H(null!=t?t:void 0,t,s,o),l=g(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return new ee({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:i,symbolSize:t??f,unitInMeters:o,anchor:a,scale:n,rotation:l,fallbackColor:this._getFallbackOpacityAndColor(),fallbackSize:n})}get _primitive(){const{resource:e}=this.symbolLayer;return null!=e?.href?null:e?.primitive??U}_getFallbackOpacityAndColor(){return e.toUnitRGBA(this._materialColor)??(this._isPrimitive?b:I)}get _materialColor(){return this.symbolLayer.material?.color}}function ce(e,t,s){const r=y();switch(s.anchor){case"center":h(r,w(e)),c(r,r);break;case"top":{const t=w(e);u(r,-t[0],-t[1],-e[5]);break}case"bottom":{const t=w(e);u(r,-t[0],-t[1],-e[2]);break}case"relative":{const t=w(e),i=C(e),a=s.anchorPosition,o=a?g(a.x,a.y,a.z):_;d(r,i,o),m(r,r,t),c(r,r);break}default:null!=t?c(r,t):h(r,_)}return r}function he(e){return"absolute-height"!==e.mode}function de(e){return 1===(e.material?.color?.a??0)&&null==e.resource?.href}function me(e){return e?0:2}const ue=y(),pe=n(),fe=n(),ye=P(),_e=new D;export{le as Graphics3DObjectSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import"../../../../core/has.js";import t from"../../../../core/Error.js";import{translate as r}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as i,create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as a,scale as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as n,fromArray as l,clone as h}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{h as c}from"../../../../chunks/vec32.js";import{fromArray as p,create as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBuffer as f}from"../../../../geometry/projection/projectBuffer.js";import{create as d,fromSubBuffer as u,intersectsClippingArea as g}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as _,doubleArrayFrom as b}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as y}from"../../../../geometry/support/FloatArray.js";import{needsElevationUpdates3D as v,evaluateElevationAlignmentAtPoint as w,SampleElevationInfo as x}from"./elevationAlignmentUtils.js";import{Graphics3DObject3DGraphicLayer as C}from"./Graphics3DObject3DGraphicLayer.js";import{pathNumRoundJoinSubdivisions as S,pathNumRoundCapExtrusionSubdivisions as P}from"./Graphics3DPathSymbolLayerConstants.js";import{Graphics3DSymbolLayer as D,nanFallbackColor as j}from"./Graphics3DSymbolLayer.js";import{isValidSize as V}from"./graphicUtils.js";import{ConvertOptions as U,initFastSymbolUpdatesState as A,updateFastSymbolUpdatesState as z,getAttributeValue as E}from"../support/FastSymbolUpdates.js";import{SamplePosition as R}from"../../support/ElevationProvider.js";import{Object3D as k}from"../../webgl-engine/lib/Object3D.js";import{Path as L}from"../../webgl-engine/lib/Path.js";import{PathBuilder as G}from"../../webgl-engine/lib/PathBuilder.js";import{RoundCapBuilder as O,TriangulationCapBuilder as I,NoCapBuilder as B}from"../../webgl-engine/lib/PathCapBuilder.js";import{SimpleExtruder as M,MiterExtruder as F}from"../../webgl-engine/lib/PathExtruder.js";import{PathGeometry as T,isPathGeometry as q}from"../../webgl-engine/lib/PathGeometry.js";import{FastUpdatePathGeometry as H,StaticPathGeometry as N}from"../../webgl-engine/lib/PathGeometryData.js";import{computeMinimumRotationTangentFrame as W}from"../../webgl-engine/lib/pathGeometryUtils.js";import{quadProfiles as Z,circleProfiles as J}from"../../webgl-engine/lib/PathProfile.js";import{newPathVertex as K}from"../../webgl-engine/lib/PathVertex.js";import{DefaultMaterial as Q}from"../../webgl-engine/materials/DefaultMaterial.js";import{PathMaterial as X}from"../../webgl-engine/materials/PathMaterial.js";const Y=["polyline"];class $ extends D{constructor(e,t,r,i){super(e,t,r,i,se(t)),this._intrinsicSize=n(1,1),this._upVectorAlignment=1,this._stencilWidth=.1,this.ensureDrapedStatus(!1)}async doLoad(){const e=this.symbolLayer,r=null!=e.width?e.width:e.height,i=null!=e.height?e.height:r;this._vvConvertOptions=new U({supports:{size:!0,color:!0,rotation:!1,opacity:!0},modelSize:[1,1,1],symbolSize:[r,1,i],unitInMeters:this._context.renderCoordsHelper.unitInMeters,fallbackColor:this._getFallbackOpacityAndColor(j),fallbackSize:[r,1,i]});const s=this._context.renderer?.visualVariables;this._fastUpdates=s?.length?A(this._context.renderer,this._vvConvertOptions):null;const n=e.anchor||"center";this._upVectorAlignment="heading"===e.profileRotation?0:1;const h=e.profile||"circle";switch(h){default:case"circle":this._profile=J[n];break;case"quad":this._profile=Z[n]}switch(e.join){case"round":this._extruder=new F(0,S);break;case"bevel":this._extruder=new F(0,1);break;case"miter":this._extruder=new F(.8*Math.PI,1);break;default:this._extruder=new M}switch(this._cap){case"none":this._startCap=new B,this._endCap=new B;break;case"butt":default:this._startCap=new I(this._profile,0),this._endCap=new I(this._profile,0,!0);break;case"square":this._startCap=new I(this._profile,-.5),this._endCap=new I(this._profile,.5,!0);break;case"round":{const e="quad"===h;this._startCap=new O({profile:this._profile,flip:!1,breakNormals:e,subdivisions:P}),this._endCap=new O({profile:this._profile,flip:!0,breakNormals:e,subdivisions:P});break}}const c=this._materialColor,m=this._getCombinedOpacityAndColor(c),f=p(m),d=m[3],u=this.needsDrivenTransparentPass,g=e.material?.emissive,_={diffuse:f,ambient:f,emissiveStrength:g?.strength??0,emissiveSource:1,opacity:d,drivenOpacity:u,hasVertexColors:!1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!0};if(!this._drivenProperties.size&&(a(this._intrinsicSize,r,i),!V(this._intrinsicSize[0])||!V(this._intrinsicSize[1])))throw new t("graphics3dpathsymbollayer:invalid-size","Symbol sizes may not be negative values");let b;this._fastUpdates?.visualVariables.size||o(this._intrinsicSize,this._intrinsicSize,1/this._context.renderCoordsHelper.unitInMeters),this._fastUpdates?b=new X({..._,...this._fastUpdates.materialParameters,size:l(this._intrinsicSize)},this._context):(_.hasVertexColors=this._drivenProperties.color||this._drivenProperties.opacity,_.normalType=1,b=new Q(_,this._context)),b.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),this._materials[0]=b,this._updateTransparentDepedentMaterialParameters()}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Y,this.symbolLayer.type))return null;const r=this.createElevationContextForGraphic(t);return this._createAs3DShape(e,r)}layerOpacityChanged(){const e=this._materialColor,t=this._getCombinedOpacity(e),r=this._materials[0];r&&(r.setParameters({opacity:t}),this._updateTransparentDepedentMaterialParameters())}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,v)}slicePlaneEnabledChanged(){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return this._materials[0]?.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),!0}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return 0;if(!z(this._fastUpdates,t,this._vvConvertOptions))return 0;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return 2}_getVertexData(e){let t=0;const r=e.paths,i=[],s=e.spatialReference,a=this._context.elevationProvider.spatialReference,o=this._context.renderCoordsHelper.spatialReference;for(const c of r)t+=c.length;const n=_(3*t);let l,h=0;for(const c of r){i.push({offset:h,numVertices:c.length});for(const t of c)n[h++]=t[0],n[h++]=t[1],n[h++]=e.hasZ?t[2]:0}return null==a||s.equals(a)||f(n,s,0,n,a,0,t)?(null==a||a.equals(o)?l=b(n):(l=_(3*t),f(n,a,0,l,o,0,t)),{pathVertexDataInfos:i,vertexDataES:n,vertexDataRS:l}):null}_createAs3DShape(e,t){const{graphic:a,renderingInfo:o}=e,n=a.geometry,l=this._getVertexData(n);if(null==l)return this.logger.warn("PathSymbol3DLayer geometry failed to be created (failed to project geometry to view spatial reference)"),null;if(0===l.pathVertexDataInfos.length)return 0!==n.paths.length&&n.paths.some(e=>e.length>0)||this.logger.warn("PathSymbol3DLayer geometry failed to be created (no paths were defined)"),null;const p=new Array,m=n.spatialReference,f=d(),_=this._context.renderCoordsHelper,b=new R(l.vertexDataES),x=a.uid,S=y(l.vertexDataRS.length);for(const d of l.pathVertexDataInfos){const e=d.numVertices;if(e<2)continue;const n=d.offset;if(null!=this._context.clippingExtent&&(u(l.vertexDataES,n,e,f),!g(f,this._context.clippingExtent)))continue;const y=new Array,v=n+3*e;for(let r=n;r<v;r+=3){b.offset=r;const e=w(b,this._context.elevationProvider,t,_);c(ae,l.vertexDataRS[r],l.vertexDataRS[r+1],l.vertexDataRS[r+2]),_.setAltitude(ae,e),l.vertexDataRS[r]=ae[0],l.vertexDataRS[r+1]=ae[1],l.vertexDataRS[r+2]=ae[2],y.push(K(this._upVectorAlignment))}const C=new L(y,l.vertexDataES,l.vertexDataRS,n,S);ee(C,this._upVectorAlignment,this._context.renderCoordsHelper);const P=new G(C,this._profile,this._extruder,this._startCap,this._endCap);let D=null;if(this._fastUpdates){const e=this._fastUpdates.visualVariables,t=E(e.size?.field,a),r=E(e.color?.field,a),i=E(e.opacity?.field,a);D=new H(P,t,r,i)}else{const e=h(this._intrinsicSize);if(this._drivenProperties.size){const t=o.size??["symbol-value","symbol-value","symbol-value"];e[0]*=te(t[0],"symbol-value"===t[2]?this.symbolLayer.height||0:t[2],this.symbolLayer.width||0),e[1]*=te(t[2],"symbol-value"===t[0]?this.symbolLayer.width||0:t[0],this.symbolLayer.height||0)}const t=new N(P);t.bake(e);const r=this._getDrivenColor(o);r&&t.bakeVertexColors(r),D=t}const j=D.createGeometryData(),V=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:x,layerViewUid:this._context.layerViewUid}),U=new T(this._materials[0],j,D,m,this._stencilWidth,V);U.transformation=r(s(),i,P.path.origin),p.push(U)}if(0===p.length)return null;const P=new k({geometries:p,layerViewUid:this._context.layerViewUid,graphicUid:x}),D=new C(this,P,null,(e,t,r,i,s)=>ie(e,t,i,s,this._upVectorAlignment),t,null);return D.alignedSampledElevation=0,D.needsElevationUpdates=v(t.mode),D}_getDrivenColor(e){return this._hasDrivenColorOrOpacity?this._getDrivenUInt8ColorWithNaNSupport(e,this._materialColor,!1):null}get _materialColor(){return this.symbolLayer.material?.color}_getFallbackOpacityAndColor(t){return e.toUnitRGBA(this._materialColor)??t}get _cap(){return this.symbolLayer.cap||"butt"}_updateTransparentDepedentMaterialParameters(){const e=this._materials[0];e&&e.setParameters({cullFace:e.transparent||"none"===this._cap?0:2})}}function ee(e,t,r){const{origin:i,positions:s}=e;let a=e.offset;switch(t){default:case 0:for(const t of e.vertices)ae[0]=s[a++]+i[0],ae[1]=s[a++]+i[1],ae[2]=s[a++]+i[2],r.worldUpAtPosition(ae,ae),t.setFrameFromUpVector(ae);break;case 1:ae[0]=s[a]+i[0],ae[1]=s[a+1]+i[1],ae[2]=s[a+2]+i[2],r.worldUpAtPosition(ae,ae),W(e,ae)}}function te(e,t,r){switch(e){case"symbol-value":return r;case"proportional":return t;default:return e}}function re(e,t,r,i){let s=0;const{origin:a,vertices:o,positions:n,positionsES:l}=e,h=e.offset+3*o.length;for(let p=e.offset;p<h;p+=3)c(ae,l[p],l[p+1],l[p+2]),r(ae,oe),s+=oe.sampledElevation,ae[0]=n[p]+a[0],ae[1]=n[p+1]+a[1],ae[2]=n[p+2]+a[2],i.setAltitude(ae,oe.z),n[p]=ae[0]-a[0],n[p+1]=ae[1]-a[1],n[p+2]=ae[2]-a[2];return e.updatePathVertexInformation(),s/o.length}function ie(e,t,r,i,s){const a=e.stageObject,o=a.geometries;let n=0;for(const l of o){if(!q(l))continue;const e=l.path,o=e.builder.path;n+=re(o,t,r,i),0!==s&&ee(o,s,i),e.onPathChanged(l),l.invalidateBoundingInfo(),a.geometryVertexAttributeUpdated(l,"position")}return n/o.length}function se(e){return 1===(e.material?.color?.a??0)}const ae=m(),oe=new x;export{$ as Graphics3DPathSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import"../../../../core/has.js";import t from"../../../../core/Error.js";import{translate as r}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as i,create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as a,scale as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as n,fromArray as l,clone as h}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{h as c}from"../../../../chunks/vec32.js";import{fromArray as p,create as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBuffer as f}from"../../../../geometry/projection/projectBuffer.js";import{create as d,fromSubBuffer as u,intersectsClippingArea as g}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as _,doubleArrayFrom as b}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as y}from"../../../../geometry/support/FloatArray.js";import{needsElevationUpdates3D as v,evaluateElevationAlignmentAtPoint as w,SampleElevationInfo as x}from"./elevationAlignmentUtils.js";import{Graphics3DObject3DGraphicLayer as C}from"./Graphics3DObject3DGraphicLayer.js";import{pathNumRoundJoinSubdivisions as S,pathNumRoundCapExtrusionSubdivisions as P}from"./Graphics3DPathSymbolLayerConstants.js";import{Graphics3DSymbolLayer as D,nanFallbackColor as j}from"./Graphics3DSymbolLayer.js";import{isValidSize as V}from"./graphicUtils.js";import{ConvertOptions as U,initFastSymbolUpdatesState as A,updateFastSymbolUpdatesState as z,getAttributeValue as E}from"../support/FastSymbolUpdates.js";import{SamplePosition as R}from"../../support/ElevationProvider.js";import{Object3D as k}from"../../webgl-engine/lib/Object3D.js";import{Path as L}from"../../webgl-engine/lib/Path.js";import{PathBuilder as G}from"../../webgl-engine/lib/PathBuilder.js";import{RoundCapBuilder as O,TriangulationCapBuilder as I,NoCapBuilder as B}from"../../webgl-engine/lib/PathCapBuilder.js";import{SimpleExtruder as F,MiterExtruder as M}from"../../webgl-engine/lib/PathExtruder.js";import{PathGeometry as T,isPathGeometry as q}from"../../webgl-engine/lib/PathGeometry.js";import{FastUpdatePathGeometry as H,StaticPathGeometry as N}from"../../webgl-engine/lib/PathGeometryData.js";import{computeMinimumRotationTangentFrame as W}from"../../webgl-engine/lib/pathGeometryUtils.js";import{quadProfiles as Z,circleProfiles as J}from"../../webgl-engine/lib/PathProfile.js";import{newPathVertex as K}from"../../webgl-engine/lib/PathVertex.js";import{DefaultMaterial as Q}from"../../webgl-engine/materials/DefaultMaterial.js";import{PathMaterial as X}from"../../webgl-engine/materials/PathMaterial.js";const Y=["polyline"];class $ extends D{constructor(e,t,r,i){super(e,t,r,i,se(t)),this._intrinsicSize=n(1,1),this._upVectorAlignment=1,this._stencilWidth=.1,this.ensureDrapedStatus(!1)}async doLoad(){const e=this.symbolLayer,r=null!=e.width?e.width:e.height,i=null!=e.height?e.height:r;this._vvConvertOptions=new U({supports:{size:!0,color:!0,rotation:!1,opacity:!0},modelSize:[1,1,1],symbolSize:[r,1,i],unitInMeters:this._context.renderCoordsHelper.unitInMeters,fallbackColor:this._getFallbackOpacityAndColor(j),fallbackSize:[r,1,i]});const s=this._context.renderer?.visualVariables;this._fastUpdates=s?.length?A(this._context.renderer,this._vvConvertOptions):null;const n=e.anchor||"center";this._upVectorAlignment="heading"===e.profileRotation?0:1;const h=e.profile||"circle";switch(h){default:case"circle":this._profile=J[n];break;case"quad":this._profile=Z[n]}switch(e.join){case"round":this._extruder=new M(0,S);break;case"bevel":this._extruder=new M(0,1);break;case"miter":this._extruder=new M(.8*Math.PI,1);break;default:this._extruder=new F}switch(this._cap){case"none":this._startCap=new B,this._endCap=new B;break;case"butt":default:this._startCap=new I(this._profile,0),this._endCap=new I(this._profile,0,!0);break;case"square":this._startCap=new I(this._profile,-.5),this._endCap=new I(this._profile,.5,!0);break;case"round":{const e="quad"===h;this._startCap=new O({profile:this._profile,flip:!1,breakNormals:e,subdivisions:P}),this._endCap=new O({profile:this._profile,flip:!0,breakNormals:e,subdivisions:P});break}}const c=this._materialColor,m=this._getCombinedOpacityAndColor(c),f=p(m),d=m[3],u=this.needsDrivenTransparentPass,g=e.material?.emissive,_={diffuse:f,ambient:f,emissiveStrengthFromSymbol:g?.strength??0,emissiveSource:1,opacity:d,drivenOpacity:u,hasVertexColors:!1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!0};if(!this._drivenProperties.size&&(a(this._intrinsicSize,r,i),!V(this._intrinsicSize[0])||!V(this._intrinsicSize[1])))throw new t("graphics3dpathsymbollayer:invalid-size","Symbol sizes may not be negative values");let b;this._fastUpdates?.visualVariables.size||o(this._intrinsicSize,this._intrinsicSize,1/this._context.renderCoordsHelper.unitInMeters),this._fastUpdates?b=new X({..._,...this._fastUpdates.materialParameters,size:l(this._intrinsicSize)},this._context):(_.hasVertexColors=this._drivenProperties.color||this._drivenProperties.opacity,_.normalType=1,b=new Q(_,this._context)),b.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),this._materials[0]=b,this._updateTransparentDepedentMaterialParameters()}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Y,this.symbolLayer.type))return null;const r=this.createElevationContextForGraphic(t);return this._createAs3DShape(e,r)}layerOpacityChanged(){const e=this._materialColor,t=this._getCombinedOpacity(e),r=this._materials[0];r&&(r.setParameters({opacity:t}),this._updateTransparentDepedentMaterialParameters())}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,v)}slicePlaneEnabledChanged(){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return this._materials[0]?.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),!0}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return 0;if(!z(this._fastUpdates,t,this._vvConvertOptions))return 0;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return 2}_getVertexData(e){let t=0;const r=e.paths,i=[],s=e.spatialReference,a=this._context.elevationProvider.spatialReference,o=this._context.renderCoordsHelper.spatialReference;for(const c of r)t+=c.length;const n=_(3*t);let l,h=0;for(const c of r){i.push({offset:h,numVertices:c.length});for(const t of c)n[h++]=t[0],n[h++]=t[1],n[h++]=e.hasZ?t[2]:0}return null==a||s.equals(a)||f(n,s,0,n,a,0,t)?(null==a||a.equals(o)?l=b(n):(l=_(3*t),f(n,a,0,l,o,0,t)),{pathVertexDataInfos:i,vertexDataES:n,vertexDataRS:l}):null}_createAs3DShape(e,t){const{graphic:a,renderingInfo:o}=e,n=a.geometry,l=this._getVertexData(n);if(null==l)return this.logger.warn("PathSymbol3DLayer geometry failed to be created (failed to project geometry to view spatial reference)"),null;if(0===l.pathVertexDataInfos.length)return 0!==n.paths.length&&n.paths.some(e=>e.length>0)||this.logger.warn("PathSymbol3DLayer geometry failed to be created (no paths were defined)"),null;const p=new Array,m=n.spatialReference,f=d(),_=this._context.renderCoordsHelper,b=new R(l.vertexDataES),x=a.uid,S=y(l.vertexDataRS.length);for(const d of l.pathVertexDataInfos){const e=d.numVertices;if(e<2)continue;const n=d.offset;if(null!=this._context.clippingExtent&&(u(l.vertexDataES,n,e,f),!g(f,this._context.clippingExtent)))continue;const y=new Array,v=n+3*e;for(let r=n;r<v;r+=3){b.offset=r;const e=w(b,this._context.elevationProvider,t,_);c(ae,l.vertexDataRS[r],l.vertexDataRS[r+1],l.vertexDataRS[r+2]),_.setAltitude(ae,e),l.vertexDataRS[r]=ae[0],l.vertexDataRS[r+1]=ae[1],l.vertexDataRS[r+2]=ae[2],y.push(K(this._upVectorAlignment))}const C=new L(y,l.vertexDataES,l.vertexDataRS,n,S);ee(C,this._upVectorAlignment,this._context.renderCoordsHelper);const P=new G(C,this._profile,this._extruder,this._startCap,this._endCap);let D=null;if(this._fastUpdates){const e=this._fastUpdates.visualVariables,t=E(e.size?.field,a),r=E(e.color?.field,a),i=E(e.opacity?.field,a);D=new H(P,t,r,i)}else{const e=h(this._intrinsicSize);if(this._drivenProperties.size){const t=o.size??["symbol-value","symbol-value","symbol-value"];e[0]*=te(t[0],"symbol-value"===t[2]?this.symbolLayer.height||0:t[2],this.symbolLayer.width||0),e[1]*=te(t[2],"symbol-value"===t[0]?this.symbolLayer.width||0:t[0],this.symbolLayer.height||0)}const t=new N(P);t.bake(e);const r=this._getDrivenColor(o);r&&t.bakeVertexColors(r),D=t}const j=D.createGeometryData(),V=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:x,layerViewUid:this._context.layerViewUid}),U=new T(this._materials[0],j,D,m,this._stencilWidth,V);U.transformation=r(s(),i,P.path.origin),p.push(U)}if(0===p.length)return null;const P=new k({geometries:p,layerViewUid:this._context.layerViewUid,graphicUid:x}),D=new C(this,P,null,(e,t,r,i,s)=>ie(e,t,i,s,this._upVectorAlignment),t,null);return D.alignedSampledElevation=0,D.needsElevationUpdates=v(t.mode),D}_getDrivenColor(e){return this._hasDrivenColorOrOpacity?this._getDrivenUInt8ColorWithNaNSupport(e,this._materialColor,!1):null}get _materialColor(){return this.symbolLayer.material?.color}_getFallbackOpacityAndColor(t){return e.toUnitRGBA(this._materialColor)??t}get _cap(){return this.symbolLayer.cap||"butt"}_updateTransparentDepedentMaterialParameters(){const e=this._materials[0];e&&e.setParameters({cullFace:e.transparent||"none"===this._cap?0:2})}}function ee(e,t,r){const{origin:i,positions:s}=e;let a=e.offset;switch(t){default:case 0:for(const t of e.vertices)ae[0]=s[a++]+i[0],ae[1]=s[a++]+i[1],ae[2]=s[a++]+i[2],r.worldUpAtPosition(ae,ae),t.setFrameFromUpVector(ae);break;case 1:ae[0]=s[a]+i[0],ae[1]=s[a+1]+i[1],ae[2]=s[a+2]+i[2],r.worldUpAtPosition(ae,ae),W(e,ae)}}function te(e,t,r){switch(e){case"symbol-value":return r;case"proportional":return t;default:return e}}function re(e,t,r,i){let s=0;const{origin:a,vertices:o,positions:n,positionsES:l}=e,h=e.offset+3*o.length;for(let p=e.offset;p<h;p+=3)c(ae,l[p],l[p+1],l[p+2]),r(ae,oe),s+=oe.sampledElevation,ae[0]=n[p]+a[0],ae[1]=n[p+1]+a[1],ae[2]=n[p+2]+a[2],i.setAltitude(ae,oe.z),n[p]=ae[0]-a[0],n[p+1]=ae[1]-a[1],n[p+2]=ae[2]-a[2];return e.updatePathVertexInformation(),s/o.length}function ie(e,t,r,i,s){const a=e.stageObject,o=a.geometries;let n=0;for(const l of o){if(!q(l))continue;const e=l.path,o=e.builder.path;n+=re(o,t,r,i),0!==s&&ee(o,s,i),e.onPathChanged(l),l.invalidateBoundingInfo(),a.geometryVertexAttributeUpdated(l,"position")}return n/o.length}function se(e){return 1===(e.material?.color?.a??0)}const ae=m(),oe=new x;export{$ as Graphics3DPathSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{
|
|
5
|
+
import{delinearize as e,colorGamma as r}from"../../../../colorUtils.js";import{adjustStaticAGOUrl as t}from"../../../../core/devEnvironmentUtils.js";import{hasScaling as o}from"../../../../core/mathUtils.js";import{normalFromMat4 as s,fromMat4 as i}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as u}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{p as c,e as m,B as f,b as d,n as p,l as g}from"../../../../chunks/vec32.js";import{create as x}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as T,expandWithVec3 as b}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as h}from"../../../../geometry/support/FloatArray.js";import{BufferViewVec3f as y,BufferViewVec4f as v,BufferViewVec4u8 as w,BufferViewVec4u16 as R,BufferViewVec3u8 as S,BufferViewVec3u16 as B}from"../../../../geometry/support/buffer/BufferView.js";import{t as j,b as M,n as F,f as A}from"../../../../chunks/vec3.js";import{t as E,b as C}from"../../../../chunks/vec4.js";import{a as I}from"../../../../chunks/vec2.js";import{DefaultLoadingContext as L}from"../../glTF/DefaultLoadingContext.js";import{convertPrimitiveToTriangles as P}from"../../glTF/internal/indexUtils.js";import{isEncodedMeshTexture as U}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as O}from"../../glTF/internal/TextureTransformUtils.js";import{ProcessedObjectResource as k}from"./ProcessedObjectResource.js";import{load as V,processLoadResult as _}from"./wosrLoader.js";import{Attribute as H}from"../../webgl-engine/lib/Attribute.js";import{Geometry as D}from"../../webgl-engine/lib/Geometry.js";import{ManagedTexture as K}from"../../webgl-engine/lib/ManagedTexture.js";import{DefaultMaterial as G}from"../../webgl-engine/materials/DefaultMaterial.js";import{useSchematicPBR as W,schematicMRRFactors as N,esriSymbologyMRRFactors as Q,advancedMRRFactors as $}from"../../webgl-engine/materials/pbrUtils.js";async function z(e,r){const o=q(t(e));if("wosr"===o.fileType){const e=await(r.cache?r.cache.loadWOSR(o.url,r):V(o.url,r)),{engineResources:t,referenceBoundingBox:s}=_(e,r);return{lods:t,referenceBoundingBox:s,isEsriSymbolResource:!1,isWosr:!0}}let s;if(r.cache)s=await r.cache.loadGLTF(o.url,r,!!r.usePBR);else{const{loadGLTF:e}=await import("../../glTF/loader.js");s=await e(new L,o.url,r,r.usePBR)}const{engineResources:i,referenceBoundingBox:n}=J(s,r,o.specifiedLodIndex);return{lods:i,referenceBoundingBox:n,isEsriSymbolResource:s.meta.isEsriSymbolResource,isWosr:!1}}function q(e){const r=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);if(r)return{fileType:"gltf",url:r[1],specifiedLodIndex:null!=r[4]?Number(r[4]):null};return e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}function J(e,r,t){const o=e.model,s=e.meta,i=o.meta?.ESRI_proxyEllipsoid,n=s.isEsriSymbolResource&&null!=i&&"EsriRealisticTreesStyle"===s.ESRI_webstyle;n&&!e.customMeta.esriTreeRendering&&(e.customMeta.esriTreeRendering=!0,re(e,i));const l=!!r.usePBR,a=s.isEsriSymbolResource?{usePBR:l,isSchematic:!1,treeRendering:n,mrrFactors:Q}:{usePBR:l,isSchematic:!1,treeRendering:!1,mrrFactors:$},u={...r.materialParameters,treeRendering:n},c=new Array,m=new Map,f=new Map,d=o.lods.length,p=T();return o.lods.forEach((e,s)=>{const i=!0===r.skipHighLods&&(d>1&&0===s||d>3&&1===s)||!1===r.skipHighLods&&null!=t&&s!==t;if(i&&0!==s)return;const l=new k(e.name,e.lodThreshold,[0,0,0]);e.parts.forEach(e=>{const t=i?new G({},r):X(o,e,l,a,u,m,f,r,n),{geometry:c,vertexCount:d}=Y(e,t??new G({},r)),g=c.boundingInfo;null!=g&&0===s&&(b(p,g.bbMin),b(p,g.bbMax)),null!=t&&(l.stageResources.geometries.push(c),l.numberOfVertices+=d)}),i||c.push(l)}),{engineResources:c,referenceBoundingBox:p}}function X(r,t,o,s,i,n,l,a,c){const m=r.materials.get(t.material);if(null==m)return null;const{normal:f,color:d,texCoord0:p,tangent:g}=t.attributes,x=t.material+(f?"_normal":"")+(d?"_color":"")+(p?"_texCoord0":"")+(g?"_tangent":""),T=null!=t.attributes.texCoord0,b=null!=t.attributes.normal,h=ee(m.alphaMode);if(!n.has(x)){if(T){const e=(e,t=!1,o=!1)=>{if(null!=e&&!l.has(e)){const s=r.textures.get(e);if(s){const r=s.data,i=t&&!U(r)?a.compressionOptions:void 0;l.set(e,new K(U(r)?r.data:r,{...s.parameters,preMultiplyAlpha:!U(r)&&o,encoding:U(r)?r.encoding:void 0,compressionOptions:i}))}}},t=1!==h&&!c;e(m.colorTexture,t,1!==h),e(m.normalTexture),e(m.occlusionTexture,!0),e(m.emissiveTexture),e(m.metallicRoughnessTexture,!0)}const o=e(m.color[0]),f=e(m.color[1]),d=e(m.color[2]),p=null!=m.colorTexture&&T?l.get(m.colorTexture):null,g=W(m),y=null!=m.normalTextureTransform?.scale?m.normalTextureTransform?.scale:u;n.set(x,new G({...s,customDepthTest:1,textureAlphaMode:h,textureAlphaCutoff:m.alphaCutoff,diffuse:[o,f,d],ambient:[o,f,d],opacity:"OPAQUE"===m.alphaMode?1:m.opacity,doubleSided:m.doubleSided,doubleSidedType:"winding-order",cullFace:m.doubleSided?0:2,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:b?0:2,castShadows:!0,receiveShadows:m.receiveShadows,receiveAmbientOcclusion:m.receiveAmbientOcclusion,textureId:null!=p?p.id:void 0,colorMixMode:m.colorMixMode,normalTextureId:null!=m.normalTexture&&T?l.get(m.normalTexture).id:void 0,textureAlphaPremultiplied:null!=p&&!!p.parameters.preMultiplyAlpha,occlusionTextureId:null!=m.occlusionTexture&&T?l.get(m.occlusionTexture).id:void 0,emissiveTextureId:null!=m.emissiveTexture&&T?l.get(m.emissiveTexture).id:void 0,metallicRoughnessTextureId:null!=m.metallicRoughnessTexture&&T?l.get(m.metallicRoughnessTexture).id:void 0,emissiveBaseColor:[m.emissiveFactor[0],m.emissiveFactor[1],m.emissiveFactor[2]],emissiveStrengthKHR:null!=m.emissiveStrengthKHR?m.emissiveStrengthKHR:1,emissiveStrengthFromSymbol:null!=i.emissiveStrengthFromSymbol?i.emissiveStrengthFromSymbol:void 0,mrrFactors:g?N:[m.metallicFactor,m.roughnessFactor,s.mrrFactors[2]],isSchematic:g,colorTextureTransformMatrix:O(m.colorTextureTransform),normalTextureTransformMatrix:O(m.normalTextureTransform),scale:[y[0],y[1]],occlusionTextureTransformMatrix:O(m.occlusionTextureTransform),emissiveTextureTransformMatrix:O(m.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:O(m.metallicRoughnessTextureTransform),...i},a))}const y=n.get(x);if(o.stageResources.materials.push(y),T){const e=e=>{null!=e&&o.stageResources.textures.push(l.get(e))};e(m.colorTexture),e(m.normalTexture),e(m.occlusionTexture),e(m.emissiveTexture),e(m.metallicRoughnessTexture)}return y}function Y(e,r){const t=e.attributes.position.count,n=P(e.indices||t,e.primitiveType),l=h(3*t),{typedBuffer:a,typedBufferStride:u}=e.attributes.position;j(l,a,e.transform,3,u);const c=[["position",new H(l,n,3,!0)]];if(null!=e.attributes.normal){const r=h(3*t),{typedBuffer:i,typedBufferStride:l}=e.attributes.normal;s(Z,e.transform),M(r,i,Z,3,l),o(Z)&&F(r,r),c.push(["normal",new H(r,n,3,!0)])}if(null!=e.attributes.tangent){const r=h(4*t),{typedBuffer:s,typedBufferStride:l}=e.attributes.tangent;i(Z,e.transform),E(r,s,Z,4,l),o(Z)&&F(r,r,4),c.push(["tangent",new H(r,n,4,!0)])}if(null!=e.attributes.texCoord0){const r=h(2*t),{typedBuffer:o,typedBufferStride:s}=e.attributes.texCoord0;I(r,o,2,s),c.push(["uv0",new H(r,n,2,!0)])}const m=e.attributes.color;if(null!=m){const r=new Uint8Array(4*t);4===m.elementCount?m instanceof v?C(r,m,1,255):(m instanceof w||m instanceof R)&&C(r,m,1/255,255):(r.fill(255),m instanceof y?A(r,m.typedBuffer,1,255,4,m.typedBufferStride):(e.attributes.color instanceof S||e.attributes.color instanceof B)&&A(r,m.typedBuffer,1/255,255,4,e.attributes.color.typedBufferStride)),c.push(["color",new H(r,n,4,!0)])}return{geometry:new D(r,c),vertexCount:t}}const Z=n();function ee(e){switch(e){case"BLEND":return 0;case"MASK":return 2;case"OPAQUE":case null:case void 0:return 1}}function re(e,t){for(let o=0;o<e.model.lods.length;++o){const s=e.model.lods[o];for(const i of s.parts){const s=i.attributes.normal;if(null==s)return;const n=i.attributes.position,u=n.count,T=x(),b=x(),h=x(),w=new Float32Array(4*u),R=new Float32Array(3*u),S=l(a(),i.transform);let B=0,j=0;for(let l=0;l<u;l++){n.getVec(l,b),s.getVec(l,T),c(b,b,i.transform),m(h,b,t.center),f(h,h,t.radius);const a=h[2],u=d(h),x=Math.min(.45+.55*u*u,1)**r;f(h,h,t.radius),null!==S&&c(h,h,S),p(h,h),o+1!==e.model.lods.length&&e.model.lods.length>1&&g(h,h,T,a>-1?.2:Math.min(-4*a-3.8,1)),R[B]=h[0],R[B+1]=h[1],R[B+2]=h[2],B+=3,w[j]=x,w[j+1]=x,w[j+2]=x,w[j+3]=1,j+=4}i.attributes.normal=new y(R.buffer),i.attributes.color=new v(w.buffer)}}}export{z as fetch,q as parseUrl};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{Evented as e}from"../../../../core/Evented.js";import"../../../../core/has.js";import{findInMap as t,someMap as s}from"../../../../core/MapUtils.js";class i extends e{constructor(e,t){super(),this._updateAndCompare=e,this._notifyUpdated=t,this._nodes=new Map,this._graphics=new Map,this._duplicates=new Map}clear(){if(this._graphics.size>0){const e=this.toArray();this._graphics.clear(),this.emit("change",{added:[],removed:e})}this._nodes.clear()}get length(){return this._graphics.size}get(e){return this._graphics.get(e)}getNode(e){return this._nodes.get(e)}hasNode(e){return this._nodes.has(e)}nodes(){return this._nodes.values()}addNode(e,t){this._nodes.set(e,t);const s=t.graphics;if(0===s.length)return;const i=new Set;for(let o=0;o<s.length;o++){const t=s[o],n=t.objectId,
|
|
5
|
+
import{Evented as e}from"../../../../core/Evented.js";import"../../../../core/has.js";import{findInMap as t,someMap as s}from"../../../../core/MapUtils.js";class i extends e{constructor(e,t,s){super(),this._updateAndCompare=e,this._notifyUpdated=t,this._logError=s,this._nodes=new Map,this._graphics=new Map,this._duplicates=new Map}clear(){if(this._graphics.size>0){const e=this.toArray();this._graphics.clear(),this.emit("change",{added:[],removed:e})}this._nodes.clear()}get length(){return this._graphics.size}get(e){return this._graphics.get(e)}getNode(e){return this._nodes.get(e)}hasNode(e){return this._nodes.has(e)}nodes(){return this._nodes.values()}addNode(e,t){if(this._nodes.has(e))return void this._logError(`Added node[${e}] already added`);this._nodes.set(e,t);const s=t.graphics;if(0===s.length)return;const i=new Set;for(let o=0;o<s.length;o++){const t=s[o],n=t.objectId,r=this._graphics.get(n);if(r){i.add(n),t!==r&&(s[o]=r);const h=this._duplicates.get(n);h?h.push(e):this._duplicates.set(n,[r.nodeIndex,e])}else t.nodeIndex=e,this._graphics.set(n,t)}i.size&&this._updateForeignGraphics(t);const n=i.size>0?s.filter(e=>!i.has(e.objectId)):s;n.length>0&&this.emit("change",{added:n,removed:[]})}removeNode(e){const t=this._nodes.get(e);if(!t)return;this._nodes.delete(e);const s=new Set,i=[];for(const n of t.graphics){const t=n.objectId,o=this._graphics.get(t);if(!o)continue;const r=this._duplicates.get(t);if(r){const i=r.indexOf(e);if(-1===i)continue;if(r.splice(i,1),o.nodeIndex===e){let e=this.getNode(r[0]);for(let t=1;t<r.length;t++){const s=this.getNode(r[t]);(null==e||null!=s&&s.node.level>e.node.level)&&(e=s)}null!=e&&s.add(e)}1===r.length&&this._duplicates.delete(t)}else this._graphics.delete(t),i.push(n)}i.length>0&&this.emit("change",{added:[],removed:i}),s.forEach(e=>this._updateForeignGraphics(e))}_updateForeignGraphics(e){const t=[],s=e.node.index,i=e.node.level;let n=0;for(;n<e.graphics.length;){const o=e.graphics[n].nodeIndex;if(o===s){n++;continue}let r=1;for(;n+r<e.graphics.length&&e.graphics[n+r].nodeIndex===o;)r++;const h=this.getNode(o);if(null!=h&&h.node.level>i)n+=r;else{for(let i=n;i<n+r;i++){const n=e.graphics[i];n.nodeIndex=s,this._updateAndCompare(n,e,i)&&t.push(n)}n+=r}}t.length>0&&this._notifyUpdated(t)}toArray(){return Array.from(this._graphics.values())}find(e){return t(this._graphics,e)}some(e){return s(this._graphics,e)}forEach(e){this._graphics.forEach(t=>e(t))}forEachNode(e){this._nodes.forEach((t,s)=>e(t,s))}get nodeCount(){return this._nodes.size}_checkInvariants(){const e=new Map;this._nodes.forEach((t,s)=>{t.graphics.forEach(t=>{e.set(t.objectId,1+(e.get(t.objectId)??0)),this._duplicates.get(t.objectId)})}),e.forEach((e,t)=>{const s=this._graphics.get(t);if(!s)return;if(!this._nodes.get(s.nodeIndex))return;const i=this._duplicates.get(t);i&&i.forEach(e=>{this._nodes.get(e)})})}}export{i as I3SGraphicsMap};
|