@arcgis/core 4.33.0-next.20250310 → 4.33.0-next.20250312
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/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{f0351930cbb3d8643119.js → 0a98dc3ea67ce97a6e7b.js} +1 -1
- package/assets/esri/core/workers/chunks/{eacab4bd6eb58e545f73.js → 11f9d7cd95891596b716.js} +1 -1
- package/assets/esri/core/workers/chunks/{400951e3e742452a5fe2.js → 3ee2cf2db08164cde43c.js} +45 -45
- package/assets/esri/core/workers/chunks/4d95cc85f4b73e857b1f.js +1 -0
- package/assets/esri/core/workers/chunks/54ace3e4802934f3f9f2.js +1 -0
- package/assets/esri/core/workers/chunks/5820808c7659460969d4.js +1 -0
- package/assets/esri/core/workers/chunks/{42b862550c96cc1be956.js → 81bf362ec0d23ffdc90c.js} +2 -2
- package/assets/esri/core/workers/chunks/add0770399a63b7635b5.js +1 -0
- package/assets/esri/core/workers/chunks/b2f8702a9f54fff23ad9.js +1 -0
- package/assets/esri/core/workers/chunks/b8b8425e8b1246cdc86d.js +1 -0
- package/assets/esri/core/workers/chunks/d0ad20548eb4786b7750.js +314 -0
- package/assets/esri/core/workers/chunks/d0fbd4c6bffe0cb98d14.js +1 -0
- package/assets/esri/core/workers/chunks/dd6f18bbab50be139d20.js +1 -0
- package/assets/esri/core/workers/chunks/de6864e120243cf0bee8.js +1 -0
- package/assets/esri/core/workers/chunks/fc7ce48c7b31a4665a9b.js +1 -0
- package/chunks/DefaultMaterial.glsl.js +21 -21
- package/chunks/Pattern.glsl.js +23 -25
- package/chunks/RealisticTree.glsl.js +12 -12
- package/chunks/Terrain.glsl.js +27 -27
- package/core/LRUCache.js +1 -1
- package/core/MemCache.js +1 -1
- package/editing/sharedTemplates/SharedTemplateProvider.js +1 -1
- package/geometry/support/ShortArray.js +5 -0
- package/interfaces.d.ts +18 -4
- package/layers/video/VideoController.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedComputedData.js +1 -1
- package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
- package/views/3d/environment/Precipitation.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/Graphics3DObject3DGraphicLayer.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/LabelInfo.js +1 -1
- package/views/3d/layers/graphics/defaultSymbolComplexity.js +1 -1
- package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/FeaturePipelineRenderManager.js +1 -1
- package/views/3d/layers/graphics/wosrLoader.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/PathVertexPosition.glsl.js +63 -77
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexPosition.glsl.js +6 -6
- package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
- package/views/3d/webgl-engine/lib/Normals.js +1 -1
- package/views/3d/webgl-engine/lib/Object3D.js +1 -1
- package/views/3d/webgl-engine/lib/PathBuilder.js +1 -1
- package/views/3d/webgl-engine/lib/PathGeometryData.js +1 -1
- package/views/3d/webgl-engine/lib/VertexAttribute.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/internal/bufferWriterUtils.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/PerBufferData.js +1 -1
- package/views/3d/webgl-engine/parts/Model.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/RealisticTree.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/Terrain.glsl.js +1 -1
- package/views/FocusAreas.js +1 -1
- package/views/animation/easing.js +1 -1
- package/views/support/projectionUtils.js +1 -1
- package/views/webgl/VertexArrayObject.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FloorFilter/FloorFilterViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/support/GoTo.js +1 -1
- package/widgets/support/goToUtils.js +1 -1
- package/assets/esri/core/workers/chunks/40f2c8022fd583c43f42.js +0 -1
- package/assets/esri/core/workers/chunks/5295e685ae839087c568.js +0 -1
- package/assets/esri/core/workers/chunks/54b115ecf446b4095d3e.js +0 -1
- package/assets/esri/core/workers/chunks/5a536de1ecae424bad05.js +0 -1
- package/assets/esri/core/workers/chunks/6ce738960ee47904968f.js +0 -314
- package/assets/esri/core/workers/chunks/840c02610d845114ace7.js +0 -1
- package/assets/esri/core/workers/chunks/97078a7871e243c19b6b.js +0 -1
- package/assets/esri/core/workers/chunks/9dfdd8e91897d166d888.js +0 -1
- package/assets/esri/core/workers/chunks/a4228101f709f0bb9a3d.js +0 -1
- package/assets/esri/core/workers/chunks/aba4353892c47de98eb3.js +0 -1
- package/assets/esri/core/workers/chunks/c2939e0c45a6d074cac0.js +0 -1
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/PositionAttribute.glsl.js +0 -5
package/package.json
CHANGED
package/support/revision.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
const d="20250312",c="6d4c14dfd5dfb7856aa3c131d0f5066c45df1393";export{d as buildDate,c as commitHash};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{isSome as s}from"../../../../core/arrayUtils.js";import has from"../../../../core/has.js";import r from"../../../../core/Identifiable.js";import{assertIsSome as i}from"../../../../core/maybe.js";import{ignoreAbortErrors as o,throwIfAborted as a}from"../../../../core/promiseUtils.js";import{watch as n}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import{subclass as d}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as c}from"../../../../geometry/support/aaBoundingRect.js";import{isPolyline as l,isPolygon as p,isExtent as u,getJsonType as m}from"../../../../geometry/support/jsonUtils.js";import g from"../../../../layers/support/FieldsIndex.js";import{symbolToCIM as f,CIMSymbolHelper as y}from"../../../../symbols/cim/CIMSymbolHelper.js";import{OverrideHelper as _}from"../../../../symbols/cim/OverrideHelper.js";import{errorPolylineSymbol2D as b,errorPolygonSymbol2D as w,errorPointSymbol2D as S}from"../../../../symbols/support/defaults.js";import{filterFlag0 as I}from"../../engine/webgl/definitions.js";import{FeatureTile as v}from"../../engine/webgl/FeatureTile.js";import{MeshData as T}from"../../engine/webgl/mesh/MeshData.js";import{ResourceProxy as M}from"../../engine/webgl/mesh/factories/ResourceProxy.js";import{createGraphicSymbolMeshSchemas as R}from"../../engine/webgl/shaderGraph/techniques/createGraphicSymbolMeshSchemas.js";import{createStorageSchema as j}from"../features/schema/processor/StorageSchema.js";import{AttributeStore as x}from"../features/support/AttributeStore.js";import{ComputedAttributeStorage as U}from"../features/support/ComputedAttributeStorage.js";import{GraphicsMetadata as C}from"../features/support/FeatureMetadata.js";import{GraphicsReader as q}from"../features/support/GraphicsReader.js";import G from"./GraphicStore.js";import{FeatureCommandQueue as k}from"../support/FeatureCommandQueue.js";import{UpdateTracking2D as P}from"../support/UpdateTracking2D.js";class F{static getOrCreate(e,t,s){let r=t.get(e.id);return r||(r=new F(e,s),t.set(e.id,r)),r}static fromItems(e,t,s){const r=new F(e,s);for(const i of t)r.append(i);return r}constructor(e,t){this.tile=e,this.metadata=t,this.addedOrModified=[],this.removed=[],this.objectIdMap=null}get reader(){return this._reader||(this._reader=q.from(this.addedOrModified,this.tile,this.metadata)),this._reader}append(e){this.addedOrModified.push(e),e.hasAnimations&&(this.objectIdMap=this.objectIdMap||{},this.objectIdMap[e.displayId]=e.objectId)}}let O=class extends(r.IdentifiableMixin(t)){constructor(e){super(e),this._attached=!1,this._tiles=new Map,this._controller=new AbortController,this._hashToSymbolInfo=new Map,this._lastCleanup=performance.now(),this._cleanupRequired=!0,this.lastUpdateId=-1,this.renderer=null,this._updateTracking=new P({debugName:"GraphicsView2D"}),this.updateRequested=!1,this.defaultPointSymbolEnabled=!0,this._commandQueue=new k({process:e=>{if("update"===e.type)return this._update();throw new Error("InternalError: Unsupported command")}}),this.graphicUpdateHandler=this.graphicUpdateHandler.bind(this)}destroy(){this.container.destroy(),this.view=null,this.renderer=null,this._set("graphics",null),this._controller.abort(),this._graphicStore.clear(),this._graphicStore.destroy(),this._attributeStore=null,this._hashToSymbolInfo.clear(),this._updateTracking.destroy(),this._commandQueue.destroy()}_initAttributeStore(){this._storage=new U({spatialReference:this.view.spatialReference,fields:new g}),this._attributeStore=new x({isLocal:!0,update:e=>{has("esri-2d-update-debug")&&console.debug(`[Id: ${this.layerId}] GraphicsView2D.AttributeStoreView.updateStart`,{message:e}),this.container.attributeView.requestUpdate(e),this.container.requestRender(),has("esri-2d-update-debug")&&console.debug(`[Id: ${this.layerId}] GraphicsView2D.AttributeStoreView.updateEnd`,{message:e})}});const e=j(null,[]);this._attributeStore.update(e,this._storage,null),this.container.checkHighlight=()=>this._attributeStore.hasHighlight}initialize(){this._initAttributeStore(),this._metadata=C.createGraphics(this.view.spatialReference),this._resourceProxy=new M({fetch:e=>Promise.all(e.map((e=>this.view.stage.textureManager.rasterizeItem(e)))),fetchDictionary:e=>{throw new Error("InternalError: Graphics do not support Dictionary requests")}}),this.addHandles([n((()=>this._effectiveRenderer),(()=>this._pushUpdate())),this.view.graphicsTileStore.on("update",this._onTileUpdate.bind(this)),this.container.on("attach",(()=>{this.addHandles([this.graphics.on("change",(()=>this._pushUpdate()))]),this._graphicStore?.destroy(),this._graphicStore=new G(this.view.spatialReference,this._cimResourceManager,this.view.featuresTilingScheme,this.view.state.scale,this._attributeStore),this._attached=!0,this.requestUpdate(),this._pushUpdate()}))]),this._updateTracking.addUpdateTracking("CommandQueue",this._commandQueue.updateTracking);const e=this.view.graphicsTileStore.tiles;this._onTileUpdate({added:e,removed:[]})}get _effectiveRenderer(){return"function"==typeof this.renderer?this.renderer():this.renderer}get _cimResourceManager(){return this.view.stage.textureManager.resourceManager}get updating(){const e=!this._attached||this._updateTracking.updating;return has("esri-2d-log-updating")&&console.log(`Updating GraphicsView2D: ${e}\n -> attaching ${!this._attached}\n -> updateTracking ${this._updateTracking.updating}`),e}hitTest(e){if(!this.view||this.view.suspended)return[];const{resolution:t,rotation:r}=this.view.state,i=this._graphicStore.hitTest(e.x,e.y,2,t,r),o=new Set(i),a=this.graphics.items.reduce(((e,t)=>(o.has(t.uid)&&e.set(t.uid,t),e)),new Map);return i.map((e=>a.get(e))).filter(s)}requestUpdate(){this.updateRequested||(this.updateRequested=!0,this.requestUpdateCallback()),this.notifyChange("updating")}processUpdate(e){this.updateRequested&&(this.updateRequested=!1,this.update(e))}viewChange(){this.requestUpdate()}setHighlight(e){const t=[];for(const{objectId:s,highlightFlags:r}of e){const e=this._graphicStore.getItem(s)?.displayId;t.push({objectId:s,highlightFlags:r,displayId:e})}this._attributeStore.setHighlight(t,e),this._pushUpdate()}graphicUpdateHandler(e){this._pushUpdate()}update(e){this.updateRequested=!1,this._attached&&this._graphicStore.updateLevel(e.state.resolution)&&this.pushUpdate()}pushUpdate(){this._pushUpdate()}_pushUpdate(){o(this._commandQueue.push({type:"update"}))}async _update(){try{has("esri-2d-update-debug")&&console.debug(`[Id: ${this.layerId}] GraphicsView._update start`);const e=await this._graphicStore.update(this.graphics,(e=>this._getSymbolForGraphic(e)),(e=>this._ensureSymbolResource(e)));for(const s of e.updated)this.container.restartAnimation(s.objectId);if(!e.hasAnyUpdate())return void this._attributeStore.sendUpdates();e.removed.length&&(this._cleanupRequired=!0),has("esri-2d-update-debug")&&console.debug(`[Id: ${this.layerId}] GraphicsView updateMessage`,e);const t=this._createTileMessages(e);await this._densifyItemsForDisplay(t),await this._fetchResources(t),this._write(t);for(const s of e.added)this._setFilterState(s);for(const s of e.updated)this._setFilterState(s);has("esri-2d-update-debug")&&console.debug(`[Id: ${this.layerId}] GraphicsView sendUpdate`,e),this._attributeStore.sendUpdates(),has("esri-2d-update-debug")&&console.debug(`[Id: ${this.layerId}] GraphicsView sendUpdate.await`,e)}catch(e){}this._cleanupSharedResources()}_createTileMessages(e){const t=new Map;for(const s of e.added){const e=this.view.graphicsTileStore.getIntersectingTiles(s.symbolBounds);for(const r of e){F.getOrCreate(r,t,this._metadata).append(s)}}for(const s of e.updated){const e=this.view.graphicsTileStore.getIntersectingTiles(s.prevSymbolBounds),r=this.view.graphicsTileStore.getIntersectingTiles(s.symbolBounds);for(const i of e){F.getOrCreate(i,t,this._metadata).removed.push(s.displayId)}for(const i of r){F.getOrCreate(i,t,this._metadata).append(s)}}for(const s of e.removed){const e=this.view.graphicsTileStore.getIntersectingTiles(s.symbolBounds);for(const r of e){F.getOrCreate(r,t,this._metadata).removed.push(s.displayId)}}return Array.from(t.values())}async _densifyItemsForDisplay(e){const t=new Map;for(const s of e)for(const e of s.addedOrModified)t.has(e)||t.set(e,e.densifyCurvedGeometryForDisplay(this.view.spatialReference));await Promise.all(t.values())}async _fetchResources(e){const t={timeZone:null,timeExtent:null};for(const{tile:s,reader:r}of e){has("esri-2d-update-debug")&&console.debug(`Id[${this.layerId}] Tile[${s.id}] GraphicsView fetchResources`,e);const i=r.getCursor();for(;i.next();)for(const e of i.getMeshWriters())e.enqueueRequest(this._resourceProxy,i,s.createArcadeEvaluationOptions(t))}await this._resourceProxy.fetchEnqueuedResources()}_write(e){for(const t of e){has("esri-2d-update-debug")&&console.debug(`Id[${this.layerId}] Tile[${t.tile.id}] GraphicsView write`,t);const e=this._writeMeshes(t);let s=this._tiles.get(t.tile.key);s||(s=this._createFeatureTile(t.tile.key)),has("esri-2d-update-debug")&&console.debug(`Id[${this.layerId}] Tile[${t.tile.id}] GraphicsView onTileData`,t),this.container.onTileData(s,{type:"update",modify:e,remove:t.removed,end:!1,attributeEpoch:this._attributeStore.epoch,objectIdMap:t.objectIdMap}),this.container.requestRender()}}_writeMeshes(e){const t={timeZone:null,timeExtent:null},s=new T(e.tile.id),r=e.reader.getCursor();for(;r.next();){s.entityStart(r.getDisplayId(),r.getZOrder());for(const i of r.getMeshWriters())i.write(s,this._resourceProxy,r,e.tile.createArcadeEvaluationOptions(t),e.tile.level);s.entityEnd()}return{...s.serialize().message,tileId:e.tile.id}}_setFilterState(e){const t=e.displayId,s=this._attributeStore.getHighlightFlags(e.objectId);this._attributeStore.setData(t,0,0,s|(e.visible?I:0))}_getSymbolForGraphic(e){return null!=e.symbol?e.symbol:null!=this._effectiveRenderer?this._effectiveRenderer.getSymbol(e):this._getNullSymbol(e)}async _ensureSymbolResource(e){if(!e.symbol)return;const t=await this._getSymbolInfo(e.symbol);if(!t)return;const s=t.linearCIM.filter((e=>"text"===e.type));if(s.length>0){const r=await this._getTextResources(e,s);e.symbolResource={symbolInfo:t,textInfo:r}}else e.symbolResource={symbolInfo:t}}_getSymbolInfo(e){const t=e.hash();return this._hashToSymbolInfo.has(t)||this._hashToSymbolInfo.set(t,this._createSymbolInfo(t,e).catch((e=>null))),this._hashToSymbolInfo.get(t)}async _createSymbolInfo(e,t){const s=await this._convertToCIMSymbol(t),r=await this._createLinearCIM(s);return{hash:e,cimSymbol:s,linearCIM:r,meshWriters:await this._createMeshWriters(s,r)}}async _convertToCIMSymbol(e){const t=f(e);if("web-style"===t.type){return(await t.fetchCIMSymbol()).data}return t}async _createLinearCIM(e){return await Promise.all(y.fetchResources(e.symbol,this._cimResourceManager,[])),this.view.stage.cimAnalyzer.analyzeSymbolReference(e,!1)}async _createMeshWriters(e,t){a(this._controller.signal);const s=this.container.instanceStore,r=this.view.stage.meshWriterRegistry,i=await R(e,t,s);return Promise.all(i.map((e=>r.createMeshWriter(this._storage,this._resourceProxy,{tileInfo:this.view.featuresTilingScheme.tileInfo},e,null))))}_onTileUpdate(e){if(e.added&&e.added.length>0)for(const t of e.added)this._updateTracking.addPromise(this._addTile(t));if(e.removed&&e.removed.length>0)for(const t of e.removed)this._removeTile(t.key)}_createFeatureTile(e){const t=this.view.featuresTilingScheme.getTileBounds(c(),e),s=this.view.featuresTilingScheme.getTileResolution(e.level),r=new v(e,s,t[0],t[3]);return this._tiles.set(e,r),this.container.addChild(r),r}async _addTile(e){if(!this._attached)return;const t=this._graphicStore.queryItems(e);if(!t.length)return;const s=this._createFeatureTile(e.key),r=F.fromItems(e,t,this._metadata);await this._densifyItemsForDisplay([r]),await this._fetchResources([r]);const i=this._writeMeshes(r);s.onMessage({type:"append",append:i,clear:!1,end:!0,attributeEpoch:this._attributeStore.epoch,objectIdMap:r.objectIdMap})}_removeTile(e){if(!this._tiles.has(e))return;const t=this._tiles.get(e);this.container.removeChild(t),t.destroy(),this._tiles.delete(e)}_getNullSymbol(e){const t=e.geometry;return l(t)?b:p(t)||u(t)?w:this.defaultPointSymbolEnabled?S:null}async _getTextResources(e,t){const s=new Array,r=new Array;for(let i=0;i<t.length;i++){const o=t[i],{resource:a,overrides:n}=o.textRasterizationParam;if(n?.length>0){const t=_.resolveSymbolOverrides({type:"CIMSymbolReference",primitiveOverrides:n,symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:!0,size:a.symbol.height,anchorPointUnits:"Relative",frame:{xmin:-5,ymin:-5,xmax:5,ymax:5},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{x:0,y:0},symbol:a.symbol,textString:a.textString}],scaleSymbolsProportionally:!0,respectFrame:!0}]}},e,this.view.spatialReference,null,m(e.projectedGeometry),null,null);t.then((e=>{const t=e.symbolLayers[0],{textString:s}=t.markerGraphics[0];r.push({type:"cim-rasterization-info",resource:{type:"text",textString:s||"",font:a.font}}),o.text=a.textString=s||""})),s.push(t)}else r.push({type:"cim-rasterization-info",resource:a})}s.length>0&&await Promise.all(s);const o=r.map((e=>this.view.stage.textureManager.rasterizeItem(e))),a=await Promise.all(o);i(a);const n=new Map;for(let i=0;i<t.length;i++){const e=t[i];n.set(e.textRasterizationParam.resource.symbol,{text:e.text,glyphMosaicItems:a[i]})}return n}_cleanupSharedResources(){if(!this._cleanupRequired)return;const e=performance.now();if(e-this._lastCleanup<5e3)return;this._cleanupRequired=!1,this._lastCleanup=e;const t=new Set;for(const r of this._graphicStore.items()){const e=r.symbolResource?.symbolInfo.hash;t.add(e)}const s=new Set(this._hashToSymbolInfo.keys());for(const r of s.values())t.has(r)||this._hashToSymbolInfo.delete(r)}};e([h()],O.prototype,"_effectiveRenderer",null),e([h({constructOnly:!0})],O.prototype,"layerId",void 0),e([h({constructOnly:!0})],O.prototype,"requestUpdateCallback",void 0),e([h()],O.prototype,"container",void 0),e([h({constructOnly:!0})],O.prototype,"graphics",void 0),e([h()],O.prototype,"renderer",void 0),e([h()],O.prototype,"_updateTracking",void 0),e([h()],O.prototype,"updating",null),e([h()],O.prototype,"view",void 0),e([h()],O.prototype,"updateRequested",void 0),e([h()],O.prototype,"defaultPointSymbolEnabled",void 0),O=e([d("esri.views.2d.layers.graphics.GraphicsView2D")],O);const A=O;export{A as default};
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{isSome as s}from"../../../../core/arrayUtils.js";import has from"../../../../core/has.js";import r from"../../../../core/Identifiable.js";import{assertIsSome as i}from"../../../../core/maybe.js";import{ignoreAbortErrors as o,throwIfAborted as a}from"../../../../core/promiseUtils.js";import{watch as n}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import{subclass as d}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as c}from"../../../../geometry/support/aaBoundingRect.js";import{isPolyline as l,isPolygon as p,isExtent as u,getJsonType as m}from"../../../../geometry/support/jsonUtils.js";import g from"../../../../layers/support/FieldsIndex.js";import{symbolToCIM as f,CIMSymbolHelper as y}from"../../../../symbols/cim/CIMSymbolHelper.js";import{OverrideHelper as _}from"../../../../symbols/cim/OverrideHelper.js";import{errorPointSymbol2D as b,errorPolylineSymbol2D as w,errorPolygonSymbol2D as S}from"../../../../symbols/support/defaults.js";import{filterFlag0 as I}from"../../engine/webgl/definitions.js";import{FeatureTile as v}from"../../engine/webgl/FeatureTile.js";import{MeshData as T}from"../../engine/webgl/mesh/MeshData.js";import{ResourceProxy as M}from"../../engine/webgl/mesh/factories/ResourceProxy.js";import{createGraphicSymbolMeshSchemas as R}from"../../engine/webgl/shaderGraph/techniques/createGraphicSymbolMeshSchemas.js";import{createStorageSchema as j}from"../features/schema/processor/StorageSchema.js";import{AttributeStore as x}from"../features/support/AttributeStore.js";import{ComputedAttributeStorage as U}from"../features/support/ComputedAttributeStorage.js";import{GraphicsMetadata as C}from"../features/support/FeatureMetadata.js";import{GraphicsReader as q}from"../features/support/GraphicsReader.js";import G from"./GraphicStore.js";import{FeatureCommandQueue as k}from"../support/FeatureCommandQueue.js";import{UpdateTracking2D as P}from"../support/UpdateTracking2D.js";class F{static getOrCreate(e,t,s){let r=t.get(e.id);return r||(r=new F(e,s),t.set(e.id,r)),r}static fromItems(e,t,s){const r=new F(e,s);for(const i of t)r.append(i);return r}constructor(e,t){this.tile=e,this.metadata=t,this.addedOrModified=[],this.removed=[],this.objectIdMap=null}get reader(){return this._reader||(this._reader=q.from(this.addedOrModified,this.tile,this.metadata)),this._reader}append(e){this.addedOrModified.push(e),e.hasAnimations&&(this.objectIdMap=this.objectIdMap||{},this.objectIdMap[e.displayId]=e.objectId)}}let O=class extends(r.IdentifiableMixin(t)){constructor(e){super(e),this._attached=!1,this._tiles=new Map,this._controller=new AbortController,this._hashToSymbolInfo=new Map,this._lastCleanup=performance.now(),this._cleanupRequired=!0,this.lastUpdateId=-1,this.renderer=null,this._updateTracking=new P({debugName:"GraphicsView2D"}),this.updateRequested=!1,this.defaultPointSymbolEnabled=!0,this._commandQueue=new k({process:e=>{if("update"===e.type)return this._update();throw new Error("InternalError: Unsupported command")}}),this.graphicUpdateHandler=this.graphicUpdateHandler.bind(this)}destroy(){this.container.destroy(),this.view=null,this.renderer=null,this._set("graphics",null),this._controller.abort(),this._graphicStore.clear(),this._graphicStore.destroy(),this._attributeStore=null,this._hashToSymbolInfo.clear(),this._updateTracking.destroy(),this._commandQueue.destroy()}_initAttributeStore(){this._storage=new U({spatialReference:this.view.spatialReference,fields:new g}),this._attributeStore=new x({isLocal:!0,update:e=>{has("esri-2d-update-debug")&&console.debug(`[Id: ${this.layerId}] GraphicsView2D.AttributeStoreView.updateStart`,{message:e}),this.container.attributeView.requestUpdate(e),this.container.requestRender(),has("esri-2d-update-debug")&&console.debug(`[Id: ${this.layerId}] GraphicsView2D.AttributeStoreView.updateEnd`,{message:e})}});const e=j(null,[]);this._attributeStore.update(e,this._storage,null),this.container.checkHighlight=()=>this._attributeStore.hasHighlight}initialize(){this._initAttributeStore(),this._metadata=C.createGraphics(this.view.spatialReference),this._resourceProxy=new M({fetch:e=>Promise.all(e.map((e=>this.view.stage.textureManager.rasterizeItem(e)))),fetchDictionary:e=>{throw new Error("InternalError: Graphics do not support Dictionary requests")}}),this.addHandles([n((()=>this._effectiveRenderer),(()=>this._pushUpdate())),this.view.graphicsTileStore.on("update",this._onTileUpdate.bind(this)),this.container.on("attach",(()=>{this.addHandles([this.graphics.on("change",(()=>this._pushUpdate()))]),this._graphicStore?.destroy(),this._graphicStore=new G(this.view.spatialReference,this._cimResourceManager,this.view.featuresTilingScheme,this.view.state.scale,this._attributeStore),this._attached=!0,this.requestUpdate(),this._pushUpdate()}))]),this._updateTracking.addUpdateTracking("CommandQueue",this._commandQueue.updateTracking);const e=this.view.graphicsTileStore.tiles;this._onTileUpdate({added:e,removed:[]})}get _effectiveRenderer(){return"function"==typeof this.renderer?this.renderer():this.renderer}get _cimResourceManager(){return this.view.stage.textureManager.resourceManager}get updating(){const e=!this._attached||this._updateTracking.updating;return has("esri-2d-log-updating")&&console.log(`Updating GraphicsView2D: ${e}\n -> attaching ${!this._attached}\n -> updateTracking ${this._updateTracking.updating}`),e}hitTest(e){if(!this.view||this.view.suspended)return[];const{resolution:t,rotation:r}=this.view.state,i=this._graphicStore.hitTest(e.x,e.y,2,t,r),o=new Set(i),a=this.graphics.items.reduce(((e,t)=>(o.has(t.uid)&&e.set(t.uid,t),e)),new Map);return i.map((e=>a.get(e))).filter(s)}requestUpdate(){this.updateRequested||(this.updateRequested=!0,this.requestUpdateCallback()),this.notifyChange("updating")}processUpdate(e){this.updateRequested&&(this.updateRequested=!1,this.update(e))}viewChange(){this.requestUpdate()}setHighlight(e){const t=[];for(const{objectId:s,highlightFlags:r}of e){const e=this._graphicStore.getItem(s)?.displayId;t.push({objectId:s,highlightFlags:r,displayId:e})}this._attributeStore.setHighlight(t,e),this._pushUpdate()}graphicUpdateHandler(e){this._pushUpdate()}update(e){this.updateRequested=!1,this._attached&&this._graphicStore.updateLevel(e.state.resolution)&&this.pushUpdate()}pushUpdate(){this._pushUpdate()}_pushUpdate(){o(this._commandQueue.push({type:"update"}))}async _update(){try{has("esri-2d-update-debug")&&console.debug(`[Id: ${this.layerId}] GraphicsView._update start`);const e=await this._graphicStore.update(this.graphics,(e=>this._getSymbolForGraphic(e)),(e=>this._ensureSymbolResource(e)));for(const s of e.updated)this.container.restartAnimation(s.objectId);if(!e.hasAnyUpdate())return void this._attributeStore.sendUpdates();e.removed.length&&(this._cleanupRequired=!0),has("esri-2d-update-debug")&&console.debug(`[Id: ${this.layerId}] GraphicsView updateMessage`,e);const t=this._createTileMessages(e);await this._densifyItemsForDisplay(t),await this._fetchResources(t),this._write(t);for(const s of e.added)this._setFilterState(s);for(const s of e.updated)this._setFilterState(s);has("esri-2d-update-debug")&&console.debug(`[Id: ${this.layerId}] GraphicsView sendUpdate`,e),this._attributeStore.sendUpdates(),has("esri-2d-update-debug")&&console.debug(`[Id: ${this.layerId}] GraphicsView sendUpdate.await`,e)}catch(e){}this._cleanupSharedResources()}_createTileMessages(e){const t=new Map;for(const s of e.added){const e=this.view.graphicsTileStore.getIntersectingTiles(s.symbolBounds);for(const r of e){F.getOrCreate(r,t,this._metadata).append(s)}}for(const s of e.updated){const e=this.view.graphicsTileStore.getIntersectingTiles(s.prevSymbolBounds),r=this.view.graphicsTileStore.getIntersectingTiles(s.symbolBounds);for(const i of e){F.getOrCreate(i,t,this._metadata).removed.push(s.displayId)}for(const i of r){F.getOrCreate(i,t,this._metadata).append(s)}}for(const s of e.removed){const e=this.view.graphicsTileStore.getIntersectingTiles(s.symbolBounds);for(const r of e){F.getOrCreate(r,t,this._metadata).removed.push(s.displayId)}}return Array.from(t.values())}async _densifyItemsForDisplay(e){const t=new Map;for(const s of e)for(const e of s.addedOrModified)t.has(e)||t.set(e,e.densifyCurvedGeometryForDisplay(this.view.spatialReference));await Promise.all(t.values())}async _fetchResources(e){const t={timeZone:null,timeExtent:null};for(const{tile:s,reader:r}of e){has("esri-2d-update-debug")&&console.debug(`Id[${this.layerId}] Tile[${s.id}] GraphicsView fetchResources`,e);const i=r.getCursor();for(;i.next();)for(const e of i.getMeshWriters())e.enqueueRequest(this._resourceProxy,i,s.createArcadeEvaluationOptions(t))}await this._resourceProxy.fetchEnqueuedResources()}_write(e){for(const t of e){has("esri-2d-update-debug")&&console.debug(`Id[${this.layerId}] Tile[${t.tile.id}] GraphicsView write`,t);const e=this._writeMeshes(t);let s=this._tiles.get(t.tile.key);s||(s=this._createFeatureTile(t.tile.key)),has("esri-2d-update-debug")&&console.debug(`Id[${this.layerId}] Tile[${t.tile.id}] GraphicsView onTileData`,t),this.container.onTileData(s,{type:"update",modify:e,remove:t.removed,end:!1,attributeEpoch:this._attributeStore.epoch,objectIdMap:t.objectIdMap}),this.container.requestRender()}}_writeMeshes(e){const t={timeZone:null,timeExtent:null},s=new T(e.tile.id),r=e.reader.getCursor();for(;r.next();){s.entityStart(r.getDisplayId(),r.getZOrder());for(const i of r.getMeshWriters())i.write(s,this._resourceProxy,r,e.tile.createArcadeEvaluationOptions(t),e.tile.level);s.entityEnd()}return{...s.serialize().message,tileId:e.tile.id}}_setFilterState(e){const t=e.displayId,s=this._attributeStore.getHighlightFlags(e.objectId);this._attributeStore.setData(t,0,0,s|(e.visible?I:0))}_getSymbolForGraphic(e){return null!=e.symbol?e.symbol:null!=this._effectiveRenderer?this._effectiveRenderer.getSymbol(e):this._getNullSymbol(e)}async _ensureSymbolResource(e){if(!e.symbol)return;const t=await this._getSymbolInfo(e.symbol);if(!t)return;const s=t.linearCIM.filter((e=>"text"===e.type));if(s.length>0){const r=await this._getTextResources(e,s);e.symbolResource={symbolInfo:t,textInfo:r}}else e.symbolResource={symbolInfo:t}}_getSymbolInfo(e){const t=e.hash();return this._hashToSymbolInfo.has(t)||this._hashToSymbolInfo.set(t,this._createSymbolInfo(t,e).catch((e=>null))),this._hashToSymbolInfo.get(t)}async _createSymbolInfo(e,t){const s=await this._convertToCIMSymbol(t),r=await this._createLinearCIM(s);return{hash:e,cimSymbol:s,linearCIM:r,meshWriters:await this._createMeshWriters(s,r)}}async _convertToCIMSymbol(e){const t=f(e);if("web-style"===t.type){return(await t.fetchCIMSymbol()).data}return t}async _createLinearCIM(e){return await Promise.all(y.fetchResources(e.symbol,this._cimResourceManager,[])),this.view.stage.cimAnalyzer.analyzeSymbolReference(e,!1)}async _createMeshWriters(e,t){a(this._controller.signal);const s=this.container.instanceStore,r=this.view.stage.meshWriterRegistry,i=await R(e,t,s);return Promise.all(i.map((e=>r.createMeshWriter(this._storage,this._resourceProxy,{tileInfo:this.view.featuresTilingScheme.tileInfo},e,null))))}_onTileUpdate(e){if(e.added&&e.added.length>0)for(const t of e.added)this._updateTracking.addPromise(this._addTile(t));if(e.removed&&e.removed.length>0)for(const t of e.removed)this._removeTile(t.key)}_createFeatureTile(e){const t=this.view.featuresTilingScheme.getTileBounds(c(),e),s=this.view.featuresTilingScheme.getTileResolution(e.level),r=new v(e,s,t[0],t[3]);return this._tiles.set(e,r),this.container.addChild(r),r}async _addTile(e){if(!this._attached)return;const t=this._graphicStore.queryItems(e);if(!t.length)return;const s=this._createFeatureTile(e.key),r=F.fromItems(e,t,this._metadata);await this._densifyItemsForDisplay([r]),await this._fetchResources([r]);const i=this._writeMeshes(r);s.onMessage({type:"append",append:i,clear:!1,end:!0,attributeEpoch:this._attributeStore.epoch,objectIdMap:r.objectIdMap})}_removeTile(e){if(!this._tiles.has(e))return;const t=this._tiles.get(e);this.container.removeChild(t),t.destroy(),this._tiles.delete(e)}_getNullSymbol(e){const t=e.geometry;return t?l(t)?w:p(t)||u(t)?S:this.defaultPointSymbolEnabled?b:null:this.defaultPointSymbolEnabled?b:null}async _getTextResources(e,t){const s=new Array,r=new Array;for(let i=0;i<t.length;i++){const o=t[i],{resource:a,overrides:n}=o.textRasterizationParam;if(n?.length>0){const t=_.resolveSymbolOverrides({type:"CIMSymbolReference",primitiveOverrides:n,symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:!0,size:a.symbol.height,anchorPointUnits:"Relative",frame:{xmin:-5,ymin:-5,xmax:5,ymax:5},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{x:0,y:0},symbol:a.symbol,textString:a.textString}],scaleSymbolsProportionally:!0,respectFrame:!0}]}},e,this.view.spatialReference,null,m(e.projectedGeometry),null,null);t.then((e=>{const t=e.symbolLayers[0],{textString:s}=t.markerGraphics[0];r.push({type:"cim-rasterization-info",resource:{type:"text",textString:s||"",font:a.font}}),o.text=a.textString=s||""})),s.push(t)}else r.push({type:"cim-rasterization-info",resource:a})}s.length>0&&await Promise.all(s);const o=r.map((e=>this.view.stage.textureManager.rasterizeItem(e))),a=await Promise.all(o);i(a);const n=new Map;for(let i=0;i<t.length;i++){const e=t[i];n.set(e.textRasterizationParam.resource.symbol,{text:e.text,glyphMosaicItems:a[i]})}return n}_cleanupSharedResources(){if(!this._cleanupRequired)return;const e=performance.now();if(e-this._lastCleanup<5e3)return;this._cleanupRequired=!1,this._lastCleanup=e;const t=new Set;for(const r of this._graphicStore.items()){const e=r.symbolResource?.symbolInfo.hash;t.add(e)}const s=new Set(this._hashToSymbolInfo.keys());for(const r of s.values())t.has(r)||this._hashToSymbolInfo.delete(r)}};e([h()],O.prototype,"_effectiveRenderer",null),e([h({constructOnly:!0})],O.prototype,"layerId",void 0),e([h({constructOnly:!0})],O.prototype,"requestUpdateCallback",void 0),e([h()],O.prototype,"container",void 0),e([h({constructOnly:!0})],O.prototype,"graphics",void 0),e([h()],O.prototype,"renderer",void 0),e([h()],O.prototype,"_updateTracking",void 0),e([h()],O.prototype,"updating",null),e([h()],O.prototype,"view",void 0),e([h()],O.prototype,"updateRequested",void 0),e([h()],O.prototype,"defaultPointSymbolEnabled",void 0),O=e([d("esri.views.2d.layers.graphics.GraphicsView2D")],O);const A=O;export{A as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{deg2rad as r}from"../../../../core/mathUtils.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{a as n,n as p,e as a,v as c,g as l,h}from"../../../../chunks/vec32.js";import{create as d,fromValues as u,fromArray as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import v from"../../../../geometry/Point.js";import{rotateBy as g}from"./viewshedToolUtils.js";var S;let m=S=class extends t{constructor(e){super(e),this.observerRenderSpaceOverride=null}get observer(){return this.viewshed.observer??new v}get effectiveObserverRenderSpace(){return this.observerRenderSpaceOverride??this.observerRenderSpace}get effectiveObserver(){return this.renderSpaceToPoint(this.effectiveObserverRenderSpace,this.observer.spatialReference)}get effectiveTargetRenderSpace(){return this._computeTargetRenderSpace(this.effectiveObserverRenderSpace)}get farDistance(){return this.viewshed.farDistance}get farDistanceRenderSpace(){return this.farDistance/this.metersPerUnit}get heading(){return this.viewshed.heading}get tilt(){return this.viewshed.tilt}get feature(){return this.viewshed.feature}get tiltParallelToSurface(){return this.tilt-90}get horizontalFieldOfView(){return this.viewshed.horizontalFieldOfView}get verticalFieldOfView(){return this.viewshed.verticalFieldOfView}get observerRenderSpace(){return this._pointToRenderSpace(this.observer,d())}get target(){const e=this.targetRenderSpace;return this.renderSpaceToPoint(e,this.observer.spatialReference)}get targetRenderSpace(){return this._computeTargetRenderSpace(this.observerRenderSpace)}get targetDirection(){const e=n(d(),this.targetRenderSpace,this.observerRenderSpace);return p(e,e)}get tiltedUpVector(){const e=g(d(),this.upVector,-r(this.tiltParallelToSurface),this.leftVector);return p(e,e)}get _basis(){return this.renderCoordsHelper.basisMatrixAtPosition(this.observerRenderSpace,s())}get upVector(){const e=this._basis;return u(e[8],e[9],e[10])}get northVector(){const e=this._basis;return u(e[4],e[5],e[6])}get leftVector(){const e=this.upVector,t=g(d(),this.northVector,-r(this.heading),e);return a(t,e,t)}get rightVector(){return c(d(),this.leftVector)}clone(){return new S({renderCoordsHelper:this.renderCoordsHelper,viewshed:this.viewshed.clone()})}isValid(){return this.viewshed.isValid()}get metersPerUnit(){return this.renderCoordsHelper.spatialReference.metersPerUnit}pointOnSphere(e,t,o){const{observerRenderSpace:i,targetRenderSpace:s}=this,p=n(R,s,i);return g(p,p,-r(t),this.leftVector),g(p,p,-r(e),this.tiltedUpVector),l(o,p,i)}cornerPoints(e){const t=this.horizontalFieldOfView/2,r=this.verticalFieldOfView/2;this.pointOnSphere(-t,r,e.topLeft),this.pointOnSphere(t,r,e.topRight),this.pointOnSphere(-t,-r,e.bottomLeft),this.pointOnSphere(t,-r,e.bottomRight)}arcCentersPoints(e){const t=this.horizontalFieldOfView/2,r=this.verticalFieldOfView/2;this.pointOnSphere(0,r,e.top),this.pointOnSphere(0,-r,e.bottom),this.pointOnSphere(-t,0,e.left),this.pointOnSphere(t,0,e.right)}parallelCenterPoints(e){const t=this.observerRenderSpace,o=this.farDistanceRenderSpace*Math.sin(r(this.verticalFieldOfView/2)),i=h(R,this.tiltedUpVector,o);l(e.top,t,i),n(e.bottom,t,i)}renderSpaceToPoint(e,t){const r=R;return this.renderCoordsHelper.fromRenderCoords(e,r,t),new v(r[0],r[1],r[2],t)}_pointToRenderSpace(e,t){const r=f(e.toArray());return this.renderCoordsHelper.toRenderCoords(r,e.spatialReference,t),t}_computeTargetRenderSpace(e){const{leftVector:t,northVector:o,upVector:i}=this,s=this.farDistanceRenderSpace,n=d();return h(n,o,s),g(n,n,-r(this.heading),i),g(n,n,-r(this.tiltParallelToSurface),t),l(n,e,n),n}};e([o()],m.prototype,"renderCoordsHelper",void 0),e([o()],m.prototype,"viewshed",void 0),e([o()],m.prototype,"observerRenderSpaceOverride",void 0),e([o()],m.prototype,"observer",null),e([o()],m.prototype,"effectiveObserverRenderSpace",null),e([o()],m.prototype,"effectiveObserver",null),e([o()],m.prototype,"effectiveTargetRenderSpace",null),e([o()],m.prototype,"farDistance",null),e([o()],m.prototype,"farDistanceRenderSpace",null),e([o()],m.prototype,"heading",null),e([o()],m.prototype,"tilt",null),e([o()],m.prototype,"feature",null),e([o()],m.prototype,"tiltParallelToSurface",null),e([o()],m.prototype,"horizontalFieldOfView",null),e([o()],m.prototype,"verticalFieldOfView",null),e([o()],m.prototype,"observerRenderSpace",null),e([o()],m.prototype,"target",null),e([o()],m.prototype,"targetRenderSpace",null),e([o()],m.prototype,"targetDirection",null),e([o()],m.prototype,"tiltedUpVector",null),e([o()],m.prototype,"_basis",null),e([o()],m.prototype,"upVector",null),e([o()],m.prototype,"northVector",null),e([o()],m.prototype,"leftVector",null),e([o()],m.prototype,"rightVector",null),e([o()],m.prototype,"isValid",null),e([o()],m.prototype,"metersPerUnit",null),m=S=e([i("esri.views.3d.analysis.Viewshed.ViewshedComputedData")],m);const R=d();export{m as ViewshedComputedData};
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{deg2rad as r}from"../../../../core/mathUtils.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{a as n,n as p,e as a,v as c,g as l,h}from"../../../../chunks/vec32.js";import{create as d,fromValues as u,fromArray as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import v from"../../../../geometry/Point.js";import{rotateBy as g}from"./viewshedToolUtils.js";var S;let m=S=class extends t{constructor(e){super(e),this.observerRenderSpaceOverride=null,this.needUpdateByFeature=!1}get observer(){return this.viewshed.observer??new v}get effectiveObserverRenderSpace(){return this.observerRenderSpaceOverride??this.observerRenderSpace}get effectiveObserver(){return this.renderSpaceToPoint(this.effectiveObserverRenderSpace,this.observer.spatialReference)}get effectiveTargetRenderSpace(){return this._computeTargetRenderSpace(this.effectiveObserverRenderSpace)}get farDistance(){return this.viewshed.farDistance}get farDistanceRenderSpace(){return this.farDistance/this.metersPerUnit}get heading(){return this.viewshed.heading}get tilt(){return this.viewshed.tilt}get feature(){return this.viewshed.feature}get tiltParallelToSurface(){return this.tilt-90}get horizontalFieldOfView(){return this.viewshed.horizontalFieldOfView}get verticalFieldOfView(){return this.viewshed.verticalFieldOfView}get observerRenderSpace(){return this._pointToRenderSpace(this.observer,d())}get target(){const e=this.targetRenderSpace;return this.renderSpaceToPoint(e,this.observer.spatialReference)}get targetRenderSpace(){return this._computeTargetRenderSpace(this.observerRenderSpace)}get targetDirection(){const e=n(d(),this.targetRenderSpace,this.observerRenderSpace);return p(e,e)}get tiltedUpVector(){const e=g(d(),this.upVector,-r(this.tiltParallelToSurface),this.leftVector);return p(e,e)}get _basis(){return this.renderCoordsHelper.basisMatrixAtPosition(this.observerRenderSpace,s())}get upVector(){const e=this._basis;return u(e[8],e[9],e[10])}get northVector(){const e=this._basis;return u(e[4],e[5],e[6])}get leftVector(){const e=this.upVector,t=g(d(),this.northVector,-r(this.heading),e);return a(t,e,t)}get rightVector(){return c(d(),this.leftVector)}clone(){return new S({renderCoordsHelper:this.renderCoordsHelper,viewshed:this.viewshed.clone()})}isValid(){return this.viewshed.isValid()}get metersPerUnit(){return this.renderCoordsHelper.spatialReference.metersPerUnit}pointOnSphere(e,t,o){const{observerRenderSpace:i,targetRenderSpace:s}=this,p=n(R,s,i);return g(p,p,-r(t),this.leftVector),g(p,p,-r(e),this.tiltedUpVector),l(o,p,i)}cornerPoints(e){const t=this.horizontalFieldOfView/2,r=this.verticalFieldOfView/2;this.pointOnSphere(-t,r,e.topLeft),this.pointOnSphere(t,r,e.topRight),this.pointOnSphere(-t,-r,e.bottomLeft),this.pointOnSphere(t,-r,e.bottomRight)}arcCentersPoints(e){const t=this.horizontalFieldOfView/2,r=this.verticalFieldOfView/2;this.pointOnSphere(0,r,e.top),this.pointOnSphere(0,-r,e.bottom),this.pointOnSphere(-t,0,e.left),this.pointOnSphere(t,0,e.right)}parallelCenterPoints(e){const t=this.observerRenderSpace,o=this.farDistanceRenderSpace*Math.sin(r(this.verticalFieldOfView/2)),i=h(R,this.tiltedUpVector,o);l(e.top,t,i),n(e.bottom,t,i)}renderSpaceToPoint(e,t){const r=R;return this.renderCoordsHelper.fromRenderCoords(e,r,t),new v(r[0],r[1],r[2],t)}_pointToRenderSpace(e,t){const r=f(e.toArray());return this.renderCoordsHelper.toRenderCoords(r,e.spatialReference,t),t}_computeTargetRenderSpace(e){const{leftVector:t,northVector:o,upVector:i}=this,s=this.farDistanceRenderSpace,n=d();return h(n,o,s),g(n,n,-r(this.heading),i),g(n,n,-r(this.tiltParallelToSurface),t),l(n,e,n),n}};e([o()],m.prototype,"renderCoordsHelper",void 0),e([o()],m.prototype,"viewshed",void 0),e([o()],m.prototype,"observerRenderSpaceOverride",void 0),e([o()],m.prototype,"needUpdateByFeature",void 0),e([o()],m.prototype,"observer",null),e([o()],m.prototype,"effectiveObserverRenderSpace",null),e([o()],m.prototype,"effectiveObserver",null),e([o()],m.prototype,"effectiveTargetRenderSpace",null),e([o()],m.prototype,"farDistance",null),e([o()],m.prototype,"farDistanceRenderSpace",null),e([o()],m.prototype,"heading",null),e([o()],m.prototype,"tilt",null),e([o()],m.prototype,"feature",null),e([o()],m.prototype,"tiltParallelToSurface",null),e([o()],m.prototype,"horizontalFieldOfView",null),e([o()],m.prototype,"verticalFieldOfView",null),e([o()],m.prototype,"observerRenderSpace",null),e([o()],m.prototype,"target",null),e([o()],m.prototype,"targetRenderSpace",null),e([o()],m.prototype,"targetDirection",null),e([o()],m.prototype,"tiltedUpVector",null),e([o()],m.prototype,"_basis",null),e([o()],m.prototype,"upVector",null),e([o()],m.prototype,"northVector",null),e([o()],m.prototype,"leftVector",null),e([o()],m.prototype,"rightVector",null),e([o()],m.prototype,"isValid",null),e([o()],m.prototype,"metersPerUnit",null),m=S=e([i("esri.views.3d.analysis.Viewshed.ViewshedComputedData")],m);const R=d();export{m as ViewshedComputedData};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import{getFeatureId as s,updatePointsFromFeatureReference as t}from"../../../analysis/featureReferenceUtils.js";import i from"../../../core/Accessor.js";import"../../../core/has.js";import r from"../../../core/Logger.js";import{mapCollection as o}from"../../../core/mapCollectionUtils.js";import{abortMaybe as a,destroyMaybe as d}from"../../../core/maybe.js";import{watch as
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import{getFeatureId as s,updatePointsFromFeatureReference as t}from"../../../analysis/featureReferenceUtils.js";import i from"../../../core/Accessor.js";import"../../../core/has.js";import r from"../../../core/Logger.js";import{mapCollection as o}from"../../../core/mapCollectionUtils.js";import{abortMaybe as a,destroyMaybe as d}from"../../../core/maybe.js";import{watch as n,when as l,syncAndInitial as h,initial as c}from"../../../core/reactiveUtils.js";import{property as p}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as m}from"../../../core/accessorSupport/decorators/subclass.js";import{c as u,p as w}from"../../../chunks/vec32.js";import{create as v}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectOrLoad as f,canProjectWithoutEngine as V,isLoaded as y}from"../../../geometry/projection.js";import{projectBoundingRect as _}from"../../../geometry/projection/projectBoundingRect.js";import{empty as j,containsPoint as g}from"../../../geometry/support/aaBoundingRect.js";import{AnalysisView3D as R}from"./AnalysisView3D.js";import{logFailedGeometryProjectionError as b}from"./support/projectionUtils.js";import{ViewshedAnalysisVisualization as C}from"./Viewshed/ViewshedAnalysisVisualization.js";import{ViewshedComputedData as D}from"./Viewshed/ViewshedComputedData.js";import F from"./Viewshed/ViewshedTool.js";import{newIntersector as H}from"../webgl-engine/lib/Intersector.js";import{StoreResults as T}from"../webgl-engine/lib/IntersectorInterfaces.js";import{Viewshed as O}from"../webgl-engine/lib/Viewshed.js";import{connectAnalysisViewToTool as k,removeAnalysisViewTool as S,activateAnalysisViewTool as U}from"../../analysis/analysisViewUtils.js";let A=class extends(R(i)){constructor(e){super(e),this.type="viewshed-view-3d",this.analysis=null,this.tool=null,this._selectedViewshed=null,this.viewshedComputedDataHandles=null,this._placementTask=null,this._viewshedRenderer=null,this._intersector=null}get selectedViewshed(){return this._selectedViewshed}set selectedViewshed(e){this._unselectOtherViewsheds(e),this._selectedViewshed=e}get selectedViewshedComputedData(){return this.tool?.selectedViewshedComputedData}initialize(){const e=this.view;this._viewshedRenderer=new O({view:e,selectedViewshed:()=>this.selectedViewshed??this.tool?.stagedViewshed}),this._intersector=H(this.view.state.viewingMode),this._intersector.options.hud=!1,this._intersector.options.store=T.MIN,this.viewshedComputedDataHandles=o((()=>this.analysis.viewsheds),(s=>{const t=new D({renderCoordsHelper:e.renderCoordsHelper,viewshed:s}),i=Symbol();return this.addHandles([n((()=>({valid:t.isValid(),canProject:V(t.observer?.spatialReference,this.view.spatialReference)||y()})),(({valid:e,canProject:s},i)=>{this.visible&&(e&&s?this._addViewshedsToRenderer(t):i?.valid&&i?.canProject&&this._removeViewshedsFromRenderer(t),s||b(this.analysis,t.observer.spatialReference,r.getLogger(this)))}),c),...this._createFeatureReferenceHandles(t)],i),{viewshedComputedData:t,remove:()=>{this.removeHandles(i),this._removeViewshedsFromRenderer(t),t.destroy()}}})),this._analysisVisualization=new C({view:e,analysisViewData:this,isDecoration:!this.parent}),this.addHandles([n((()=>this.visible),(e=>{const s=this.viewshedComputedDataHandles;if(null==s)return;e||(this.selectedViewshed=null);const t=s.map((e=>e.viewshedComputedData)).filter((e=>e.isValid())).toArray();e?this._addViewshedsToRenderer(t):this._removeViewshedsFromRenderer(t)})),n((()=>e.renderCoordsHelper),(e=>{this.viewshedComputedDataHandles?.forEach((({viewshedComputedData:s})=>s.renderCoordsHelper=e))})),k(this,F),l((()=>this.interactive),(()=>{this._unselectOtherViewsheds(this.selectedViewshed)}),h)])}destroy(){this._placementTask=a(this._placementTask),S(this),this._analysisVisualization=d(this._analysisVisualization);const e=this.viewshedComputedDataHandles;null!=e&&this._removeViewshedsFromRenderer(e.map((e=>e.viewshedComputedData)).toArray())}_createFeatureReferenceHandles(e){const{view:s}=this;return[n((()=>[s.state.camera,s.slicePlane,e.viewshed.observer,e.targetRenderSpace,e.verticalFieldOfView,e.horizontalFieldOfView,e.feature]),(()=>{this._updateObserverFromFeature(s,e)}),c),this._createElevationUpdateHandle(e),l((()=>e.needUpdateByFeature),(()=>{this._updateObserverFromFeature(s,e),e.needUpdateByFeature=!1}))]}_createElevationUpdateHandle(e){const s=(t,i)=>{const{view:r}=this,{observer:o}=e;if(null==o)return;const a=f(o,r.spatialReference);if(null!=a.pending)return void a.pending.finally((()=>s(t,i)));const d=a.geometry;null!=d&&(_(t,i,I,r.spatialReference),g(I,[d.x,d.y])&&(e.needUpdateByFeature=!0))};return this.view.elevationProvider.on("elevation-change",(({extent:e,spatialReference:t})=>s(e,t)))}async createViewsheds(e){return this._placementTask=a(this._placementTask),this._placementTask=U(this,e),null!=this.tool&&this.tool.createViewsheds(),await this._placementTask.promise}_addViewshedsToRenderer(e){this._viewshedRenderer.updateViewsheds({adds:e})}_removeViewshedsFromRenderer(e){this._viewshedRenderer.updateViewsheds({removes:e})}_updateObserverFromFeature(e,i){const r=i.observerRenderSpace,o=i.targetRenderSpace,a=u(v(),r),d={observer:r,observerSurfaceNormal:null,observerAdjusted:a,observerFeatureId:s(i.feature),target:o,targetSurfaceNormal:null,targetAdjusted:u(v(),o),targetFeatureId:null};t(e,this._intersector,d,(e=>Math.min(e,.05*i.farDistanceRenderSpace))),i.observerRenderSpaceOverride=w(a,r)?null:a}_unselectOtherViewsheds(e){if(null!=e)for(const s of this.view.tools.items)s!==this.tool&&s instanceof F&&(s.analysisViewData.selectedViewshed=null)}get test(){}};e([p({readOnly:!0})],A.prototype,"type",void 0),e([p({constructOnly:!0,nonNullable:!0})],A.prototype,"analysis",void 0),e([p()],A.prototype,"tool",void 0),e([p()],A.prototype,"_selectedViewshed",void 0),e([p()],A.prototype,"selectedViewshed",null),e([p()],A.prototype,"selectedViewshedComputedData",null),e([p()],A.prototype,"viewshedComputedDataHandles",void 0),e([p()],A.prototype,"_analysisVisualization",void 0),e([p()],A.prototype,"_placementTask",void 0),e([p()],A.prototype,"_viewshedRenderer",void 0),A=e([m("esri.views.3d.analysis.ViewshedAnalysisView3D")],A);const z=A,I=j();export{z as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import{lerp as t}from"../../../core/mathUtils.js";import{disposeMaybe as
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import{lerp as t}from"../../../core/mathUtils.js";import{disposeMaybe as s}from"../../../core/maybe.js";import{watch as r,syncAndInitial as i,sync as o}from"../../../core/reactiveUtils.js";import{secondsFromMilliseconds as a}from"../../../core/time.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{getReferenceEllipsoid as m}from"../../../geometry/ellipsoidUtils.js";import{InternalRenderCategory as p}from"../webgl.js";import{PrecipitationPassParameters as d,PrecipitationTechnique as h}from"./PrecipitationTechnique.js";import{PrecipitationTechniqueConfiguration as l,PrecipitationType as f}from"./PrecipitationTechniqueConfiguration.js";import{glLayout as u}from"../support/buffer/glUtil.js";import{newLayout as _}from"../support/buffer/InterleavedLayout.js";import{TransparentEnvironment as b}from"../webgl-engine/effects/TransparentEnvironment.js";import{RenderRequestType as y}from"../webgl-engine/lib/basicInterfaces.js";import{VertexArrayObject as g}from"../webgl-engine/lib/VertexArrayObject.js";import{VertexAttribute as j}from"../webgl-engine/lib/VertexAttribute.js";import{BufferObject as w}from"../../webgl/BufferObject.js";import{PrimitiveType as P,Usage as A}from"../../webgl/enums.js";import{bindVertexBufferLayout as I,unbindVertexBufferLayout as v}from"../../webgl/Util.js";let T=class extends b{constructor(e){super(e),this._rainSpeed=.1,this._snowSpeed=.01,this._numParticles=0,this._passParameters=new d,this._configuration=new l;const{view:t,type:s}=e;this._configuration.type="rainy"===s?f.Rain:f.Snow,t._stage.renderView.techniques.precompile(h,this._configuration),this._passParameters.time=0,this._passParameters.radius=m(t.spatialReference).radius,this.addHandles([r((()=>t.environment.weather),(e=>{e.type===s&&this.addHandles(r((()=>e.precipitation),(e=>this._adjustParticles(e)),i))}),i)]),this.addHandles(r((()=>t._stage?.renderer.renderContext.bind.clouds.fadeFactor??1),(e=>{this._passParameters.opacity=e,1===e&&(this.removeHandles("opacity"),this.addHandles(r((()=>t._stage?.renderer.renderContext.bind.clouds.opacity??1),(e=>this._passParameters.opacity=e),i),"opacity"))}),o),"opacity")}initialize(){this.addHandles([r((()=>this.view.environment.atmosphereEnabled),(e=>e?this._enable():this._disable()),i)])}_adjustParticles(e){const s=.35,r=e<.5?t(0,s,2*e):t(s,1,2*(e-.5));this._numParticles=R*r}destroy(){this._numParticles=0,this._vao=s(this._vao),this._instanceIdBuffer=s(this._instanceIdBuffer)}fadeOut(e){this.removeAllHandles(),this.addHandles(r((()=>this.renderContext?.bind.clouds.fadeFactor??1),(t=>{this._passParameters.opacity=1-t,1===t&&(this.removeAllHandles(),e())})),"opacity")}updateAnimation(e){const t=("rainy"===this.type?this._rainSpeed:this._snowSpeed)*a(e.time)%1e5;return this._passParameters.time!==t&&(this._passParameters.time=t,!0)}render(e){const t=this.renderingContext;this._instanceIdBuffer??=this._createInstanceIndices(t);const s=Math.round(this._numParticles*this._passParameters.opacity),r=e.find((({name:e})=>e===p.TRANSPARENT_ENVIRONMENT));if(s<1)return r;const i=this.techniques.get(h,this._configuration);if(!i.compiled)return this.requestRender(y.UPDATE),r;const o=t.bindTechnique(i,this.bindParameters,this._passParameters);return this._vao??=S(t,i.locations),t.bindVAO(this._vao),o.assertCompatibleVertexAttributeLocations(this._vao),I(t,i.locations,this._instanceIdBuffer,E,0),t.drawArraysInstanced(P.TRIANGLES,0,3,s),v(t,i.locations,this._instanceIdBuffer,E),r}_createInstanceIndices(e){const t=[];for(let s=0;s<R;s++)t.push(s);return w.createVertex(e,A.STATIC_DRAW,new Float32Array(t))}};function S(e,t){const s=new Float32Array([-1,0,1,1,0,-1,1,0,1]);return new g(e,t,new Map([["geometry",u(x)]]),new Map([["geometry",w.createVertex(e,A.STATIC_DRAW,s)]]))}e([n({constructOnly:!0})],T.prototype,"type",void 0),T=e([c("esri.views.3d.environment.Precipitation")],T);const R=25e4,x=_().vec3f(j.POSITION),E=u(_().f32(j.INSTANCEFEATUREATTRIBUTE),1);export{T as Precipitation};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../../../Color.js";import"../../../../core/has.js";import e from"../../../../core/Error.js";import{clone as r}from"../../../../core/lang.js";import{getMetersPerVerticalUnitForSR as o}from"../../../../core/unitUtils.js";import{e as s}from"../../../../chunks/earcut.js";import{normalFromMat4 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 a,invertOrIdentity as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{F as m,c as p,n as h,i as g,d,e as u,t as f,a as y}from"../../../../chunks/vec32.js";import{fromArray as b,clone as _,ZEROS as x,create as j}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as S}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{computeTranslationToOriginAndRotation as P}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{create as O,fromBuffer as E,intersectsClippingArea as C}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as w}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as v,getZeroIndexArray as M}from"../../../../geometry/support/Indices.js";import{t as I}from"../../../../chunks/vec3.js";import{makeVertexCandidate as A,makeEdgeCandidate as L}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as B}from"../../../../renderers/support/renderingInfoUtils.js";import{ViewingMode as R}from"../../../ViewingMode.js";import{needsElevationUpdates3D as z,SampleElevationInfo as D}from"./elevationAlignmentUtils.js";import{Object3DEdgeState as T,Graphics3DObject3DGraphicLayer as U}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as G}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as F,computeCentroid as N}from"./graphicUtils.js";import{ApplyRendererDiffResult as V}from"./interfaces.js";import{geometryAsPolygon as k}from"./polygonUtils.js";import{createMaterial as H}from"../support/edgeUtils.js";import{debugFlags as W}from"../../support/debugFlags.js";import{SamplePosition as q}from"../../support/ElevationProvider.js";import{geometryToRenderInfo as Z}from"../../support/renderInfoUtils/polygon.js";import{NormalType as J}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{Attribute as K}from"../../webgl-engine/lib/Attribute.js";import{CullFaceOptions as Q}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as X}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as Y}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as $}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{compressNormals as tt,compressNormal as et}from"../../webgl-engine/lib/Normals.js";import{Object3D as rt}from"../../webgl-engine/lib/Object3D.js";import{VertexAttribute as ot}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as st}from"../../webgl-engine/materials/DefaultMaterial.js";const it=["polygon","extent"];class nt extends G{constructor(t,e,r,o){super(t,e,r,o,St(e)),this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const t=F(this._getSymbolSize());if(t)throw new e("graphics3dextrudesymbollayer:invalid-size",t)}const t=this.symbolLayer?.material?.color,r=this._getCombinedOpacityAndColor(t),o=b(r),s=r[3],i=s<1||this.needsDrivenTransparentPass,n=this.symbolLayer?.material?.emissiveFactor,a=n?m(_(n)):x,l={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,diffuse:o,ambient:o,opacity:s,transparent:i,cullFace:i?Q.None:Q.Back,hasVertexColors:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,emissiveFactor:a,offsetTransparentBackfaces:!0,normalType:J.Compressed};this._materials[Bt.Main]=new st(l,this._context),this._materials[Bt.Bottom]=new st({...l,cullFace:Q.Back},this._context),this._context.stage.addMany(this._materials)}destroy(){super.destroy(),this._context.stage.removeMany(this._materials),this._materials.length=0}createGraphics3DGraphic(t){const e=t.graphic;if(!this._validateGeometry(e.geometry,it,this.symbolLayer.type))return null;const r=this._getVertexOpacityAndColor(t.renderingInfo,this._getFallbackOpacityAndColor(),255),o=this.setGraphicElevationContext(e);return this._createAs3DShape(e,t.renderingInfo,r,o,e.uid)}layerOpacityChanged(t,e){const r=this.symbolLayer?.material?.color,o=this._getCombinedOpacity(r),s=o<1||this.needsDrivenTransparentPass;this._materials[Bt.Main]?.setParameters({opacity:o,transparent:s}),this._materials[Bt.Bottom]?.setParameters({opacity:o,transparent:s});const i=this._getLayerOpacity();t.forEach((t=>e(t)?.layerOpacityChanged(i,this._context.isAsync)))}layerElevationInfoChanged(t,e){return this.updateGraphics3DGraphicElevationInfo(t,e,z)}slicePlaneEnabledChanged(t,e){return this._materials[Bt.Main]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[Bt.Bottom]?.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[Bt.Main]?.setParameters(t),this._materials[Bt.Bottom]?.setParameters(t),!0}_getExtrusionSize(t){let e;return e=t.size&&this._drivenProperties.size?B(t.size,2)??0:this._getSymbolSize(),e/=this._context.renderCoordsHelper.unitInMeters,e}applyRendererDiff(t,e){return this._drivenPropertiesChanged(e)?V.RecreateSymbol:V.RecreateGraphics}async queryForSnapping(t,e,s,i){const n=this._getExtrusionSize(s)*this._context.renderCoordsHelper.unitInMeters/o(e),{objectId:a,target:l}=t,c=r(l);switch(c.z=(c.z??0)+n,t.type){case"edge":{const{start:e,end:o}=t,s=r(e),i=r(o);return s.z=(s.z??0)+n,i.z=(i.z??0)+n,[L(a,c,1/0,s,i)]}case"vertex":return[A(a,c,1/0),L(a,l,1/0,l,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(t,e,r,o,l){const m=k(t.geometry);if(null==m)return null;if(0===m.rings.length||!m.rings.some((t=>t.length>0)))return this._logGeometryValidationWarnings(m.rings,"rings","ExtrudeSymbol3DLayer"),null;const p=Z(m,this._context.elevationProvider,this._context.renderCoordsHelper,o);this._logGeometryCreationWarnings(p,m.rings,"rings","ExtrudeSymbol3DLayer");const h=N(m);if(null==h)return null;const g=new Array,d=new Array,u=O(),f=c(),y=j(),b=this._context.renderCoordsHelper.viewingMode===R.Global;b||this._context.renderCoordsHelper.worldUpAtPosition(null,y),P(m.spatialReference,[h.x,h.y,0],f,this._context.renderCoordsHelper.spatialReference);const _=c();a(_,f);const x=n();i(x,_);const{polygons:S,mapPositions:M,position:A}=p,L=new Map,B=this._materials[Bt.Main];for(const i of S){const t=i.count;if(this._context.clippingExtent&&(E(i.mapPositions,u),!C(u,this._context.clippingExtent)))continue;const o=s(i.mapPositions,i.holeIndices,3);if(0===o.length)continue;const n=o.length,a=6*t,c=v(a+n),m=v(n),p=w(3*a),h=w(3*a),x=w(3*a),j=w(a);lt(A,M,o,i,p,x,h,j,c,m,this._getExtrusionSize(e),y,b),I(p,p,_);const S=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:l,layerUid:this._context.layer.uid}),P=new Rt(p,x,tt(h),j),O=at(B,c,c.length-m.length,P,r,S),R=t,z=t,D=2*i.count,T=new zt(R,z,D,n/3);jt(O,T,f),L.set(O,T),g.push(O,at(this._materials[Bt.Bottom],m,0,P,r,S)),d.push(P.heights)}if(0===g.length)return null;const D=new rt({geometries:g,layerUid:this._context.layer.uid,graphicUid:l,isElevationSource:!0});D.transformation=f;const G=H(this.symbolLayer,{opacity:this._getLayerOpacity()}),F=G?new T(this._materials[Bt.Main],G,this._context.slicePlaneEnabled):null,V=new U(this,D,g,null,null,((t,e,r,o,s)=>xt(t,e,r,o,s,d,L)),o,F);return V.alignedSampledElevation=p.sampledElevation,V.needsElevationUpdates=z(o.mode),V}_getFallbackOpacityAndColor(){const e=this.symbolLayer?.material?.color;return t.toUnitRGBA(e)??S}}function at(t,e,r,o,s,i){const n=M(e.length),a=[[ot.POSITION,new K(o.positions,e,3,!0)],[ot.NORMALCOMPRESSED,new K(o.normals,e,2,!0)],[ot.COLOR,new K(s,n,4,!0)]];return new Y(t,a,o.elevation,X.Mesh,i,r)}function lt(t,e,r,o,s,i,n,a,l,c,m,p,h){{const g=r.length/3,d=2*o.count;ct(t,e,o.index,o.count,r,0,g,s,i,n,a,l,c,d,m,p,h)}{let t=0,e=2*o.count,r=0;const c=o.pathLengths[0];ht(s,i,a,n,t,c,o.count,e,l,r,m),e+=4*c,r+=2*c,t+=c;for(let p=1;p<o.pathLengths.length;++p){const c=o.pathLengths[p];ht(s,i,a,n,t,c,o.count,e,l,r,m),e+=4*c,r+=2*c,t+=c}}}function ct(t,e,r,o,s,i,n,a,l,c,m,g,d,u,f,y,b){p(Ot,y);{const s=f>0?1:-1;let i=3*r,n=0,p=3*n,g=o,d=3*g;for(let r=0;r<o;++r){const r=t[i],o=t[i+1],u=t[i+2];b&&(Ot[0]=r,Ot[1]=o,Ot[2]=u,h(Ot,Ot)),a[p+0]=r,a[p+1]=o,a[p+2]=u;const y=e[i+0],_=e[i+1],x=e[i+2];l[p+0]=y,l[p+1]=_,l[p+2]=x,c[p+0]=-s*Ot[0],c[p+1]=-s*Ot[1],c[p+2]=-s*Ot[2],m[n]=0,a[d+0]=r+f*Ot[0],a[d+1]=o+f*Ot[1],a[d+2]=u+f*Ot[2],l[d+0]=y,l[d+1]=_,l[d+2]=x,m[g]=f,p+=3,d+=3,i+=3,n+=1,g+=1}}{let t=3*i,e=0,r=3*u;const a=f<0?wt:Ct,l=f<0?Ct:wt;for(let i=0;i<n;++i)d[e]=s[t+a[0]],d[e+1]=s[t+a[1]],d[e+2]=s[t+a[2]],g[r]=s[t+l[0]]+o,g[r+1]=s[t+l[1]]+o,g[r+2]=s[t+l[2]]+o,e+=3,r+=3,t+=3}}function mt(t,e,r,o,s,i,n){o[i]=o[n],n*=3,t[i*=3]=t[n],t[i+1]=t[n+1],t[i+2]=t[n+2],e[i]=e[n],e[i+1]=e[n+1],e[i+2]=e[n+2],r[i]=s[0],r[i+1]=s[1],r[i+2]=s[2]}const pt=j();function ht(t,e,r,o,s,i,n,a,l,c,m){let p=s,h=s+1,g=s+n,d=s+n+1,u=a,f=a+1,y=a+2*i,b=a+2*i+1;m<0&&(p=s+n+1,d=s);let _=3*c;for(let x=0;x<i;++x)x===i-1&&(h=s,m>0?d=s+n:p=s+n),bt(t,p,h,g,pt),mt(t,e,o,r,pt,u,p),mt(t,e,o,r,pt,f,h),mt(t,e,o,r,pt,y,g),mt(t,e,o,r,pt,b,d),l[_]=u,l[_+1]=y,l[_+2]=b,l[_+3]=u,l[_+4]=b,l[_+5]=f,_+=6,p++,h++,g++,d++,u+=2,f+=2,y+=2,b+=2}const gt=j(),dt=j(),ut=j(),ft=j(),yt=j();function bt(t,e,r,o,s){e*=3,r*=3,o*=3,g(gt,t[e++],t[e++],t[e++]),g(dt,t[r++],t[r++],t[r++]),g(ut,t[o++],t[o++],t[o++]),d(ft,dt,gt),d(yt,ut,gt),u(s,yt,ft),h(s,s)}const _t=j();function xt(t,e,r,o,s,i,n){const a=t.stageObject,m=a.geometries,p=m.length,h="absolute-height"!==e.mode;let d=0;const u=a.transformation,y=l(c(),u);for(let l=0;l<p;l+=2){const t=m[l];if(!$(t))continue;const e=t.getMutableAttribute(ot.POSITION).data,c=i[l/2],p=new q(t.mapPositions),b=e.length/3;let _=!1,x=0;{let t=0;for(let i=0;i<b;i++){_t[0]=e[t],_t[1]=e[t+1],_t[2]=e[t+2],o(p,Et),h&&(x+=Et.sampledElevation),W.TESTS_DISABLE_OPTIMIZATIONS?(g(Pt,p.array[p.offset],p.array[p.offset+1],Et.z+c[t/3]),null!=r&&s.toRenderCoords(Pt,r,Pt),f(Pt,Pt,y)):(g(Pt,e[t],e[t+1],e[t+2]),f(Pt,Pt,u),s.setAltitude(Pt,Et.z+c[t/3]),f(Pt,Pt,y)),e[t]=Pt[0],e[t+1]=Pt[1],e[t+2]=Pt[2];const i=vt/s.unitInMeters;(Math.abs(_t[0]-e[t])>=i||Math.abs(_t[1]-e[t+1])>=i||Math.abs(_t[2]-e[t+2])>=i)&&(_=!0),p.offset+=3,t+=3}}if(_){const e=n.get(t);e&&jt(t,e,u),a.geometryVertexAttributeUpdated(m[l],ot.NORMALCOMPRESSED),t.invalidateBoundingInfo(),a.geometryVertexAttributeUpdated(m[l],ot.POSITION),m[l+1].invalidateBoundingInfo(),a.geometryVertexAttributeUpdated(m[l+1],ot.POSITION)}d+=x/b}return d/p}function jt(t,e,r){const o=t.getMutableAttribute(ot.POSITION),s=t.getMutableAttribute(ot.NORMALCOMPRESSED).data,{topVertexStart:i,topVertexCount:n,topFaceStart:a,topFaceCount:l}=e,c=o.data,m=n,p=t.attributes.get(ot.POSITION).indices,d=a+l,b=i+n,_=w(3*m);for(let h=0;h<m;++h){const t=3*h;_[t+0]=0,_[t+1]=0,_[t+2]=0}const x=Mt,j=It,S=At,P=Lt,O=Ot;for(let E=a;E<d;++E){const t=3*E;for(let e=0;e<3;++e){const o=p[t+e];P[e]=o;const s=3*o;g(Pt,c[s+0],c[s+1],c[s+2]),f(x[e],Pt,r)}y(j,x[1],x[0]),y(S,x[2],x[0]),u(O,j,S),h(O,O);for(let e=0;e<3;++e){const t=3*(P[e]-i);_[t+0]+=O[0],_[t+1]+=O[1],_[t+2]+=O[2]}}for(let h=i;h<b;++h){const t=3*(h-i),e=_[t+0],r=_[t+1],o=_[t+2],n=Math.sqrt(e*e+r*r+o*o);et(s,h,e/n,r/n,o/n)}}function St(t){return 1===(t.material?.color?.a??1)}const Pt=j(),Ot=j(),Et=new D,Ct=[0,2,1],wt=[0,1,2],vt=.01,Mt=[j(),j(),j()],It=j(),At=j(),Lt=[0,0,0];var Bt;!function(t){t[t.Main=0]="Main",t[t.Bottom=1]="Bottom"}(Bt||(Bt={}));class Rt{constructor(t,e,r,o){this.positions=t,this.elevation=e,this.normals=r,this.heights=o}}class zt{constructor(t,e,r,o){this.topVertexStart=t,this.topVertexCount=e,this.topFaceStart=r,this.topFaceCount=o}}export{nt as Graphics3DExtrudeSymbolLayer,lt as extrudePolygon};
|
|
5
|
+
import t from"../../../../Color.js";import"../../../../core/has.js";import e from"../../../../core/Error.js";import{clone as r}from"../../../../core/lang.js";import{getMetersPerVerticalUnitForSR as o}from"../../../../core/unitUtils.js";import{e as s}from"../../../../chunks/earcut.js";import{normalFromMat4 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 a,invertOrIdentity as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{F as m,c as p,n as h,i as g,d,e as u,t as f,a as y}from"../../../../chunks/vec32.js";import{fromArray as b,clone as _,ZEROS as x,create as j}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as S}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{computeTranslationToOriginAndRotation as P}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{create as O,fromBuffer as E,intersectsClippingArea as C}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as w}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as v,getZeroIndexArray as M}from"../../../../geometry/support/Indices.js";import{t as I}from"../../../../chunks/vec3.js";import{makeVertexCandidate as A,makeEdgeCandidate as L}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as B}from"../../../../renderers/support/renderingInfoUtils.js";import{ViewingMode as R}from"../../../ViewingMode.js";import{needsElevationUpdates3D as z,SampleElevationInfo as D}from"./elevationAlignmentUtils.js";import{Object3DEdgeState as U,Graphics3DObject3DGraphicLayer as G}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as T}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as F,computeCentroid as N}from"./graphicUtils.js";import{ApplyRendererDiffResult as V}from"./interfaces.js";import{geometryAsPolygon as k}from"./polygonUtils.js";import{createMaterial as H}from"../support/edgeUtils.js";import{debugFlags as W}from"../../support/debugFlags.js";import{SamplePosition as q}from"../../support/ElevationProvider.js";import{geometryToRenderInfo as Z}from"../../support/renderInfoUtils/polygon.js";import{NormalType as J}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{Attribute as K}from"../../webgl-engine/lib/Attribute.js";import{CullFaceOptions as Q}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as X}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as Y}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as $}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{compressNormals as tt,compressNormal as et}from"../../webgl-engine/lib/Normals.js";import{Object3D as rt}from"../../webgl-engine/lib/Object3D.js";import{VertexAttribute as ot}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as st}from"../../webgl-engine/materials/DefaultMaterial.js";const it=["polygon","extent"];class nt extends T{constructor(t,e,r,o){super(t,e,r,o,St(e)),this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const t=F(this._getSymbolSize());if(t)throw new e("graphics3dextrudesymbollayer:invalid-size",t)}const t=this.symbolLayer?.material?.color,r=this._getCombinedOpacityAndColor(t),o=b(r),s=r[3],i=this.needsDrivenTransparentPass,n=this.symbolLayer?.material?.emissiveFactor,a=n?m(_(n)):x,l={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,diffuse:o,ambient:o,opacity:s,drivenOpacity:i,hasVertexColors:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,emissiveFactor:a,offsetTransparentBackfaces:!0,normalType:J.Compressed},c=new st(l,this._context);c.setParameters({cullFace:c.transparent?Q.None:Q.Back});const p=new st({...l,cullFace:Q.Back},this._context);this._materials[Bt.Main]=c,this._materials[Bt.Bottom]=p,this._context.stage.addMany(this._materials)}destroy(){super.destroy(),this._context.stage.removeMany(this._materials),this._materials.length=0}createGraphics3DGraphic(t){const e=t.graphic;if(!this._validateGeometry(e.geometry,it,this.symbolLayer.type))return null;const r=this._getVertexOpacityAndColor(t.renderingInfo,this._getFallbackOpacityAndColor(),255),o=this.setGraphicElevationContext(e);return this._createAs3DShape(e,t.renderingInfo,r,o,e.uid)}layerOpacityChanged(t,e){const r=this.symbolLayer?.material?.color,o=this._getCombinedOpacity(r);this._materials[Bt.Main]?.setParameters({opacity:o}),this._materials[Bt.Bottom]?.setParameters({opacity:o});const s=this._getLayerOpacity();t.forEach((t=>e(t)?.layerOpacityChanged(s,this._context.isAsync)))}layerElevationInfoChanged(t,e){return this.updateGraphics3DGraphicElevationInfo(t,e,z)}slicePlaneEnabledChanged(t,e){return this._materials[Bt.Main]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[Bt.Bottom]?.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[Bt.Main]?.setParameters(t),this._materials[Bt.Bottom]?.setParameters(t),!0}_getExtrusionSize(t){let e;return e=t.size&&this._drivenProperties.size?B(t.size,2)??0:this._getSymbolSize(),e/=this._context.renderCoordsHelper.unitInMeters,e}applyRendererDiff(t,e){return this._drivenPropertiesChanged(e)?V.RecreateSymbol:V.RecreateGraphics}async queryForSnapping(t,e,s,i){const n=this._getExtrusionSize(s)*this._context.renderCoordsHelper.unitInMeters/o(e),{objectId:a,target:l}=t,c=r(l);switch(c.z=(c.z??0)+n,t.type){case"edge":{const{start:e,end:o}=t,s=r(e),i=r(o);return s.z=(s.z??0)+n,i.z=(i.z??0)+n,[L(a,c,1/0,s,i)]}case"vertex":return[A(a,c,1/0),L(a,l,1/0,l,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(t,e,r,o,l){const m=k(t.geometry);if(null==m)return null;if(0===m.rings.length||!m.rings.some((t=>t.length>0)))return this._logGeometryValidationWarnings(m.rings,"rings","ExtrudeSymbol3DLayer"),null;const p=Z(m,this._context.elevationProvider,this._context.renderCoordsHelper,o);this._logGeometryCreationWarnings(p,m.rings,"rings","ExtrudeSymbol3DLayer");const h=N(m);if(null==h)return null;const g=new Array,d=new Array,u=O(),f=c(),y=j(),b=this._context.renderCoordsHelper.viewingMode===R.Global;b||this._context.renderCoordsHelper.worldUpAtPosition(null,y),P(m.spatialReference,[h.x,h.y,0],f,this._context.renderCoordsHelper.spatialReference);const _=c();a(_,f);const x=n();i(x,_);const{polygons:S,mapPositions:M,position:A}=p,L=new Map,B=this._materials[Bt.Main];for(const i of S){const t=i.count;if(this._context.clippingExtent&&(E(i.mapPositions,u),!C(u,this._context.clippingExtent)))continue;const o=s(i.mapPositions,i.holeIndices,3);if(0===o.length)continue;const n=o.length,a=6*t,c=v(a+n),m=v(n),p=w(3*a),h=w(3*a),x=w(3*a),j=w(a);lt(A,M,o,i,p,x,h,j,c,m,this._getExtrusionSize(e),y,b),I(p,p,_);const S=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:l,layerUid:this._context.layer.uid}),P=new Rt(p,x,tt(h),j),O=at(B,c,c.length-m.length,P,r,S),R=t,z=t,D=2*i.count,U=new zt(R,z,D,n/3);jt(O,U,f),L.set(O,U),g.push(O,at(this._materials[Bt.Bottom],m,0,P,r,S)),d.push(P.heights)}if(0===g.length)return null;const D=new rt({geometries:g,layerUid:this._context.layer.uid,graphicUid:l,isElevationSource:!0});D.transformation=f;const T=H(this.symbolLayer,{opacity:this._getLayerOpacity()}),F=T?new U(this._materials[Bt.Main],T,this._context.slicePlaneEnabled):null,V=new G(this,D,g,null,null,((t,e,r,o,s)=>xt(t,e,r,o,s,d,L)),o,F);return V.alignedSampledElevation=p.sampledElevation,V.needsElevationUpdates=z(o.mode),V}_getFallbackOpacityAndColor(){const e=this.symbolLayer?.material?.color;return t.toUnitRGBA(e)??S}}function at(t,e,r,o,s,i){const n=M(e.length),a=[[ot.POSITION,new K(o.positions,e,3,!0)],[ot.NORMALCOMPRESSED,new K(o.normals,e,2,!0)],[ot.COLOR,new K(s,n,4,!0)]];return new Y(t,a,o.elevation,X.Mesh,i,r)}function lt(t,e,r,o,s,i,n,a,l,c,m,p,h){{const g=r.length/3,d=2*o.count;ct(t,e,o.index,o.count,r,0,g,s,i,n,a,l,c,d,m,p,h)}{let t=0,e=2*o.count,r=0;const c=o.pathLengths[0];ht(s,i,a,n,t,c,o.count,e,l,r,m),e+=4*c,r+=2*c,t+=c;for(let p=1;p<o.pathLengths.length;++p){const c=o.pathLengths[p];ht(s,i,a,n,t,c,o.count,e,l,r,m),e+=4*c,r+=2*c,t+=c}}}function ct(t,e,r,o,s,i,n,a,l,c,m,g,d,u,f,y,b){p(Ot,y);{const s=f>0?1:-1;let i=3*r,n=0,p=3*n,g=o,d=3*g;for(let r=0;r<o;++r){const r=t[i],o=t[i+1],u=t[i+2];b&&(Ot[0]=r,Ot[1]=o,Ot[2]=u,h(Ot,Ot)),a[p+0]=r,a[p+1]=o,a[p+2]=u;const y=e[i+0],_=e[i+1],x=e[i+2];l[p+0]=y,l[p+1]=_,l[p+2]=x,c[p+0]=-s*Ot[0],c[p+1]=-s*Ot[1],c[p+2]=-s*Ot[2],m[n]=0,a[d+0]=r+f*Ot[0],a[d+1]=o+f*Ot[1],a[d+2]=u+f*Ot[2],l[d+0]=y,l[d+1]=_,l[d+2]=x,m[g]=f,p+=3,d+=3,i+=3,n+=1,g+=1}}{let t=3*i,e=0,r=3*u;const a=f<0?wt:Ct,l=f<0?Ct:wt;for(let i=0;i<n;++i)d[e]=s[t+a[0]],d[e+1]=s[t+a[1]],d[e+2]=s[t+a[2]],g[r]=s[t+l[0]]+o,g[r+1]=s[t+l[1]]+o,g[r+2]=s[t+l[2]]+o,e+=3,r+=3,t+=3}}function mt(t,e,r,o,s,i,n){o[i]=o[n],n*=3,t[i*=3]=t[n],t[i+1]=t[n+1],t[i+2]=t[n+2],e[i]=e[n],e[i+1]=e[n+1],e[i+2]=e[n+2],r[i]=s[0],r[i+1]=s[1],r[i+2]=s[2]}const pt=j();function ht(t,e,r,o,s,i,n,a,l,c,m){let p=s,h=s+1,g=s+n,d=s+n+1,u=a,f=a+1,y=a+2*i,b=a+2*i+1;m<0&&(p=s+n+1,d=s);let _=3*c;for(let x=0;x<i;++x)x===i-1&&(h=s,m>0?d=s+n:p=s+n),bt(t,p,h,g,pt),mt(t,e,o,r,pt,u,p),mt(t,e,o,r,pt,f,h),mt(t,e,o,r,pt,y,g),mt(t,e,o,r,pt,b,d),l[_]=u,l[_+1]=y,l[_+2]=b,l[_+3]=u,l[_+4]=b,l[_+5]=f,_+=6,p++,h++,g++,d++,u+=2,f+=2,y+=2,b+=2}const gt=j(),dt=j(),ut=j(),ft=j(),yt=j();function bt(t,e,r,o,s){e*=3,r*=3,o*=3,g(gt,t[e++],t[e++],t[e++]),g(dt,t[r++],t[r++],t[r++]),g(ut,t[o++],t[o++],t[o++]),d(ft,dt,gt),d(yt,ut,gt),u(s,yt,ft),h(s,s)}const _t=j();function xt(t,e,r,o,s,i,n){const a=t.stageObject,m=a.geometries,p=m.length,h="absolute-height"!==e.mode;let d=0;const u=a.transformation,y=l(c(),u);for(let l=0;l<p;l+=2){const t=m[l];if(!$(t))continue;const e=t.getMutableAttribute(ot.POSITION).data,c=i[l/2],p=new q(t.mapPositions),b=e.length/3;let _=!1,x=0;{let t=0;for(let i=0;i<b;i++){_t[0]=e[t],_t[1]=e[t+1],_t[2]=e[t+2],o(p,Et),h&&(x+=Et.sampledElevation),W.TESTS_DISABLE_OPTIMIZATIONS?(g(Pt,p.array[p.offset],p.array[p.offset+1],Et.z+c[t/3]),null!=r&&s.toRenderCoords(Pt,r,Pt),f(Pt,Pt,y)):(g(Pt,e[t],e[t+1],e[t+2]),f(Pt,Pt,u),s.setAltitude(Pt,Et.z+c[t/3]),f(Pt,Pt,y)),e[t]=Pt[0],e[t+1]=Pt[1],e[t+2]=Pt[2];const i=vt/s.unitInMeters;(Math.abs(_t[0]-e[t])>=i||Math.abs(_t[1]-e[t+1])>=i||Math.abs(_t[2]-e[t+2])>=i)&&(_=!0),p.offset+=3,t+=3}}if(_){const e=n.get(t);e&&jt(t,e,u),a.geometryVertexAttributeUpdated(m[l],ot.NORMALCOMPRESSED),t.invalidateBoundingInfo(),a.geometryVertexAttributeUpdated(m[l],ot.POSITION),m[l+1].invalidateBoundingInfo(),a.geometryVertexAttributeUpdated(m[l+1],ot.POSITION)}d+=x/b}return d/p}function jt(t,e,r){const o=t.getMutableAttribute(ot.POSITION),s=t.getMutableAttribute(ot.NORMALCOMPRESSED).data,{topVertexStart:i,topVertexCount:n,topFaceStart:a,topFaceCount:l}=e,c=o.data,m=n,p=t.attributes.get(ot.POSITION).indices,d=a+l,b=i+n,_=w(3*m);for(let h=0;h<m;++h){const t=3*h;_[t+0]=0,_[t+1]=0,_[t+2]=0}const x=Mt,j=It,S=At,P=Lt,O=Ot;for(let E=a;E<d;++E){const t=3*E;for(let e=0;e<3;++e){const o=p[t+e];P[e]=o;const s=3*o;g(Pt,c[s+0],c[s+1],c[s+2]),f(x[e],Pt,r)}y(j,x[1],x[0]),y(S,x[2],x[0]),u(O,j,S),h(O,O);for(let e=0;e<3;++e){const t=3*(P[e]-i);_[t+0]+=O[0],_[t+1]+=O[1],_[t+2]+=O[2]}}for(let h=i;h<b;++h){const t=3*(h-i),e=_[t+0],r=_[t+1],o=_[t+2],n=Math.sqrt(e*e+r*r+o*o);et(s,h,e/n,r/n,o/n)}}function St(t){return 1===(t.material?.color?.a??1)}const Pt=j(),Ot=j(),Et=new D,Ct=[0,2,1],wt=[0,1,2],vt=.01,Mt=[j(),j(),j()],It=j(),At=j(),Lt=[0,0,0];var Bt;!function(t){t[t.Main=0]="Main",t[t.Bottom=1]="Bottom"}(Bt||(Bt={}));class Rt{constructor(t,e,r,o){this.positions=t,this.elevation=e,this.normals=r,this.heights=o}}class zt{constructor(t,e,r,o){this.topVertexStart=t,this.topVertexCount=e,this.topFaceStart=r,this.topFaceCount=o}}export{nt as Graphics3DExtrudeSymbolLayer,lt 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/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{releaseMaybe as r}from"../../../../core/maybe.js";import{isPromiseLike as o}from"../../../../core/promiseUtils.js";import{normalFromMat4 as a,fromMat4 as n}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as i,multiply as l,invert as c,getTranslation as u}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m,IDENTITY as f,clone as p}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as h}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{i as d,g,h as x,t as _,q as T,n as b,b as y,f as v,d as w,e as R}from"../../../../chunks/vec32.js";import{ZEROS as M,ONES as j,create as P}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as C,ZEROS as A}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as E}from"../../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as O}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as N}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToPoint as I}from"../../../../geometry/projection/projectVectorToPoint.js";import{create as S,fromBuffer as U,intersectsClippingArea as F}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as B}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as D,getContinuousIndexArray as G}from"../../../../geometry/support/Indices.js";import V from"../../../../geometry/support/MeshComponent.js";import L from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import $ from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as H,isAbsoluteVertexSpace as k}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as q,isPlateCarree as z}from"../../../../geometry/support/spatialReferenceUtils.js";import{t as W}from"../../../../chunks/vec3.js";import{transformNormal as Y,transformVectorENUPlateCarree as Z,VectorType as J,transformVectorWMPlateCarree as K,projectNormalToPCPF as Q,transformTangent as X,projectTangentToPCPF as ee}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as te}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{makeDehydratedPoint as re}from"../../../../layers/graphics/dehydratedPoint.js";import{MeshTransformUpdateAction as oe}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as ae}from"../../../ViewingMode.js";import{isEncodedMeshTexture as ne}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as se}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as ie}from"./ElevationAligners.js";import{needsElevationUpdates3D as le,evaluateElevationInfoAtPoint as ce}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as ue}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as me}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as fe}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as pe,MeshFastUpdateProcessor as he}from"./MeshFastUpdateProcessor.js";import{createMaterial as de}from"../support/edgeUtils.js";import{parseColorMixMode as ge,encodeSymbolColor as xe}from"../support/symbolColorUtils.js";import{debugFlags as _e}from"../../support/debugFlags.js";import{Attribute as Te}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as be,CullFaceOptions as ye}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as ve}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as we}from"../../webgl-engine/lib/Geometry.js";import{Object3D as Re}from"../../webgl-engine/lib/Object3D.js";import{Texture as Me}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as je}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as Pe}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as Ce}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as Ae,advancedMRRFactors as Ee,schematicMRRFactors as Oe}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as Ne}from"../../../webgl/enums.js";const Ie=["mesh"];class Se extends fe{constructor(e,t,r,o){super(e,t,r,o,Qe(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]}))}destroy(){super.destroy(),this._textures.forEach((e=>e.unload())),this._context.stage.removeMany(this._materialInfoCache.materials),this._context.stage.removeMany(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy(this._context.stage)}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Ie,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache,this._context)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>t(e)?.layerOpacityChanged(r,this._context.isAsync)))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,le)}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 a=e.fastTransformUpdatesEnabled;switch(o){case oe.EnableFastUpdates:if(a)return!0;break;case oe.DisableFastUpdates:if(!a)return!0;break;default:if(!a)return!!this.updateTransform(e,t,r,oe.EnableFastUpdates)&&(e.autoDisableFastTransformUpdates((()=>this.updateTransform(e,t,r,oe.DisableFastUpdates))),!0)}const n=this._context.renderCoordsHelper.spatialReference,s=st,{origin:i,transform:l}=r;if(!O(t,d(tt,i.x,i.y,i.z??0),s,n))return!1;switch(o){case oe.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case oe.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case oe.UpdateFastLocalOrigin:e.updateFastLocalOrigin(s,l,this._context.localOriginFactory)}const{elevationContext:c}=e;c.centerPointInElevationSR=this._getCenterPointInElevationSR(s);const{elevationProvider:u,renderCoordsHelper:m}=this._context,f=(e,t)=>ce(e,u,c,m,t);return e.alignedSampledElevation=ie(e,c,u.spatialReference,f,m,s),e.updateTransform(s,l,this._context.isAsync),e.updateAutoDisableFastTransformUpdates((()=>this.updateTransform(e,t,r,oe.DisableFastUpdates))),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:n,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,f=Ze(a),p=Ze(n),h=Je(s),d=Ze(i),g=Je(l);if(o.color=a,o.colorTexture=n,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 L){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:n,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:f}=t.material,p=Ze(a),h=Je(n),d=Ze(i),g=Ze(c),x=Je(u),_=Ze(m),T=Je(f);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=He(s),o.normalTextureTransform=He(l),o.emissiveTextureTransform=He(u),o.occlusionTextureTransform=He(f),o.metallicRoughnessTextureTransform=He(n),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${p},mrtt:${h},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${T}`}return o}_getInternalTexture(e,t=be.Opaque){const a=Ye(e);if(!a)return null;const n=`${e.contentHash}/${t}`;let s=this._textures.get(n);if(s){const e=this._context.stage.renderView.textures;let t=null;const a=e.acquire(s.id);return null==a||o(a)||(s.events.on("unloaded",(()=>t=r(t))),t=a),s}let i=null;const l=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,c={wrap:ke(e.wrap),noUnpackFlip:!0,maxAnisotropy:l,mipmap:l>1};return ne(a)?(i=a.data,c.preMultiplyAlpha=!1,c.encoding=a.encoding):(i=a,c.preMultiplyAlpha=t!==be.Opaque),s=new Me(i,c),this._textures.set(n,s),s.load(this._context.stage.renderView.renderingContext),this._context.stage.add(s),s.events.on("unloaded",(()=>{this._textures.delete(n)})),s}_setInternalMaterialTextureParameters(t,r){if(null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}t.normalTexture&&(r.normalTextureId=this._getInternalTexture(t.normalTexture)?.id),t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTexture(t.emissiveTexture)?.id),t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTexture(t.occlusionTexture)?.id),t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTexture(t.metallicRoughnessTexture)?.id)}_setInternalMaterialParameters(e,t){null!=e.color&&We(e.color,t),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=se(e.colorTextureTransform),t.normalTextureTransformMatrix=se(e.normalTextureTransform);const r=null!=e.normalTextureTransform?.scale?e.normalTextureTransform?.scale:h;t.scale=[r[0],r[1]],t.occlusionTextureTransformMatrix=se(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=se(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=se(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t,r=this.symbolLayer?.material?.color){const o=this._drivenProperties.color;let a=this.symbolLayer.material?.colorMixMode??null;if(o)t.externalColor=C;else{const o=r??null;o?t.externalColor=e.toUnitRGBA(o):(a=null,t.externalColor=C)}a&&(t.colorMixMode=a),t.castShadows=!!this.symbolLayer.castShadows}_getOrCreateMaterial(t,r){const o=r.material?.color,a=r.material?.colorTexture,n=r.material?.alphaMode,s="blend"===n,i=!("opaque"===n)&&(ze(t)||null!=o&&o.a<1||a?.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=Ae({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:M,diffuse:j,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:ye.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled};f.mrrFactors=m?Oe:[l.metallic,l.roughness,Ee[2]],r.material&&(f.doubleSided=r.material.doubleSided,f.cullFace=r.material.doubleSided?ye.None:ye.Back,f.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(f),this._setMaterialTransparentParameter(f,u),this._setInternalMaterialParameters(l,f);const p=new Pe(f,this._context);return u.material=p,this._materialInfoCache.set(l.uid,u),this._context.stage.add(p),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._setMaterialTransparentParameter(t,e),e.material.setParameters({externalColor:t.externalColor,transparent:t.transparent})}))}))}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?be.MaskBlend:be.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?be.Opaque:"mask"===t.alphaMode?be.Mask:be.Blend}_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),i=[],l=[],c=t[0].transformation,u=a(s(),c);for(let a=0;a<r;a++){const e=t[a].attributes.get(je.POSITION);if(!e)continue;const r=e.data,o=e.indices;for(let t=0;t<o.length;t+=3)$e(r,o,t,at),Le(r,o,t,tt,rt,ot),g(tt,tt,rt),g(tt,tt,ot),x(tt,tt,1/3),_(tt,tt,c),i.push(...tt),T(at,at,u),b(at,at),y(tt,tt,at,n),i.push(...tt),l.push(l.length),l.push(l.length)}return i.length?new we(this._debugFaceNormalMaterial,[[je.POSITION,new Te(i,l,3,!0)]],null,ve.Line):null}_createPerVertexDebugVectors(e,t,r,o,i){const l=t.length,c=e.spatialReference.isGeographic?20015077/180:1,u=.1*i*Math.max(e.extent.width*c,e.extent.height*c,e.extent.zmax-e.extent.zmin),m=[],f=[],p=t[0].transformation,h=a(s(),p);r===je.TANGENT&&n(h,p);for(let a=0;a<l;a++){const e=t[a],o=e.attributes.get(je.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;d(tt,s[e+0],s[e+1],s[e+2]),_(tt,tt,p),m.push(...tt),d(rt,l[r+0],l[r+1],l[r+2]),T(rt,rt,h),b(rt,rt),y(tt,tt,rt,u),m.push(...tt),f.push(f.length),f.push(f.length)}}return m.length?new we(o,[[je.POSITION,new Te(m,f,3,!0)]],null,ve.Line):null}_createAs3DShape(e,t,r,o){const a=e.geometry;if("mesh"!==a.type)return null;const n=this._createGeometryInfo(a,t,o);if(null==n)return null;const{geometries:s,objectTransformation:i}=n;if(_e.DRAW_MESH_GEOMETRY_NORMALS){const e=this._createPerVertexDebugVectors(a,s,je.NORMAL,this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(a,s,je.TANGENT,this._debugTangentNormalMaterial,.5),r=this._createFaceDebugNormals(a,s);e&&s.push(e),t&&s.push(t),r&&s.push(r)}const l=new Re({geometries:s,layerUid:this._context.layer.uid,graphicUid:o,isElevationSource:!0});l.transformation=i;const c=de(this.symbolLayer,{opacity:this._getLayerOpacity()}),u=c?new me(s[0].material,c,this._context.slicePlaneEnabled):null,m=new ue(this,l,s,null,null,ie,r,u);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=le(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,m.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(a),r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:f,renderCoordsHelper:p}=this._context,h=(e,t)=>ce(e,f,r,p,t);return m.alignedSampledElevation=ie(m,r,f.spatialReference,h,p),m}_fastTransformUpdatesAllowed(e){const{vertexSpace:t,spatialReference:r}=e;if(!H(t))return!1;const{type:o}=t,{view:a}=this._context.graphicsCoreOwner,{viewingMode:n}=a.state,s=a.spatialReference;return n===ae.Global&&"local"===o||n===ae.Local&&q(s,r)&&"georeferenced"===o&&!r.isGeographic}_getCenterPointInElevationSR(e){const t=re(0,0,0,this._context.elevationProvider.spatialReference??null);return I([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_passthroughReprojectionInfo(e){return e.reprojection===ct.NONE&&!!e.objectTransformation}_createPositionBuffer(e,t){const r=e.vertexAttributes.position;let o,a=r;if(t.reprojection===ct.NONE)return{position:a,georeferencedPositionBuffer:o};const n=t.reprojection===ct.RENDER?t.transformBeforeProject:null;n&&(a=W(new Float64Array(a.length),a,n));const{normal:s,tangent:i}=e.vertexAttributes;this._passthroughReprojectionInfo(t)||!s&&!i||(o=a);const l=a===r||a===o?new Float64Array(a.length):a;return N(a,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:o}}_createNormalBuffer(e,t,r,o){const a=e.vertexAttributes.normal;if(null==a)return null;let n=a;const s=o.reprojection===ct.RENDER?o.transformBeforeProject:null;s&&(n=Y(n,new Float32Array(n.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(o.reprojection===ct.NONE)return n;if("local"===i){if(!z(this._context.renderCoordsHelper.spatialReference))return n;if(null==r)return null;if(e.spatialReference.isGeographic){const e=n===a?new Float32Array(n.length):n;return Z(n,J.NORMAL,r,e)}if(e.spatialReference.isWebMercator){const e=n===a?new Float32Array(n.length):n;return K(n,J.NORMAL,r,e)}return n}if(null==r)return null;const l=n===a?new Float32Array(n.length):n,c=this._context.renderCoordsHelper.spatialReference;return Q(n,r,e.spatialReference,t,c,l)}_createTangentBuffer(e,t,r,o){const a=e.vertexAttributes.tangent;if(null==a)return null;let n=a;const s=o.reprojection===ct.RENDER?o.transformBeforeProject:null;s&&(n=X(n,new Float32Array(n.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(o.reprojection===ct.NONE)return n;if("local"===i){if(!z(this._context.renderCoordsHelper.spatialReference))return n;if(null==r)return null;if(e.spatialReference.isGeographic){const e=n===a?new Float32Array(n.length):n;return Z(n,J.TANGENT,r,e)}if(e.spatialReference.isWebMercator){const e=n===a?new Float32Array(n.length):n;return K(n,J.TANGENT,r,e)}return n}if(null==r)return null;const l=n===a?new Float32Array(n.length):n,c=this._context.renderCoordsHelper.spatialReference;return ee(n,r,e.spatialReference,t,c,l)}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e,this._getFallbackOpacityAndColor()),r=ge(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return xe(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,a=e.vertexAttributes.uv,n=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(n&&n.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(a&&a.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=Ke(e),u=this._createSymbolColorBuffer(t),f=this._createNormalBuffer(e,i,l,s),p=this._createTangentBuffer(e,i,l,s),h=a,{transformation:d,position:g,normal:x,tangent:_}=this._passthroughReprojectionInfo(s)?{transformation:s.objectTransformation,position:i,normal:f,tangent:p}:this._transformOriginLocal(e,i,f,p);return{positionBuffer:g,normalBuffer:x,tangentBuffer:_,uvBuffer:h,colorBuffer:c,symbolColorBuffer:u,objectTransformation:d,geometryTransformation:s.reprojection===ct.NONE&&s.geometryTransformation?s.geometryTransformation:m()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?q(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?ct.NONE:ct.RENDER:ct.NONE;if(k(t))return{reprojection:r};const o=t.origin,a=m(),n=e.transform?.localMatrix??f;if(r===ct.NONE){O(e.spatialReference,o,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:a,geometryTransformation:p(n)}}const s=i(m(),o);return l(s,s,n),{reprojection:r,transformBeforeProject:s}}_transformOriginLocal(e,t,r,o){const a=this._context.renderCoordsHelper.spatialReference,n=e.origin;et[0]=n.x,et[1]=n.y,et[2]=n.z??0;const s=m();O(e.spatialReference,et,s,a),c(nt,s);const{position:i,normal:l,tangent:u}=e.vertexAttributes,f=t===i?new Float64Array(t.length):t;W(f,t,nt);const p=r?r===l?new Float32Array(r.length):r:null,h=o?o===u?new Float32Array(o.length):o:null;return r&&p&&Y(r,p,nt),o&&h&&X(o,h,nt),{transformation:s,position:f,normal:p,tangent:h}}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=te(e,r??e.spatialReference);return!!o&&(U(o,it),!F(it,this._context.clippingExtent))}_createGeometryInfo(e,t,r){if(!E(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:a,uvBuffer:n,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:c,objectTransformation:m,geometryTransformation:f}=o,p=e.components??lt,h=new Array;let d=!1;const g=u(tt,m),x=this._context.localOriginFactory.getOrigin(g);for(const u of p){if(!this._validateFaces(e,u))return null;const t=Fe(e,u);if(0===t.length)continue;const o=Be(a,l,u,t);o.didFlipNormals&&(d=!0);const m=[[je.POSITION,new Te(a,t,3,!0)],[je.NORMAL,new Te(o.normals,o.indices,3,!0)]];s&&m.push([je.COLOR,new Te(s,t,4,!0)]),i&&m.push([je.SYMBOLCOLOR,new Te(i,D(t.length),4,!0)]),n&&m.push([je.UV0,new Te(n,t,2,!0)]),c&&m.push([je.TANGENT,new Te(c,t,4,!0)]);const p=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),g=this._getOrCreateMaterial(e,u),_=new we(g,m,null,ve.Mesh,p);_.transformation=f,_.localOrigin=x,h.push(_)}return d&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:h,objectTransformation:m}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}_validateVertexSpace(e){const{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:r}=e;return t!==ae.Local||"local"!==r.type||(this.logger.warn("Displaying a mesh with a local vertex space in a view in local viewing mode is not supported."),!1)}test(){return{...super.test(),materials:this._materialInfoCache.materials}}_getFallbackOpacityAndColor(){const t=this.symbolLayer?.material?.color;return e.toUnitRGBA(t)??A}}class Ue{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}function Fe(e,t){return t.faces??G(e.vertexAttributes.position.length/3)}function Be(e,t,r,o){switch(r.shading||"flat"){default:case"source":return Ge(e,t,r,o);case"flat":return De(e,o);case"smooth":return Ve(e,o)}}function De(e,t){const r=B(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const n=$e(e,t,a,at);for(let e=0;e<3;e++)r[a+e]=n[e],o[a+e]=a/3}return new Ue(r,o,!1)}function Ge(e,t,r,o){if(null==t)return De(e,o);let a=!1;if(!r.trustSourceNormals)for(let n=0;n<o.length;n+=3){$e(e,o,n,at);for(let e=0;e<3;e++){const r=3*o[n+e];tt[0]=t[r],tt[1]=t[r+1],tt[2]=t[r+2],v(at,tt)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new Ue(t,o,a)}function Ve(e,t){const r={};for(let n=0;n<t.length;n+=3){const o=$e(e,t,n,at);for(let e=0;e<3;e++){const a=t[n+e];let s=r[a];s||(s={normal:P(),count:0},r[a]=s),g(s.normal,s.normal,o),s.count++}}const o=B(3*t.length),a=new Array(3*t.length);for(let n=0;n<t.length;n++){const e=r[t[n]];1!==e.count&&(b(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*n+t]=e.normal[t];a[n]=n}return new Ue(o,a,!1)}function Le(e,t,r,o,a,n){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],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],n[0]=e[l],n[1]=e[l+1],n[2]=e[l+2]}function $e(e,t,r,o){return Le(e,t,r,tt,rt,ot),w(rt,rt,tt),w(ot,ot,tt),R(tt,rt,ot),b(o,tt),o}function He(e){if(!e)return null;const{scale:r,offset:o,rotation:a}=e;return{scale:r,offset:o,rotation:t(a)}}function ke(e="repeat"){if("string"==typeof e){const t=qe(e);return{s:t,t}}return{s:qe(e.horizontal),t:qe(e.vertical)}}function qe(e){switch(e){case"clamp":return Ne.CLAMP_TO_EDGE;case"mirror":return Ne.MIRRORED_REPEAT;default:return Ne.REPEAT}}function ze(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 We(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}function Ye(e){return e.data??e.url}function Ze(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}function Je(e){const{offset:t,scale:r,rotation:o}=e??Xe;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}function Ke(e){return e.vertexAttributes.color}function Qe(e){return 1===(e.material?.color?.a??1)}const Xe=new $,et=P(),tt=P(),rt=P(),ot=P(),at=P(),nt=m(),st=m(),it=S(),lt=[new V];var ct;!function(e){e[e.NONE=0]="NONE",e[e.RENDER=1]="RENDER"}(ct||(ct={}));export{Se as Graphics3DMeshFillSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{releaseMaybe as r}from"../../../../core/maybe.js";import{isPromiseLike as o}from"../../../../core/promiseUtils.js";import{normalFromMat4 as a,fromMat4 as n}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as i,multiply as l,invert as c,getTranslation as u}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m,IDENTITY as f,clone as p}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as h}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{i as d,g,h as x,t as _,q as T,n as b,b as y,f as v,d as w,e as M}from"../../../../chunks/vec32.js";import{ZEROS as R,ONES as j,create as A}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as C,ZEROS as P}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as O}from"../../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as E}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as N}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToPoint as I}from"../../../../geometry/projection/projectVectorToPoint.js";import{create as S,fromBuffer as U,intersectsClippingArea as F}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as B}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as D,getContinuousIndexArray as G}from"../../../../geometry/support/Indices.js";import V from"../../../../geometry/support/MeshComponent.js";import L from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import $ from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as H,isAbsoluteVertexSpace as k}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as q,isPlateCarree as z}from"../../../../geometry/support/spatialReferenceUtils.js";import{t as W}from"../../../../chunks/vec3.js";import{transformNormal as Y,transformVectorENUPlateCarree as Z,VectorType as J,transformVectorWMPlateCarree as K,projectNormalToPCPF as Q,transformTangent as X,projectTangentToPCPF as ee}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as te}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{makeDehydratedPoint as re}from"../../../../layers/graphics/dehydratedPoint.js";import{MeshTransformUpdateAction as oe}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as ae}from"../../../ViewingMode.js";import{isEncodedMeshTexture as ne}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as se}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as ie}from"./ElevationAligners.js";import{needsElevationUpdates3D as le,evaluateElevationInfoAtPoint as ce}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as ue}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as me}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as fe}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as pe,MeshFastUpdateProcessor as he}from"./MeshFastUpdateProcessor.js";import{createMaterial as de}from"../support/edgeUtils.js";import{parseColorMixMode as ge,encodeSymbolColor as xe}from"../support/symbolColorUtils.js";import{debugFlags as _e}from"../../support/debugFlags.js";import{Attribute as Te}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as be,CullFaceOptions as ye}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as ve}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as we}from"../../webgl-engine/lib/Geometry.js";import{Object3D as Me}from"../../webgl-engine/lib/Object3D.js";import{Texture as Re}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as je}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as Ae}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as Ce}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as Pe,advancedMRRFactors as Oe,schematicMRRFactors as Ee}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as Ne}from"../../../webgl/enums.js";const Ie=["mesh"];class Se extends fe{constructor(e,t,r,o){super(e,t,r,o,Qe(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]}))}destroy(){super.destroy(),this._textures.forEach((e=>e.unload())),this._context.stage.removeMany(this._materialInfoCache.materials),this._context.stage.removeMany(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy(this._context.stage)}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Ie,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache,this._context)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTextureAlphaMode(t,e)})),e.forEach((e=>t(e)?.layerOpacityChanged(r,this._context.isAsync)))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,le)}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 a=e.fastTransformUpdatesEnabled;switch(o){case oe.EnableFastUpdates:if(a)return!0;break;case oe.DisableFastUpdates:if(!a)return!0;break;default:if(!a)return!!this.updateTransform(e,t,r,oe.EnableFastUpdates)&&(e.autoDisableFastTransformUpdates((()=>this.updateTransform(e,t,r,oe.DisableFastUpdates))),!0)}const n=this._context.renderCoordsHelper.spatialReference,s=st,{origin:i,transform:l}=r;if(!E(t,d(tt,i.x,i.y,i.z??0),s,n))return!1;switch(o){case oe.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case oe.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case oe.UpdateFastLocalOrigin:e.updateFastLocalOrigin(s,l,this._context.localOriginFactory)}const{elevationContext:c}=e;c.centerPointInElevationSR=this._getCenterPointInElevationSR(s);const{elevationProvider:u,renderCoordsHelper:m}=this._context,f=(e,t)=>ce(e,u,c,m,t);return e.alignedSampledElevation=ie(e,c,u.spatialReference,f,m,s),e.updateTransform(s,l,this._context.isAsync),e.updateAutoDisableFastTransformUpdates((()=>this.updateTransform(e,t,r,oe.DisableFastUpdates))),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:n,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,f=Ze(a),p=Ze(n),h=Je(s),d=Ze(i),g=Je(l);if(o.color=a,o.colorTexture=n,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 L){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:n,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:f}=t.material,p=Ze(a),h=Je(n),d=Ze(i),g=Ze(c),x=Je(u),_=Ze(m),T=Je(f);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=He(s),o.normalTextureTransform=He(l),o.emissiveTextureTransform=He(u),o.occlusionTextureTransform=He(f),o.metallicRoughnessTextureTransform=He(n),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${p},mrtt:${h},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${T}`}return o}_getInternalTexture(e,t=be.Opaque){const a=Ye(e);if(!a)return null;const n=`${e.contentHash}/${t}`;let s=this._textures.get(n);if(s){const e=this._context.stage.renderView.textures;let t=null;const a=e.acquire(s.id);return null==a||o(a)||(s.events.on("unloaded",(()=>t=r(t))),t=a),s}let i=null;const l=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,c={wrap:ke(e.wrap),noUnpackFlip:!0,maxAnisotropy:l,mipmap:l>1};return ne(a)?(i=a.data,c.preMultiplyAlpha=!1,c.encoding=a.encoding):(i=a,c.preMultiplyAlpha=t!==be.Opaque),s=new Re(i,c),this._textures.set(n,s),s.load(this._context.stage.renderView.renderingContext),this._context.stage.add(s),s.events.on("unloaded",(()=>{this._textures.delete(n)})),s}_setInternalMaterialTextureParameters(t,r){if(null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}t.normalTexture&&(r.normalTextureId=this._getInternalTexture(t.normalTexture)?.id),t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTexture(t.emissiveTexture)?.id),t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTexture(t.occlusionTexture)?.id),t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTexture(t.metallicRoughnessTexture)?.id)}_setInternalMaterialParameters(e,t,r){null!=e.color&&We(e.color,t,r),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=se(e.colorTextureTransform),t.normalTextureTransformMatrix=se(e.normalTextureTransform);const o=null!=e.normalTextureTransform?.scale?e.normalTextureTransform?.scale:h;t.scale=[o[0],o[1]],t.occlusionTextureTransformMatrix=se(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=se(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=se(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t,r=this.symbolLayer?.material?.color){const o=this._drivenProperties.color;let a=this.symbolLayer.material?.colorMixMode??null;if(o)t.externalColor=C;else{const o=r??null;o?t.externalColor=e.toUnitRGBA(o):(a=null,t.externalColor=C)}a&&(t.colorMixMode=a),t.castShadows=!!this.symbolLayer.castShadows}_getOrCreateMaterial(t,r){const o=r.material?.color,a=r.material?.colorTexture,n=r.material?.alphaMode,s="blend"===n,i=!("opaque"===n)&&(ze(t)||null!=o&&o.a<1||a?.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=Pe({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:R,diffuse:j,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:ye.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||u.isComponentTransparent};f.mrrFactors=m?Ee:[l.metallic,l.roughness,Oe[2]],r.material&&(f.doubleSided=r.material.doubleSided,f.cullFace=r.material.doubleSided?ye.None:ye.Back,f.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(f),this._setMaterialTextureAlphaMode(f,u),this._setInternalMaterialParameters(l,f,u);const p=new Ae(f,this._context);return u.material=p,this._materialInfoCache.set(l.uid,u),this._context.stage.add(p),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?be.MaskBlend:be.Opaque}else e.textureAlphaMode="opaque"===t.alphaMode?be.Opaque:"mask"===t.alphaMode?be.Mask:be.Blend}_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),i=[],l=[],c=t[0].transformation,u=a(s(),c);for(let a=0;a<r;a++){const e=t[a].attributes.get(je.POSITION);if(!e)continue;const r=e.data,o=e.indices;for(let t=0;t<o.length;t+=3)$e(r,o,t,at),Le(r,o,t,tt,rt,ot),g(tt,tt,rt),g(tt,tt,ot),x(tt,tt,1/3),_(tt,tt,c),i.push(...tt),T(at,at,u),b(at,at),y(tt,tt,at,n),i.push(...tt),l.push(l.length),l.push(l.length)}return i.length?new we(this._debugFaceNormalMaterial,[[je.POSITION,new Te(i,l,3,!0)]],null,ve.Line):null}_createPerVertexDebugVectors(e,t,r,o,i){const l=t.length,c=e.spatialReference.isGeographic?20015077/180:1,u=.1*i*Math.max(e.extent.width*c,e.extent.height*c,e.extent.zmax-e.extent.zmin),m=[],f=[],p=t[0].transformation,h=a(s(),p);r===je.TANGENT&&n(h,p);for(let a=0;a<l;a++){const e=t[a],o=e.attributes.get(je.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;d(tt,s[e+0],s[e+1],s[e+2]),_(tt,tt,p),m.push(...tt),d(rt,l[r+0],l[r+1],l[r+2]),T(rt,rt,h),b(rt,rt),y(tt,tt,rt,u),m.push(...tt),f.push(f.length),f.push(f.length)}}return m.length?new we(o,[[je.POSITION,new Te(m,f,3,!0)]],null,ve.Line):null}_createAs3DShape(e,t,r,o){const a=e.geometry;if("mesh"!==a.type)return null;const n=this._createGeometryInfo(a,t,o);if(null==n)return null;const{geometries:s,objectTransformation:i}=n;if(_e.DRAW_MESH_GEOMETRY_NORMALS){const e=this._createPerVertexDebugVectors(a,s,je.NORMAL,this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(a,s,je.TANGENT,this._debugTangentNormalMaterial,.5),r=this._createFaceDebugNormals(a,s);e&&s.push(e),t&&s.push(t),r&&s.push(r)}const l=new Me({geometries:s,layerUid:this._context.layer.uid,graphicUid:o,isElevationSource:!0});l.transformation=i;const c=de(this.symbolLayer,{opacity:this._getLayerOpacity()}),u=c?new me(s[0].material,c,this._context.slicePlaneEnabled):null,m=new ue(this,l,s,null,null,ie,r,u);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=le(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,m.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(a),r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:f,renderCoordsHelper:p}=this._context,h=(e,t)=>ce(e,f,r,p,t);return m.alignedSampledElevation=ie(m,r,f.spatialReference,h,p),m}_fastTransformUpdatesAllowed(e){const{vertexSpace:t,spatialReference:r}=e;if(!H(t))return!1;const{type:o}=t,{view:a}=this._context.graphicsCoreOwner,{viewingMode:n}=a.state,s=a.spatialReference;return n===ae.Global&&"local"===o||n===ae.Local&&q(s,r)&&"georeferenced"===o&&!r.isGeographic}_getCenterPointInElevationSR(e){const t=re(0,0,0,this._context.elevationProvider.spatialReference??null);return I([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_passthroughReprojectionInfo(e){return e.reprojection===ct.NONE&&!!e.objectTransformation}_createPositionBuffer(e,t){const r=e.vertexAttributes.position;let o,a=r;if(t.reprojection===ct.NONE)return{position:a,georeferencedPositionBuffer:o};const n=t.reprojection===ct.RENDER?t.transformBeforeProject:null;n&&(a=W(new Float64Array(a.length),a,n));const{normal:s,tangent:i}=e.vertexAttributes;this._passthroughReprojectionInfo(t)||!s&&!i||(o=a);const l=a===r||a===o?new Float64Array(a.length):a;return N(a,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:o}}_createNormalBuffer(e,t,r,o){const a=e.vertexAttributes.normal;if(null==a)return null;let n=a;const s=o.reprojection===ct.RENDER?o.transformBeforeProject:null;s&&(n=Y(n,new Float32Array(n.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(o.reprojection===ct.NONE)return n;if("local"===i){if(!z(this._context.renderCoordsHelper.spatialReference))return n;if(null==r)return null;if(e.spatialReference.isGeographic){const e=n===a?new Float32Array(n.length):n;return Z(n,J.NORMAL,r,e)}if(e.spatialReference.isWebMercator){const e=n===a?new Float32Array(n.length):n;return K(n,J.NORMAL,r,e)}return n}if(null==r)return null;const l=n===a?new Float32Array(n.length):n,c=this._context.renderCoordsHelper.spatialReference;return Q(n,r,e.spatialReference,t,c,l)}_createTangentBuffer(e,t,r,o){const a=e.vertexAttributes.tangent;if(null==a)return null;let n=a;const s=o.reprojection===ct.RENDER?o.transformBeforeProject:null;s&&(n=X(n,new Float32Array(n.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(o.reprojection===ct.NONE)return n;if("local"===i){if(!z(this._context.renderCoordsHelper.spatialReference))return n;if(null==r)return null;if(e.spatialReference.isGeographic){const e=n===a?new Float32Array(n.length):n;return Z(n,J.TANGENT,r,e)}if(e.spatialReference.isWebMercator){const e=n===a?new Float32Array(n.length):n;return K(n,J.TANGENT,r,e)}return n}if(null==r)return null;const l=n===a?new Float32Array(n.length):n,c=this._context.renderCoordsHelper.spatialReference;return ee(n,r,e.spatialReference,t,c,l)}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e,this._getFallbackOpacityAndColor()),r=ge(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return xe(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,a=e.vertexAttributes.uv,n=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(n&&n.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(a&&a.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=Ke(e),u=this._createSymbolColorBuffer(t),f=this._createNormalBuffer(e,i,l,s),p=this._createTangentBuffer(e,i,l,s),h=a,{transformation:d,position:g,normal:x,tangent:_}=this._passthroughReprojectionInfo(s)?{transformation:s.objectTransformation,position:i,normal:f,tangent:p}:this._transformOriginLocal(e,i,f,p);return{positionBuffer:g,normalBuffer:x,tangentBuffer:_,uvBuffer:h,colorBuffer:c,symbolColorBuffer:u,objectTransformation:d,geometryTransformation:s.reprojection===ct.NONE&&s.geometryTransformation?s.geometryTransformation:m()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?q(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?ct.NONE:ct.RENDER:ct.NONE;if(k(t))return{reprojection:r};const o=t.origin,a=m(),n=e.transform?.localMatrix??f;if(r===ct.NONE){E(e.spatialReference,o,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:a,geometryTransformation:p(n)}}const s=i(m(),o);return l(s,s,n),{reprojection:r,transformBeforeProject:s}}_transformOriginLocal(e,t,r,o){const a=this._context.renderCoordsHelper.spatialReference,n=e.origin;et[0]=n.x,et[1]=n.y,et[2]=n.z??0;const s=m();E(e.spatialReference,et,s,a),c(nt,s);const{position:i,normal:l,tangent:u}=e.vertexAttributes,f=t===i?new Float64Array(t.length):t;W(f,t,nt);const p=r?r===l?new Float32Array(r.length):r:null,h=o?o===u?new Float32Array(o.length):o:null;return r&&p&&Y(r,p,nt),o&&h&&X(o,h,nt),{transformation:s,position:f,normal:p,tangent:h}}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=te(e,r??e.spatialReference);return!!o&&(U(o,it),!F(it,this._context.clippingExtent))}_createGeometryInfo(e,t,r){if(!O(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:a,uvBuffer:n,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:c,objectTransformation:m,geometryTransformation:f}=o,p=e.components??lt,h=new Array;let d=!1;const g=u(tt,m),x=this._context.localOriginFactory.getOrigin(g);for(const u of p){if(!this._validateFaces(e,u))return null;const t=Fe(e,u);if(0===t.length)continue;const o=Be(a,l,u,t);o.didFlipNormals&&(d=!0);const m=[[je.POSITION,new Te(a,t,3,!0)],[je.NORMAL,new Te(o.normals,o.indices,3,!0)]];s&&m.push([je.COLOR,new Te(s,t,4,!0)]),i&&m.push([je.SYMBOLCOLOR,new Te(i,D(t.length),4,!0)]),n&&m.push([je.UV0,new Te(n,t,2,!0)]),c&&m.push([je.TANGENT,new Te(c,t,4,!0)]);const p=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),g=this._getOrCreateMaterial(e,u),_=new we(g,m,null,ve.Mesh,p);_.transformation=f,_.localOrigin=x,h.push(_)}return d&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:h,objectTransformation:m}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}_validateVertexSpace(e){const{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:r}=e;return t!==ae.Local||"local"!==r.type||(this.logger.warn("Displaying a mesh with a local vertex space in a view in local viewing mode is not supported."),!1)}test(){return{...super.test(),materials:this._materialInfoCache.materials}}_getFallbackOpacityAndColor(){const t=this.symbolLayer?.material?.color;return e.toUnitRGBA(t)??P}}class Ue{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}function Fe(e,t){return t.faces??G(e.vertexAttributes.position.length/3)}function Be(e,t,r,o){switch(r.shading||"flat"){default:case"source":return Ge(e,t,r,o);case"flat":return De(e,o);case"smooth":return Ve(e,o)}}function De(e,t){const r=B(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const n=$e(e,t,a,at);for(let e=0;e<3;e++)r[a+e]=n[e],o[a+e]=a/3}return new Ue(r,o,!1)}function Ge(e,t,r,o){if(null==t)return De(e,o);let a=!1;if(!r.trustSourceNormals)for(let n=0;n<o.length;n+=3){$e(e,o,n,at);for(let e=0;e<3;e++){const r=3*o[n+e];tt[0]=t[r],tt[1]=t[r+1],tt[2]=t[r+2],v(at,tt)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new Ue(t,o,a)}function Ve(e,t){const r={};for(let n=0;n<t.length;n+=3){const o=$e(e,t,n,at);for(let e=0;e<3;e++){const a=t[n+e];let s=r[a];s||(s={normal:A(),count:0},r[a]=s),g(s.normal,s.normal,o),s.count++}}const o=B(3*t.length),a=new Array(3*t.length);for(let n=0;n<t.length;n++){const e=r[t[n]];1!==e.count&&(b(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*n+t]=e.normal[t];a[n]=n}return new Ue(o,a,!1)}function Le(e,t,r,o,a,n){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],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],n[0]=e[l],n[1]=e[l+1],n[2]=e[l+2]}function $e(e,t,r,o){return Le(e,t,r,tt,rt,ot),w(rt,rt,tt),w(ot,ot,tt),M(tt,rt,ot),b(o,tt),o}function He(e){if(!e)return null;const{scale:r,offset:o,rotation:a}=e;return{scale:r,offset:o,rotation:t(a)}}function ke(e="repeat"){if("string"==typeof e){const t=qe(e);return{s:t,t}}return{s:qe(e.horizontal),t:qe(e.vertical)}}function qe(e){switch(e){case"clamp":return Ne.CLAMP_TO_EDGE;case"mirror":return Ne.MIRRORED_REPEAT;default:return Ne.REPEAT}}function ze(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 We(t,r,o){r.diffuse=e.toUnitRGB(t),r.opacity="opaque"===o.alphaMode?1:t.a}function Ye(e){return e.data??e.url}function Ze(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}function Je(e){const{offset:t,scale:r,rotation:o}=e??Xe;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}function Ke(e){return e.vertexAttributes.color}function Qe(e){return 1===(e.material?.color?.a??1)}const Xe=new $,et=A(),tt=A(),rt=A(),ot=A(),at=A(),nt=m(),st=m(),it=S(),lt=[new V];var ct;!function(e){e[e.NONE=0]="NONE",e[e.RENDER=1]="RENDER"}(ct||(ct={}));export{Se as Graphics3DMeshFillSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{c as e,t,g as i}from"../../../../chunks/vec32.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{setMin as a,setMax as n,create as r,isPoint as o,empty as l,center as c,offset as g}from"../../../../geometry/support/aaBoundingBox.js";import{a as h}from"../../../../chunks/sphere.js";import{evaluateElevationInfoAtPoint as d}from"./elevationAlignmentUtils.js";import{setContextFeature as u}from"./featureExpressionInfoUtils.js";import{demResolutionForBoundingBox as b}from"./graphicUtils.js";import{Object3DState as m}from"../../webgl-engine/lib/basicInterfaces.js";import{Transparency as O}from"../../webgl-engine/lib/edgeRendering/interfaces.js";class j{constructor(e,t,i){this.baseMaterial=e,this.edgeMaterial=t,this.hasSlicePlane=i}}class p{get isElevationSource(){return!!this.stageObject.lastValidElevationBB}constructor(e,t,i,s,a,n,r,o=null){this.graphics3DSymbolLayer=e,this.stageObject=t,this._uniqueGeometries=i,this._uniqueMaterials=s,this._sharedResource=a,this.elevationAligner=n,this.elevationContext=r,this._edgeState=o,this.type="object3d",this._stageLayer=null,this._visible=!1,this._addedToStage=!1,this.alignedSampledElevation=0,this.needsElevationUpdates=!1,this.useObjectOriginAsAttachmentOrigin=!1}initialize(e){this._stageLayer=e;const t=e.stage;t.addMany(this._uniqueMaterials),t.addMany(this._uniqueGeometries),t.add(this.stageObject)}destroy(){if(!this._stageLayer)return;const e=this._stageLayer.stage;e.removeMany(this._uniqueMaterials),e.removeMany(this._uniqueGeometries),e.remove(this.stageObject),this._addedToStage&&(this._stageLayer.remove(this.stageObject),this._addedToStage=!1),e.renderer.edgeView?.removeObject(this.stageObject),this.stageObject.dispose(),this._sharedResource?.release(),this._visible=!1,this._stageLayer=null}layerOpacityChanged(e,t){const{stageObject:i,_edgeState:s,_stageLayer:a}=this;if(null==s)return;const n=v(s.baseMaterial);s.edgeMaterial.objectTransparency!==n&&(s.edgeMaterial.objectTransparency=n,this.resetEdgeObject(t)),a.stage.renderer.withEdgeView((t=>t.updateAllComponentOpacities(i,[e])))}updateHighlights(e){}slicePlaneEnabledChanged(e,t){const{stageObject:i,_edgeState:s,_stageLayer:a}=this;null!=s&&a.stage.renderer.withEdgeView((a=>{a.updateAllComponentMaterials(i,s.edgeMaterial,e,!t),s.hasSlicePlane=e}))}setVisibility(e){const{_edgeState:t,stageObject:i,_stageLayer:s}=this;null!=s&&this.visible!==e&&(this._visible=e,i.visible=e,e&&!this._addedToStage&&(s.add(i),this._addedToStage=!0),null!=t&&s.stage.renderer.withEdgeView((s=>{s.hasObject(i)?s.updateObjectVisibility(i,e):e&&this._addOrUpdateEdgeObject(t,s,!1)})))}get visible(){return this._visible}alignWithElevation(e,t,i,s){if(null==this.elevationAligner)return;null!=i&&u(this.elevationContext.featureExpressionInfoContext,i);const a=(i,s)=>d(i,e,this.elevationContext,t,s);this.alignedSampledElevation=this.elevationAligner(this,this.elevationContext,e.spatialReference,a,t),this.resetEdgeObject(s)}alignWithAbsoluteElevation(e,t,i){const s=(t,i)=>{i.sampledElevation=e,i.verticalDistanceToGround=0,i.z=e};this.alignedSampledElevation=this.elevationAligner(this,this.elevationContext,null,s,t),this.resetEdgeObject(i)}getCenterObjectSpace(t=s()){return e(t,h(this.stageObject.boundingVolumeObjectSpace.bounds))}getBoundingBoxObjectSpace(e=r()){const t=this.stageObject.boundingVolumeObjectSpace;return a(e,t.min),n(e,t.max),e}computeAttachmentOrigin(e){const s=this.stageObject.effectiveTransformation;if(this.useObjectOriginAsAttachmentOrigin)e.render.origin[0]+=s[12],e.render.origin[1]+=s[13],e.render.origin[2]+=s[14],e.render.num++;else for(const a of this.stageObject.geometries)a.computeAttachmentOrigin(y)&&(t(y,y,s),i(e.render.origin,e.render.origin,y),e.render.num++)}async getProjectedBoundingBox(e,i,s,a,n){const r=this.getBoundingBoxObjectSpace(n),h=S,d=o(r)?1:h.length;for(let o=0;o<d;o++){const e=h[o];f[0]=r[e[0]],f[1]=r[e[1]],f[2]=r[e[2]],t(f,f,this.stageObject.transformation),_[3*o]=f[0],_[3*o+1]=f[1],_[3*o+2]=f[2]}if(!e(_,0,d))return null;l(r);let u=null;this.calculateRelativeScreenBounds&&(u=this.calculateRelativeScreenBounds());for(let t=0;t<3*d;t+=3){for(let e=0;e<3;e++)r[e]=Math.min(r[e],_[t+e]),r[e+3]=Math.max(r[e+3],_[t+e]);u&&s.push({location:_.slice(t,t+3),screenSpaceBoundingRect:u})}if(i?.service&&"absolute-height"!==this.elevationContext.mode){c(r,y);const e="relative-to-scene"===this.elevationContext.mode?"scene":"ground";let t=0;if(i.useViewElevation)t=i.service.getElevation(y[0],y[1],e)??0;else try{const s=b(r,i.service.spatialReference,i);t=await i.service.queryElevation(y[0],y[1],a,s,e)??0}catch(m){}g(r,0,0,-this.alignedSampledElevation+t)}return r}addObjectState(e){e.stateType===m.Highlight&&e.addObject(this.stageObject,this.stageObject.highlight(e.highlightName)),e.stateType===m.MaskOccludee&&e.addObject(this.stageObject,this.stageObject.maskOccludee())}removeObjectState(e){e.removeByObject(this.stageObject)}resetEdgeObject(e){const{_edgeState:t,stageObject:i,_stageLayer:s,_visible:a}=this;null!=t&&s.stage.renderer.withEdgeView((s=>{a?this._addOrUpdateEdgeObject(t,s,e):s.removeObject(i)}))}_addOrUpdateEdgeObject(e,t,i){const s=v(e.baseMaterial);e.edgeMaterial.objectTransparency=s,t.addOrUpdateObject3D(this.stageObject,e.edgeMaterial,e.hasSlicePlane,!i).then((()=>this._stageLayer?.sync()))}}function v(e){return e.
|
|
5
|
+
import{c as e,t,g as i}from"../../../../chunks/vec32.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{setMin as a,setMax as n,create as r,isPoint as o,empty as l,center as c,offset as g}from"../../../../geometry/support/aaBoundingBox.js";import{a as h}from"../../../../chunks/sphere.js";import{evaluateElevationInfoAtPoint as d}from"./elevationAlignmentUtils.js";import{setContextFeature as u}from"./featureExpressionInfoUtils.js";import{demResolutionForBoundingBox as b}from"./graphicUtils.js";import{Object3DState as m}from"../../webgl-engine/lib/basicInterfaces.js";import{Transparency as O}from"../../webgl-engine/lib/edgeRendering/interfaces.js";class j{constructor(e,t,i){this.baseMaterial=e,this.edgeMaterial=t,this.hasSlicePlane=i}}class p{get isElevationSource(){return!!this.stageObject.lastValidElevationBB}constructor(e,t,i,s,a,n,r,o=null){this.graphics3DSymbolLayer=e,this.stageObject=t,this._uniqueGeometries=i,this._uniqueMaterials=s,this._sharedResource=a,this.elevationAligner=n,this.elevationContext=r,this._edgeState=o,this.type="object3d",this._stageLayer=null,this._visible=!1,this._addedToStage=!1,this.alignedSampledElevation=0,this.needsElevationUpdates=!1,this.useObjectOriginAsAttachmentOrigin=!1}initialize(e){this._stageLayer=e;const t=e.stage;t.addMany(this._uniqueMaterials),t.addMany(this._uniqueGeometries),t.add(this.stageObject)}destroy(){if(!this._stageLayer)return;const e=this._stageLayer.stage;e.removeMany(this._uniqueMaterials),e.removeMany(this._uniqueGeometries),e.remove(this.stageObject),this._addedToStage&&(this._stageLayer.remove(this.stageObject),this._addedToStage=!1),e.renderer.edgeView?.removeObject(this.stageObject),this.stageObject.dispose(),this._sharedResource?.release(),this._visible=!1,this._stageLayer=null}layerOpacityChanged(e,t){const{stageObject:i,_edgeState:s,_stageLayer:a}=this;if(null==s)return;const n=v(s.baseMaterial);s.edgeMaterial.objectTransparency!==n&&(s.edgeMaterial.objectTransparency=n,this.resetEdgeObject(t)),a.stage.renderer.withEdgeView((t=>t.updateAllComponentOpacities(i,[e])))}updateHighlights(e){}slicePlaneEnabledChanged(e,t){const{stageObject:i,_edgeState:s,_stageLayer:a}=this;null!=s&&a.stage.renderer.withEdgeView((a=>{a.updateAllComponentMaterials(i,s.edgeMaterial,e,!t),s.hasSlicePlane=e}))}setVisibility(e){const{_edgeState:t,stageObject:i,_stageLayer:s}=this;null!=s&&this.visible!==e&&(this._visible=e,i.visible=e,e&&!this._addedToStage&&(s.add(i),this._addedToStage=!0),null!=t&&s.stage.renderer.withEdgeView((s=>{s.hasObject(i)?s.updateObjectVisibility(i,e):e&&this._addOrUpdateEdgeObject(t,s,!1)})))}get visible(){return this._visible}alignWithElevation(e,t,i,s){if(null==this.elevationAligner)return;null!=i&&u(this.elevationContext.featureExpressionInfoContext,i);const a=(i,s)=>d(i,e,this.elevationContext,t,s);this.alignedSampledElevation=this.elevationAligner(this,this.elevationContext,e.spatialReference,a,t),this.resetEdgeObject(s)}alignWithAbsoluteElevation(e,t,i){const s=(t,i)=>{i.sampledElevation=e,i.verticalDistanceToGround=0,i.z=e};this.alignedSampledElevation=this.elevationAligner(this,this.elevationContext,null,s,t),this.resetEdgeObject(i)}getCenterObjectSpace(t=s()){return e(t,h(this.stageObject.boundingVolumeObjectSpace.bounds))}getBoundingBoxObjectSpace(e=r()){const t=this.stageObject.boundingVolumeObjectSpace;return a(e,t.min),n(e,t.max),e}computeAttachmentOrigin(e){const s=this.stageObject.effectiveTransformation;if(this.useObjectOriginAsAttachmentOrigin)e.render.origin[0]+=s[12],e.render.origin[1]+=s[13],e.render.origin[2]+=s[14],e.render.num++;else for(const a of this.stageObject.geometries)a.computeAttachmentOrigin(y)&&(t(y,y,s),i(e.render.origin,e.render.origin,y),e.render.num++)}async getProjectedBoundingBox(e,i,s,a,n){const r=this.getBoundingBoxObjectSpace(n),h=S,d=o(r)?1:h.length;for(let o=0;o<d;o++){const e=h[o];f[0]=r[e[0]],f[1]=r[e[1]],f[2]=r[e[2]],t(f,f,this.stageObject.transformation),_[3*o]=f[0],_[3*o+1]=f[1],_[3*o+2]=f[2]}if(!e(_,0,d))return null;l(r);let u=null;this.calculateRelativeScreenBounds&&(u=this.calculateRelativeScreenBounds());for(let t=0;t<3*d;t+=3){for(let e=0;e<3;e++)r[e]=Math.min(r[e],_[t+e]),r[e+3]=Math.max(r[e+3],_[t+e]);u&&s.push({location:_.slice(t,t+3),screenSpaceBoundingRect:u})}if(i?.service&&"absolute-height"!==this.elevationContext.mode){c(r,y);const e="relative-to-scene"===this.elevationContext.mode?"scene":"ground";let t=0;if(i.useViewElevation)t=i.service.getElevation(y[0],y[1],e)??0;else try{const s=b(r,i.service.spatialReference,i);t=await i.service.queryElevation(y[0],y[1],a,s,e)??0}catch(m){}g(r,0,0,-this.alignedSampledElevation+t)}return r}addObjectState(e){e.stateType===m.Highlight&&e.addObject(this.stageObject,this.stageObject.highlight(e.highlightName)),e.stateType===m.MaskOccludee&&e.addObject(this.stageObject,this.stageObject.maskOccludee())}removeObjectState(e){e.removeByObject(this.stageObject)}resetEdgeObject(e){const{_edgeState:t,stageObject:i,_stageLayer:s,_visible:a}=this;null!=t&&s.stage.renderer.withEdgeView((s=>{a?this._addOrUpdateEdgeObject(t,s,e):s.removeObject(i)}))}_addOrUpdateEdgeObject(e,t,i){const s=v(e.baseMaterial);e.edgeMaterial.objectTransparency=s,t.addOrUpdateObject3D(this.stageObject,e.edgeMaterial,e.hasSlicePlane,!i).then((()=>this._stageLayer?.sync()))}}function v(e){return e.transparent?O.TRANSPARENT:O.OPAQUE}const _=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],f=s(),y=s(),S=[[0,1,2],[3,1,2],[0,4,2],[3,4,2],[0,1,5],[3,1,5],[0,4,5],[3,4,5]];export{p as Graphics3DObject3DGraphicLayer,j as Object3DEdgeState};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import{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{l,F as c,v as h,c as d,C as p,g as m,i as u}from"../../../../chunks/vec32.js";import{fromArray as y,clone as f,ZEROS as _,ONES as g,fromValues as b,create as P}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as x,ZEROS as R,create as v}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{computeTranslationToOriginAndRotation as L}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVector as C}from"../../../../geometry/projection/projectPointToVector.js";import{create as S,size as E,containsPoint as w,center as O}from"../../../../geometry/support/aaBoundingBox.js";import{defaultPrimitive as j}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as U,objectSymbolLayerSizeWithResourceSize as T}from"../../../../symbols/support/symbolLayerUtils3D.js";import{estimateNumVerticesForLods as B,defaultSymbolLayerMemoryComplexity as G}from"./defaultSymbolComplexity.js";import{perLodInstanceElevationAligner as I}from"./ElevationAligners.js";import{needsElevationUpdates3D as A,evaluateElevationInfoAtPoint as F,SampleElevationInfo as D}from"./elevationAlignmentUtils.js";import{Graphics3DLodInstanceGraphicLayer as z}from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as V}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as M,computeObjectScale as k,computeObjectRotation as H}from"./graphicUtils.js";import{ApplyRendererDiffResult as W}from"./interfaces.js";import{LoadStatus as q}from"./Loadable.js";import{makeLodResources as N}from"./lodResourceUtils.js";import{fetch as J}from"./objectResourceUtils.js";import{placePointOnGeometry as Y,extendPointGraphicElevationContext as $}from"./pointUtils.js";import{isValidPrimitive as Z,primitiveLodResources as K}from"./primitiveObjectSymbolUtils.js";import{SymbolComplexity as Q}from"./SymbolComplexity.js";import{getResourceUrlFromSymbolStyle as X}from"./webStyleUtils.js";import{initFastSymbolUpdatesState as ee,updateFastSymbolUpdatesState as te,ConvertOptions as se,evaluateModelTransform as re,evaluateModelTransformScale as ie}from"../support/FastSymbolUpdates.js";import{olidEnabled as ae}from"../../webgl-engine/effects/geometry/olidUtils.js";import{AlphaDiscardMode as oe,CullFaceOptions as ne}from"../../webgl-engine/lib/basicInterfaces.js";import{VertexAttribute as le}from"../../webgl-engine/lib/VertexAttribute.js";import{LodRenderer as ce}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{DefaultMaterial as he}from"../../webgl-engine/materials/DefaultMaterial.js";import{schematicMRRFactors as de}from"../../webgl-engine/materials/pbrUtils.js";class pe{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 me extends V{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,fe(t)),this._resources=null,this._optionalFields=new Array,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=M(this.symbolLayer);if(e)throw new Error(e)}if(this._isPrimitive){const t=this.symbolLayer.resource,s=t&&Z(t?.primitive)?t.primitive:j;this._resources=await this._createResourcesForPrimitive(s,e)}else{const t=await X(this.symbol.styleOrigin),s=t?.href??this.symbolLayer.resource?.href;this._resources=await this._createResourcesForUrl(s,e)}this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicalBasedRenderingChanged(),this.complexity=this.computeComplexity()}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,r){const i=this.symbolLayer,a=S(U(t)),o=y(E(a)),n=y(T(o,i)),h=l(n),d=!1,p=!1,m=i?.material,u=m?.emissiveFactor,b=u?c(f(u)):_,P={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,mrrFactors:de,ambient:g,diffuse:g,opacity:1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:i.castShadows,emissiveFactor:b,offsetTransparentBackfaces:!1},v=!!P.usePBR,L=m?.color,C=this.symbol;if("point-3d"===C.type&&C.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=C.verticalOffset;P.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0},P.castShadows=!1}if(this._context.screenSizePerspectiveEnabled&&(P.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),this._drivenProperties.color)P.externalColor=x;else{const t=null!=L?e.toUnitRGBA(L):this._drivenProperties.opacity?x:R;P.externalColor=t}P.transparent=this._computeTransparentParameter(P),P.cullFace=_e(P.transparent),this._fastUpdates=ee(this._context.renderer,this._fastVisualVariableConvertOptions(a,n,o,null)),P.isInstanced=!0,this._fastUpdates?(Object.assign(P,this._fastUpdates.materialParameters),this._optionalFields.push(le.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(P.hasInstancedColor=!0,this._optionalFields.push(le.COLOR)),ae()&&this._optionalFields.push(le.OBJECTANDLAYERIDCOLOR);const w=new he(P,this._context),O=K(t,w);if(!O)throw new Error(`Unknown object symbol primitive: ${t}`);const j=await this._createStageResources(O,v,r),B=await this._createLodRenderer(O,r);return new pe(O,B,j,o,d,p,a,n,h,v)}async _createResourcesForUrl(e,t){const r={isInstanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},i={spherical:this._context.spherical,materialParameters:r,streamDataRequester:this._context.streamDataRequester,cache:this._context.sharedResources.objectResourceCache};this._fastUpdates=ee(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(i.materialParameters,this._fastUpdates.materialParameters),this._optionalFields.push(le.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(i.materialParameters.hasInstancedColor=!0,this._optionalFields.push(le.COLOR)),ae()&&this._optionalFields.push(le.OBJECTANDLAYERIDCOLOR);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=await J(e,i),c=n.isEsriSymbolResource,h=n.isWosr,d=N(n.lods),p=this._context,m=this.symbolLayer.material,u=this._getExternalColorParameters(m),f=d.getMaterials();f.forEach((e=>{e.setParameters({...u}),e.setParameters({transparent:this._computeTransparentParameter(e.parameters)}),p.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:p.sharedResources.screenSizePerspectiveSettings})}));const _=n.referenceBoundingBox,g=y(E(_)),b=y(d.levels[0].pivotOffset),P=y(T(g,this.symbolLayer)),x=l(P),R=this._fastUpdates;te(R,this._context.renderer,this._fastVisualVariableConvertOptions(_,P,g,b))&&f.forEach((e=>e.setParameters(R.materialParameters)));const v=await this._createStageResources(d,o,t),L=await this._createLodRenderer(d,t);return new pe(d,L,v,g,c,h,_,P,x,o,b)}_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(),i.addMany(a),this._addDisposeResource((()=>i.removeMany(a)));const o=e.getTextures();i.addMany(o),this._addDisposeResource((()=>{o.forEach((e=>e.unload())),i.removeMany(o)})),await Promise.all(o.map((e=>this._context.stage.schedule((()=>e.load(i.renderView.renderingContext)),r)))),t(r);const n=e.getEngineGeometries();return i.addMany(n),this._addDisposeResource((()=>i.removeMany(n))),{materials:a,textures:o,geometries:n}}async _createLodRenderer(e,t){const s=this._context.stage,r={layerUid:this._context.layer.uid,graphicUid:e=>this._instanceIndexToGraphicUid.get(e),notifyGraphicGeometryChanged:e=>this._context.notifyGraphicGeometryChanged(this._instanceIndexToGraphicUid.get(e)),notifyGraphicVisibilityChanged:e=>this._context.notifyGraphicVisibilityChanged(this._instanceIndexToGraphicUid.get(e))},i=this._fastUpdates,a=i?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,xe),o(s,re(i.materialParameters,xe,s))},scaleFactor:(e,t,s)=>{t.getFeatureAttribute(s,xe),ie(e,i.materialParameters,xe)}}:null,n=new ce({symbol:e,optionalFields:this._optionalFields,metadata:r,shaderTransformation:a},this._context.scheduler);return n.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource((()=>{s.removeRenderPlugin(n),n.destroy()})),await s.addRenderPlugin(n,t),n}_getExternalColorParameters(t){const s={};return this._drivenProperties.color?s.externalColor=x:null!=t?.color?s.externalColor=e.toUnitRGBA(t.color):(s.externalColor=x,s.colorMixMode="ignore"),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=Y(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for object symbol: ${t.geometry.type}`),null;const r=this.setGraphicElevationContext(t),i=e.renderingInfo;return this._createAs3DShape(t,s,i,r,t.uid,e.layer.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(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,transparent:this._computeTransparentParameter({...r.parameters,layerOpacity:e})}),this._isPrimitive&&r.setParameters({cullFace:_e(r.parameters.transparent)})}}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,A)}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 W.RecreateSymbol;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 W.RecreateSymbol;if(!te(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,a,o,n)))return W.RecreateSymbol;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return W.FastUpdate}computeComplexity(){if(null==this._resources)return super.computeComplexity();const e=this._resources.lodResources,t=B(e.levels),s=e.computeUsedMemory(),r={...G(this.symbol,this.symbolLayer),resourceBytes:s};return new Q({verticesPerFeature:t,memory:r})}_hasLodRenderer(){return null!=this._resources}_createAs3DShape(e,t,s,r,i,a){if(!this._hasLodRenderer()||null==this._resources)return null;const o=this.getFastUpdateAttrValues(e),n=this._context.clippingExtent;if(C(t,ge,this._context.elevationProvider.spatialReference),null!=n&&!w(n,ge))return null;const l=ye(r),c=this._computeGlobalTransform(t,r,Pe,Re),h=this._computeLocalTransform(this._resources,this.symbolLayer,s,be),d=this._resources.lodRenderer.instanceData,p=d.addInstance();if(this._instanceIndexToGraphicUid.set(p,i),d.setLocalTransform(p,h,!1),d.setGlobalTransform(p,c),o&&d.setFeatureAttribute(p,o),null==this._fastUpdates&&this._hasPerInstanceColor()){const e=this._getVertexOpacityAndColor(s,this._getFallbackOpacityAndColor(),255);d.setColor(p,e)}const m=this._context.stage.renderView.olidRenderHelper;m&&d.setObjectAndLayerIdColor(p,m.getObjectAndLayerIdColor({graphicUid:i,layerUid:a}));const u=new z(this,p,I,r,this._context.stage.view.state.highlightOrderMap);return l&&(u.alignedSampledElevation=Re.sampledElevation),u.needsElevationUpdates=A(r.mode),$(u,t,this._context.elevationProvider),u}_computeGlobalTransform(e,t,s,r){return F(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),ge[0]=e.x,ge[1]=e.y,ge[2]=r.z,L(e.spatialReference,ge,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=k(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=t&&Y(t);if(null==s)return!1;const r=this.getGeometryElevationMode(t);return e.elevationContext.mode===r&&(this._computeGlobalTransform(s,e.elevationContext,Pe,Re),ye(e.elevationContext)&&(e.alignedSampledElevation=Re.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(e.instanceIndex,Pe,!0),$(e,s,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!(t.heading||t.tilt||t.roll||t.width||t.height||t.depth||t.anchor||t.anchorPosition))return;if(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},p=this._resources;this.loadStatus===q.LOADED&&e.symbolLayerStatePatches.push((()=>{p.symbolSize=y(T(p.resourceSize,{width:o,height:n,depth:l,isPrimitive:this._isPrimitive}))})),e.graphics3DGraphicPatches.push((({instanceIndex:e},t)=>{const s=this._computeLocalTransform(p,d,t,be);p.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):x;delete r.color;const o=this._resources;if(null==o)return;const n=this._isPrimitive;t.graphics3DGraphicPatches.push((({instanceIndex:e})=>{const t={};this._hasPerInstanceColor()?o.lodRenderer.instanceData.setColor(e,a):t.externalColor=a;for(const s of o.stageResources.materials)s.setParameters({...t,transparent:this._computeTransparentParameter({...s.parameters,...t})}),n&&s.setParameters({cullFace:_e(s.parameters.transparent)})}))}_applyObjectRotation(e,t,s){if(!this._fastUpdates?.requiresShaderTransformation||!t)return H(e.heading,e.tilt,e.roll,s)}_applyAnchor(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=ue(e.resourceBoundingBox,e.pivotOffset,t);r&&a(s,s,r)}_hasPerInstanceColor(){return this._drivenProperties.color||this._drivenProperties.opacity}_fastVisualVariableConvertOptions(e,t,s,r){const i=null!=e?y(E(e)):g,a=null!=e?ue(e,r,this.symbolLayer):_,o=this._context.renderCoordsHelper.unitInMeters,n=k(null!=t?t:void 0,t,s,o),l=b(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return new se({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:i,symbolSize:t??g,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??j}_getFallbackOpacityAndColor(){const t=this.symbolLayer.material?.color;if(null==t){return null==this._primitive?x:R}return e.toUnitRGBA(t)}_computeTransparentParameter(e){return this.needsDrivenTransparentPass||(e.opacity??1)<1||(e.externalColor?.[3]??1)<1||(e.layerOpacity??1)<1||(null!=e.texture||null!=e.textureId)&&e.textureAlphaMode!==oe.Opaque&&null!==e.textureAlphaMode}}function ue(e,t,s){const r=P();switch(s.anchor){case"center":d(r,O(e)),h(r,r);break;case"top":{const t=O(e);u(r,-t[0],-t[1],-e[5]);break}case"bottom":{const t=O(e);u(r,-t[0],-t[1],-e[2]);break}case"relative":{const t=O(e),i=E(e),a=s.anchorPosition,o=a?b(a.x,a.y,a.z):_;p(r,i,o),m(r,r,t),h(r,r);break}default:null!=t?h(r,t):d(r,_)}return r}function ye(e){return"absolute-height"!==e.mode}function fe(e){return 1===(e.material?.color?.a??1)&&null==e.resource?.href}function _e(e){return e?ne.None:ne.Back}const ge=P(),be=n(),Pe=n(),xe=v(),Re=new D;export{me 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 o,copy as a}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{l,F as c,v as h,c as d,C as m,g as p,i as u}from"../../../../chunks/vec32.js";import{fromArray as f,clone as y,ZEROS as _,ONES as g,fromValues as b,create as R}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as P,ZEROS as x,create as v}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{computeTranslationToOriginAndRotation as L}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVector as C}from"../../../../geometry/projection/projectPointToVector.js";import{create as S,size as E,containsPoint as w,center as j}from"../../../../geometry/support/aaBoundingBox.js";import{defaultPrimitive as O}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as U,objectSymbolLayerSizeWithResourceSize as T}from"../../../../symbols/support/symbolLayerUtils3D.js";import{estimateNumVerticesForLods as B,defaultSymbolLayerMemoryComplexity as G}from"./defaultSymbolComplexity.js";import{perLodInstanceElevationAligner as I}from"./ElevationAligners.js";import{needsElevationUpdates3D as A,evaluateElevationInfoAtPoint as D,SampleElevationInfo as F}from"./elevationAlignmentUtils.js";import{Graphics3DLodInstanceGraphicLayer as z}from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as V}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as M,computeObjectScale as k,computeObjectRotation as H}from"./graphicUtils.js";import{ApplyRendererDiffResult as W}from"./interfaces.js";import{LoadStatus as q}from"./Loadable.js";import{makeLodResources as N}from"./lodResourceUtils.js";import{fetch as J}from"./objectResourceUtils.js";import{placePointOnGeometry as Y,extendPointGraphicElevationContext as $}from"./pointUtils.js";import{isValidPrimitive as Z,primitiveLodResources as K}from"./primitiveObjectSymbolUtils.js";import{SymbolComplexity as Q}from"./SymbolComplexity.js";import{getResourceUrlFromSymbolStyle as X}from"./webStyleUtils.js";import{initFastSymbolUpdatesState as ee,updateFastSymbolUpdatesState as te,ConvertOptions as se,evaluateModelTransform as re,evaluateModelTransformScale as ie}from"../support/FastSymbolUpdates.js";import{olidEnabled as oe}from"../../webgl-engine/effects/geometry/olidUtils.js";import{CullFaceOptions as ae}from"../../webgl-engine/lib/basicInterfaces.js";import{VertexAttribute as ne}from"../../webgl-engine/lib/VertexAttribute.js";import{LodRenderer as le}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{DefaultMaterial as ce}from"../../webgl-engine/materials/DefaultMaterial.js";import{schematicMRRFactors as he}from"../../webgl-engine/materials/pbrUtils.js";class de{constructor(e,t,s,r,i,o,a,n,l,c,h=null){this.lodResources=e,this.lodRenderer=t,this.stageResources=s,this.resourceSize=r,this.isEsriSymbolResource=i,this.isWosr=o,this.resourceBoundingBox=a,this.symbolSize=n,this.extentPadding=l,this.physicalBasedRenderingEnabled=c,this.pivotOffset=h}}class me extends V{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,fe(t)),this._resources=null,this._optionalFields=new Array,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=M(this.symbolLayer);if(e)throw new Error(e)}if(this._isPrimitive){const t=this.symbolLayer.resource,s=t&&Z(t?.primitive)?t.primitive:O;this._resources=await this._createResourcesForPrimitive(s,e)}else{const t=await X(this.symbol.styleOrigin),s=t?.href??this.symbolLayer.resource?.href;this._resources=await this._createResourcesForUrl(s,e)}this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicalBasedRenderingChanged(),this.complexity=this.computeComplexity()}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,r){const i=this.symbolLayer,o=S(U(t)),a=f(E(o)),n=f(T(a,i)),h=l(n),d=!1,m=!1,p=i?.material,u=p?.emissiveFactor,b=u?c(y(u)):_,R={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,mrrFactors:he,ambient:g,diffuse:g,opacity:1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:i.castShadows,emissiveFactor:b,offsetTransparentBackfaces:!1,drivenOpacity:this.needsDrivenTransparentPass},v=!!R.usePBR,L=p?.color,C=this.symbol;if("point-3d"===C.type&&C.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=C.verticalOffset;R.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0},R.castShadows=!1}if(this._context.screenSizePerspectiveEnabled&&(R.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),this._drivenProperties.color)R.externalColor=P;else{const t=null!=L?e.toUnitRGBA(L):this._drivenProperties.opacity?P:x;R.externalColor=t}this._fastUpdates=ee(this._context.renderer,this._fastVisualVariableConvertOptions(o,n,a,null)),R.isInstanced=!0,this._fastUpdates?(Object.assign(R,this._fastUpdates.materialParameters),this._optionalFields.push(ne.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(R.hasInstancedColor=!0,this._optionalFields.push(ne.COLOR)),oe()&&this._optionalFields.push(ne.OBJECTANDLAYERIDCOLOR);const w=new ce(R,this._context);w.setParameters({cullFace:ye(w.transparent)});const j=K(t,w);if(!j)throw new Error(`Unknown object symbol primitive: ${t}`);const O=await this._createStageResources(j,v,r),B=await this._createLodRenderer(j,r);return new de(j,B,O,a,d,m,o,n,h,v)}async _createResourcesForUrl(e,t){const r={isInstanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},i={spherical:this._context.spherical,materialParameters:r,streamDataRequester:this._context.streamDataRequester,cache:this._context.sharedResources.objectResourceCache};this._fastUpdates=ee(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(i.materialParameters,this._fastUpdates.materialParameters),this._optionalFields.push(ne.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(i.materialParameters.hasInstancedColor=!0,this._optionalFields.push(ne.COLOR)),oe()&&this._optionalFields.push(ne.OBJECTANDLAYERIDCOLOR);const o=this.symbol;if("point-3d"===o.type&&o.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=o.verticalOffset;i.materialParameters.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0},i.materialParameters.castShadows=!1}const a=this._context.physicalBasedRenderingEnabled;i.signal=t,i.usePBR=a,i.skipHighLods=this._context.skipHighSymbolLods;const n=await J(e,i),c=n.isEsriSymbolResource,h=n.isWosr,d=N(n.lods),m=this._context,p=this.symbolLayer.material,u=this._getExternalColorParameters(p),y=this.needsDrivenTransparentPass,_=d.getMaterials();_.forEach((e=>{e.setParameters({...u,drivenOpacity:y}),m.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:m.sharedResources.screenSizePerspectiveSettings})}));const g=n.referenceBoundingBox,b=f(E(g)),R=f(d.levels[0].pivotOffset),P=f(T(b,this.symbolLayer)),x=l(P),v=this._fastUpdates;te(v,this._context.renderer,this._fastVisualVariableConvertOptions(g,P,b,R))&&_.forEach((e=>e.setParameters(v.materialParameters)));const L=await this._createStageResources(d,a,t),C=await this._createLodRenderer(d,t);return new de(d,C,L,b,c,h,g,P,x,a,R)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(e,s,r){const i=this._context.stage,o=e.getMaterials();s!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged(),i.addMany(o),this._addDisposeResource((()=>i.removeMany(o)));const a=e.getTextures();i.addMany(a),this._addDisposeResource((()=>{a.forEach((e=>e.unload())),i.removeMany(a)})),await Promise.all(a.map((e=>this._context.stage.schedule((()=>e.load(i.renderView.renderingContext)),r)))),t(r);const n=e.getEngineGeometries();return i.addMany(n),this._addDisposeResource((()=>i.removeMany(n))),{materials:o,textures:a,geometries:n}}async _createLodRenderer(e,t){const s=this._context.stage,r={layerUid:this._context.layer.uid,graphicUid:e=>this._instanceIndexToGraphicUid.get(e),notifyGraphicGeometryChanged:e=>this._context.notifyGraphicGeometryChanged(this._instanceIndexToGraphicUid.get(e)),notifyGraphicVisibilityChanged:e=>this._context.notifyGraphicVisibilityChanged(this._instanceIndexToGraphicUid.get(e))},i=this._fastUpdates,o=i?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,Re),a(s,re(i.materialParameters,Re,s))},scaleFactor:(e,t,s)=>{t.getFeatureAttribute(s,Re),ie(e,i.materialParameters,Re)}}:null,n=new le({symbol:e,optionalFields:this._optionalFields,metadata:r,shaderTransformation:o},this._context.scheduler);return n.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource((()=>{s.removeRenderPlugin(n),n.destroy()})),await s.addRenderPlugin(n,t),n}_getExternalColorParameters(t){const s={};return this._drivenProperties.color?s.externalColor=P:null!=t?.color?s.externalColor=e.toUnitRGBA(t.color):(s.externalColor=P,s.colorMixMode="ignore"),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=Y(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for object symbol: ${t.geometry.type}`),null;const r=this.setGraphicElevationContext(t),i=e.renderingInfo;return this._createAs3DShape(t,s,i,r,t.uid,e.layer.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(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:ye(r.transparent)})}}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,A)}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 W.RecreateSymbol;const{stageResources:{materials:s},lodRenderer:r,resourceBoundingBox:i,symbolSize:o,resourceSize:a,pivotOffset:n}=this._resources;for(const l in e.diff){if("visualVariables"!==l)return W.RecreateSymbol;if(!te(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,o,a,n)))return W.RecreateSymbol;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return W.FastUpdate}computeComplexity(){if(null==this._resources)return super.computeComplexity();const e=this._resources.lodResources,t=B(e.levels),s=e.computeUsedMemory(),r={...G(this.symbol,this.symbolLayer),resourceBytes:s};return new Q({verticesPerFeature:t,memory:r})}_hasLodRenderer(){return null!=this._resources}_createAs3DShape(e,t,s,r,i,o){if(!this._hasLodRenderer()||null==this._resources)return null;const a=this.getFastUpdateAttrValues(e),n=this._context.clippingExtent;if(C(t,_e,this._context.elevationProvider.spatialReference),null!=n&&!w(n,_e))return null;const l=ue(r),c=this._computeGlobalTransform(t,r,be,Pe),h=this._computeLocalTransform(this._resources,this.symbolLayer,s,ge),d=this._resources.lodRenderer.instanceData,m=d.addInstance();if(this._instanceIndexToGraphicUid.set(m,i),d.setLocalTransform(m,h,!1),d.setGlobalTransform(m,c),a&&d.setFeatureAttribute(m,a),null==this._fastUpdates&&this._hasPerInstanceColor()){const e=this._getVertexOpacityAndColor(s,this._getFallbackOpacityAndColor(),255);d.setColor(m,e)}const p=this._context.stage.renderView.olidRenderHelper;p&&d.setObjectAndLayerIdColor(m,p.getObjectAndLayerIdColor({graphicUid:i,layerUid:o}));const u=new z(this,m,I,r,this._context.stage.view.state.highlightOrderMap);return l&&(u.alignedSampledElevation=Pe.sampledElevation),u.needsElevationUpdates=A(r.mode),$(u,t,this._context.elevationProvider),u}_computeGlobalTransform(e,t,s,r){return D(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),_e[0]=e.x,_e[1]=e.y,_e[2]=r.z,L(e.spatialReference,_e,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,o=k(r,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);1===o[0]&&1===o[1]&&1===o[2]||i(s,s,o)}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=t&&Y(t);if(null==s)return!1;const r=this.getGeometryElevationMode(t);return e.elevationContext.mode===r&&(this._computeGlobalTransform(s,e.elevationContext,be,Pe),ue(e.elevationContext)&&(e.alignedSampledElevation=Pe.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(e.instanceIndex,be,!0),$(e,s,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!(t.heading||t.tilt||t.roll||t.width||t.height||t.depth||t.anchor||t.anchorPosition))return;if(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),o=s(t.roll,this.symbolLayer.roll,0),a=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:o,anchor:c,anchorPosition:h},m=this._resources;this.loadStatus===q.LOADED&&e.symbolLayerStatePatches.push((()=>{m.symbolSize=f(T(m.resourceSize,{width:a,height:n,depth:l,isPrimitive:this._isPrimitive}))})),e.graphics3DGraphicPatches.push((({instanceIndex:e},t)=>{const s=this._computeLocalTransform(m,d,t,ge);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,o=null!=i?e.toUnitRGBA(i):P;delete r.color;const a=this._resources;if(null==a)return;const n=this._isPrimitive;t.graphics3DGraphicPatches.push((({instanceIndex:e})=>{if(this._hasPerInstanceColor())a.lodRenderer.instanceData.setColor(e,o);else{const e={externalColor:o};for(const t of a.stageResources.materials)t.setParameters(e),n&&t.setParameters({cullFace:ye(t.transparent)})}}))}_applyObjectRotation(e,t,s){if(!this._fastUpdates?.requiresShaderTransformation||!t)return H(e.heading,e.tilt,e.roll,s)}_applyAnchor(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=pe(e.resourceBoundingBox,e.pivotOffset,t);r&&o(s,s,r)}_hasPerInstanceColor(){return this._drivenProperties.color||this._drivenProperties.opacity}_fastVisualVariableConvertOptions(e,t,s,r){const i=null!=e?f(E(e)):g,o=null!=e?pe(e,r,this.symbolLayer):_,a=this._context.renderCoordsHelper.unitInMeters,n=k(null!=t?t:void 0,t,s,a),l=b(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return new se({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:i,symbolSize:t??g,unitInMeters:a,anchor:o,scale:n,rotation:l,fallbackColor:this._getFallbackOpacityAndColor(),fallbackSize:n})}get _primitive(){const{resource:e}=this.symbolLayer;return null!=e?.href?null:e?.primitive??O}_getFallbackOpacityAndColor(){const t=this.symbolLayer.material?.color;if(null==t){return null==this._primitive?P:x}return e.toUnitRGBA(t)}}function pe(e,t,s){const r=R();switch(s.anchor){case"center":d(r,j(e)),h(r,r);break;case"top":{const t=j(e);u(r,-t[0],-t[1],-e[5]);break}case"bottom":{const t=j(e);u(r,-t[0],-t[1],-e[2]);break}case"relative":{const t=j(e),i=E(e),o=s.anchorPosition,a=o?b(o.x,o.y,o.z):_;m(r,i,a),p(r,r,t),h(r,r);break}default:null!=t?h(r,t):d(r,_)}return r}function ue(e){return"absolute-height"!==e.mode}function fe(e){return 1===(e.material?.color?.a??1)&&null==e.resource?.href}function ye(e){return e?ae.None:ae.Back}const _e=R(),ge=n(),be=n(),Re=v(),Pe=new F;export{me as Graphics3DObjectSymbolLayer};
|