@arcgis/core 5.0.0-next.38 → 5.0.0-next.39
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/Color.js +1 -1
- package/analysis/DimensionSimpleStyle.js +1 -1
- package/analysis/ElevationProfileAnalysis.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/02a65563779b4c64b2cf.js +1 -0
- package/assets/esri/core/workers/chunks/{328106e181e5957ceaa5.js → 09ac2bbc7327e6e6b5a2.js} +1 -1
- package/assets/esri/core/workers/chunks/1a9ed3c59a9a8bafb251.js +1 -0
- package/assets/esri/core/workers/chunks/{b96af22ec1470905e4fb.js → 1c857191e5898aba50fe.js} +1 -1
- package/assets/esri/core/workers/chunks/{3904f8732c9953cb177d.js → 28b235b56a83c498d73f.js} +1 -1
- package/assets/esri/core/workers/chunks/36d15c35fbbd4dedd5cb.js +1 -0
- package/assets/esri/core/workers/chunks/48f805929fe6241952f5.js +1 -0
- package/assets/esri/core/workers/chunks/4c278fb2d51ca6226050.js +1 -0
- package/assets/esri/core/workers/chunks/6052eccb9395c8efb295.js +1 -0
- package/assets/esri/core/workers/chunks/{50ffb22c48fadd36c748.js → 613cbac9cb925cd20b48.js} +1 -1
- package/assets/esri/core/workers/chunks/{febce0d80f019dc2a427.js → 646f58b69d2354f1ef27.js} +1 -1
- package/assets/esri/core/workers/chunks/7eab0bb42f9f062522ef.js +1 -0
- package/assets/esri/core/workers/chunks/{5e34a183420e7007a989.js → 8e8d5422f57269d8c8d2.js} +1 -1
- package/assets/esri/core/workers/chunks/9100330ed4b4437c819d.js +1 -0
- package/assets/esri/core/workers/chunks/95cb062cae4c31c07124.js +1 -0
- package/assets/esri/core/workers/chunks/{7ab237d19b84d89ff483.js → 96f798ee286b59396131.js} +50 -50
- package/assets/esri/core/workers/chunks/{e9bc3c6482ba778c9349.js → 9d95f38da21f97214f83.js} +1 -1
- package/assets/esri/core/workers/chunks/ad4fcb73cfe9a1e4b710.js +1 -0
- package/assets/esri/core/workers/chunks/{a8a017d7969562d21d2e.js → b48aceaeefa07214e430.js} +1 -1
- package/assets/esri/core/workers/chunks/c1a4d1ec0125617374b4.js +1 -0
- package/assets/esri/core/workers/chunks/{d2a6f035022a3f060ffa.js → c320a29df40e85fb4a8e.js} +1 -1
- package/assets/esri/core/workers/chunks/{27ec791318e81285c222.js → dca6a61fd239cf1ff90c.js} +1 -1
- package/assets/esri/core/workers/chunks/{2f9129003f77bfeab2f9.js → e66bcdfd75e0113d1cec.js} +1 -1
- package/assets/esri/core/workers/chunks/f1381c5a2a1de1ef9139.js +1 -0
- package/assets/esri/core/workers/chunks/f21cb5b34d4d1e3af1a9.js +1 -0
- package/chunks/ChapmanAtmosphere.glsl.js +20 -20
- package/chunks/HUDMaterial.glsl.js +38 -38
- package/chunks/Haze.glsl.js +23 -23
- package/config.js +1 -1
- package/core/Collection.js +1 -1
- package/core/CollectionFlattener.js +1 -1
- package/core/arrayUtils.js +1 -1
- package/interfaces.d.ts +50 -0
- package/kernel.js +1 -1
- package/layers/ImageryTileLayer.js +1 -1
- package/layers/RouteLayer.js +1 -1
- package/layers/support/FeatureReductionCluster.js +1 -1
- package/layers/support/LabelClass.js +1 -1
- package/package.json +3 -3
- package/renderers/FlowRenderer.js +1 -1
- package/renderers/HeatmapRenderer.js +1 -1
- package/renderers/PieChartRenderer.js +1 -1
- package/rest/route/utils.js +1 -1
- package/rest/support/PointBarrier.js +1 -1
- package/rest/support/Stop.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/Font.js +1 -1
- package/symbols/IconSymbol3DLayer.js +1 -1
- package/symbols/LineSymbol.js +1 -1
- package/symbols/LineSymbol3DLayer.js +1 -1
- package/symbols/MarkerSymbol.js +1 -1
- package/symbols/PictureFillSymbol.js +1 -1
- package/symbols/PictureMarkerSymbol.js +1 -1
- package/symbols/TextSymbol.js +1 -1
- package/symbols/TextSymbol3DLayer.js +1 -1
- package/symbols/callouts/LineCallout3D.js +1 -1
- package/symbols/edges/Edges3D.js +1 -1
- package/symbols/support/Symbol3DIconOutline.js +1 -1
- package/symbols/support/Symbol3DOutline.js +1 -1
- package/symbols/support/Symbol3DVerticalOffset.js +1 -1
- package/views/2d/layers/RouteLayerView2D.js +1 -1
- package/views/2d/layers/support/RouteLayerInteraction.js +1 -1
- package/views/2d/layers/support/util.js +1 -1
- package/views/3d/camera/intersectionUtils.js +1 -1
- package/views/3d/environment/ChapmanApproximation.glsl.js +8 -8
- package/views/3d/environment/ChapmanAtmosphere.glsl.js +1 -1
- package/views/3d/environment/ChapmanRaymarching.glsl.js +16 -15
- package/views/3d/layers/graphics/Deconflictor.js +1 -1
- package/views/3d/layers/graphics/Graphics3DGraphic.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObject3DGraphicLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
- package/views/3d/state/NearFarHeuristic.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/hud/HUD.glsl.js +12 -12
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBuffer.js +1 -1
- package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferLayout.js +1 -1
- package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferUtils.js +5 -0
- package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBuffer.js +5 -0
- package/views/3d/webgl-engine/shaders/TerrainTechnique.js +1 -1
- package/views/View.js +1 -1
- package/views/analysis/ElevationProfile/ElevationProfileTool.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/layers/GroupLayerView.js +1 -1
- package/views/support/Scheduler.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageOverlays.js +1 -1
- package/widgets/ScaleRangeSlider.js +1 -1
- package/widgets/Slider.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/1d877c3c96c40eab906c.js +0 -1
- package/assets/esri/core/workers/chunks/22f745539ca54d8cd30d.js +0 -1
- package/assets/esri/core/workers/chunks/42f3e83826b3a3dedaaa.js +0 -1
- package/assets/esri/core/workers/chunks/44471962c30344dfafdf.js +0 -1
- package/assets/esri/core/workers/chunks/8ca83a9af9d24b192128.js +0 -1
- package/assets/esri/core/workers/chunks/9527f1a611557a7af237.js +0 -1
- package/assets/esri/core/workers/chunks/ad3a4d139613b4c0e0b4.js +0 -1
- package/assets/esri/core/workers/chunks/c1c77a00f639eaee9c0d.js +0 -1
- package/assets/esri/core/workers/chunks/c8d2cce4a426c72ab173.js +0 -1
- package/assets/esri/core/workers/chunks/e3be67c762af672ec602.js +0 -1
- package/assets/esri/core/workers/chunks/eefad79be500667af96e.js +0 -1
- package/assets/esri/core/workers/chunks/f8caceeaa14d99c35526.js +0 -1
- package/assets/esri/core/workers/chunks/f919f0db9f9ec0c649b9.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as i}from"tslib";import t from"../../../../core/Accessor.js";import{lerp as e}from"../../../../core/mathUtils.js";import{destroyMaybe as s}from"../../../../core/maybe.js";import{property as r,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{transpose as c}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{p as l,j as h,h as u,d}from"../../../../chunks/vec32.js";import{ZEROS as p,create as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c as y,t as f,s as g}from"../../../../chunks/vec42.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as v}from"../../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as b}from"../../../../geometry/ellipsoidUtils.js";import{create as O,empty as w,copy as D,offset as G,width as I,height as j,expand as k}from"../../../../geometry/support/aaBoundingRect.js";import{e as Q,a as P,d as C}from"../../../../chunks/boundedPlane.js";import{create as S}from"../../../../geometry/support/ray.js";import{Sphere as T,sphereCSO as V}from"../../../../geometry/support/sphere.js";import{DeconflictAABR as x}from"./DeconflictAABR.js";import{prepare as R,drawPoly as A}from"./deconflictorDebug.js";import U from"../../webgl/RenderCamera.js";import{GPUPointOcclusionQuery as H}from"../../webgl-engine/lib/GPUPointOcclusionQuery.js";import{SeparateScreenSizePerspectiveEvaluators as M}from"../../webgl-engine/lib/screenSizePerspectiveUtils.js";import{HUDMaterial as N}from"../../webgl-engine/materials/HUDMaterial.js";import{Yield as E}from"../../../support/Yield.js";const z=_(),F=_(),B=m(),W=m(),L=_(),q=n(),Y=new T,J=S(),K=_(),X=O();class Z{constructor(i){this.id=i,this.aabr=O(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.culled=!1,this.visible=!1,this.priority=0}}function $(i,t){const e=0!==i.distanceToOccluder&&i.distance>i.distanceToOccluder,s=0!==t.distanceToOccluder&&t.distance>t.distanceToOccluder;return e!==s?+e-+s:i.priority!==t.priority?t.priority-i.priority:i.distance!==t.distance?i.distance-t.distance:i.visible!==t.visible?+t.visible-+i.visible:i.id-t.id}class ii{constructor(i,t){this.graphics3DGraphic=i,this.slicePlaneEnabled=t,this._info=null,this._labelInfo=null}ensureInfo(i){let t=this.getInfo(i);return t||(t=new Z(this.graphics3DGraphic.graphic.uid),this._setInfo(i,t)),t}getInfo(i){return 16===i?this._labelInfo:this._info}removeInfo(i){this._setInfo(i,null)}_setInfo(i,t){16===i?this._labelInfo=t:this._info=t}}class ti{constructor(){this.camera=new U,this.slicePlane=P(),this.slicePlaneEnabled=!1}copyFrom(i){this.camera.equals(i.camera)||this.camera.copyFrom(i.camera),C(i.slicePlane,this.slicePlane),this.slicePlaneEnabled=i.slicePlaneEnabled}}let ei=class extends t{get dirty(){return this._dirty}get state(){return this._state}constructor(i){super(i),this._dirty=!1,this._viewState=new ti,this._state=0,this._checkOcclusion=new Map,this._active=new Map,this._checkOcclusionIterator=null,this._activeIterator=null,this._occlusionQueryUids=new Array,this._updatingHandles=new v,this._deconflictor=new x((i,t)=>{i.visible=t,this._setGraphicVisibility(this._active.get(i.id),t)},(i,t)=>i.id!==t.id,$),this._baseOccludedVisibility=10,this._altitudeFactor=2,this._minAltitudeDifference=100}initialize(){this._updatingHandles.add(()=>(this.view?.map?.ground?.opacity??0)>0,()=>this.setDirty()),this._updatingHandles.add(()=>this.view.ready,()=>{this._occlusionQuery=null,this.setDirty()})}destroy(){this._occlusionQuery=null,this._updatingHandles.destroy(),this._deconflictor.destroy(),this._checkOcclusion.clear(),this._active.clear()}setDirty(){!this._dirty&&(this._active.size>0||this._checkOcclusion.size>0)&&(this._dirty=!0,this.notifyChange("_readyToRun"))}setPriority(i,t){const e=this._active.get(i.graphic.uid)?.getInfo(this.visibilityGroup);e&&(e.priority=t)}get _readyToRun(){return 0!==this._state||this._dirty}get updating(){return this._readyToRun||this._updatingHandles.updating}get updatingProgress(){if(!this.updating)return 1;const i=this._state/5;return this._dirty?.5*i:i}get readyToRun(){return this.view.ready&&null!=this.view.state&&this._readyToRun}get usedMemory(){return this._occlusionQuery?.usedMemory??0+4*(this._occlusionQueryUids?.length??0)}runTask(i){switch(this._state){case 0:this._startUpdate(),i.madeProgress();case 1:if(this._state=1,!this._processCheckOcclusion(i))return;case 2:if(this._state=2,this._occlusionQuery&&!this._occlusionQuery.done)return E;this._readOcclusionQueryResult(),i.madeProgress();case 3:if(this._state=3,!this._collectActiveGraphics(i))return;case 4:if(this._state=4,this._deconflictor.run(i),!this._deconflictor.done)return;default:this._state=0,this.notifyChange("_readyToRun")}}setGraphicsActive(i,t){t?i.forEach(i=>this.addToActiveGraphics(i)):i.forEach(i=>this.removeFromActiveGraphics(i))}layerSupportsDeconfliction(i){if(null==i||"object3d"!==i.type)return!1;const t=i.stageObject;if(1!==(t?.geometries.length??0))return!1;const e=t?.geometries[0],s=e?.material;return s instanceof N}_startUpdate(){R(this.view),this._dirty=!1,this._viewState.copyFrom(this.viewState);const{fullWidth:i,fullHeight:t}=this._viewState.camera;this._deconflictor.reset(i,t),this._resetIterators(),this._occlusionQueryUids.length=0,this._checkOcclusion.size||(this._occlusionQuery=s(this._occlusionQuery))}addToActiveGraphics(i){i.ensureInfo(this.visibilityGroup),this._active.set(i.graphics3DGraphic.graphic.uid,i),this.setDirty()}removeFromActiveGraphics(i){si(i,this.visibilityGroup),i.removeInfo(this.visibilityGroup),this._active.delete(i.graphics3DGraphic.graphic.uid),this.setDirty()}addToCheckOcclusion(i){this._checkOcclusion.set(i.graphics3DGraphic.graphic.uid,i),this.setDirty()}removeFromCheckOcclusion(i){this._checkOcclusion.delete(i.graphics3DGraphic.graphic.uid)}_processCheckOcclusion(i){if(0===this._checkOcclusion.size)return!0;const t=this._ensureCheckOcclusionIterator(),e=this._viewState.camera,r=c(q,e.viewInverseTransposeMatrix),o=this.view.map.ground.opacity>0,n="global"===this.view.viewingMode&&o&&e.relativeElevation>0?Y:null;let a=0;null!=n&&(l(n.center,p,e.viewMatrix),n.radius=b(this.view.spatialReference).radius,a=V.distanceToSilhouette(n,p));const h=O();for(;;){if(i.done)return!1;i.madeProgress();const s=t.next();if(!0===s.done)break;const o=s.value,c=o.graphics3DGraphic;if(c.destroyed)continue;if(!c.isVisible(1,8))continue;const u=ni(c,this.visibilityGroup);let d=null,p=!0;for(const i of u){if(!this.layerSupportsDeconfliction(i))continue;d=ai,this._projectHudLayer(i,e,d),w(h);const t=i.stageObject.geometries[0].material;if(this._expandBoundingRect(h,e,i,t,d),d.isOutsideScreen){p=!1;break}if(this._isCulledBySlice(o,d.positionView)){p=!1;break}if(null!=n&&ci(d,n,a)){p=!1;break}l(F,d.positionView,r),d.altitude=this.view.renderCoordsHelper.getAltitude(F);const s=o.ensureInfo(this.visibilityGroup);if(s.altitude=d.altitude,s.distance=d.distance,s.distanceToOccluder=d.distanceToOccluder,s.culled=!1,D(s.aabr,h),t.parameters.occlusionTest)break;this._ensureOcclusionQuery().addPosition(F)===this._occlusionQueryUids.length&&this._occlusionQueryUids.push(c.graphic.uid);break}if(this._active.has(c.graphic.uid)&&(!p||!d)){const i=o.ensureInfo(this.visibilityGroup);i.visible=!d,i.culled=!0}}return this._checkOcclusionIterator=null,this._occlusionQueryUids.length||(this._occlusionQuery=s(this._occlusionQuery)),this._occlusionQuery?.start(),!0}_readOcclusionQueryResult(){if(!this._occlusionQuery||!this._occlusionQueryUids.length)return;const i=this._viewState.camera,t=this.view.renderCoordsHelper.getAltitude(i.eye);for(let e=0;e<this._occlusionQueryUids.length;e++){const i=this._occlusionQueryUids[e],s=this._checkOcclusion.get(i);if(!s)continue;const r=this._occlusionQuery.getOcclusion(e)??-1,o=s.getInfo(this.visibilityGroup);o&&(o.distanceToOccluder=r>0?o.distance-r:0);const c=r<=0||this._occludedVisibility(o?.distanceToOccluder??0,o?.distance??r,o?.altitude??0,t);this._active.has(i)?o&&(o.culled=!c,o.visible=c):this._setGraphicVisibility(s,c)}this._occlusionQueryUids.length=0}_collectActiveGraphics(i){const t=this._ensureActiveGraphicsIterator(),e=16===this.visibilityGroup;for(;!i.done;){i.madeProgress();const s=t.next();if(!0===s.done)return this._activeIterator=null,!0;const r=s.value,o=r.getInfo(this.visibilityGroup);if(!o)continue;!(!e||r.graphics3DGraphic.isVisible())||o.culled?(A(o.aabr,!1,!0),this._setGraphicVisibility(r,o.visible)):this._deconflictor.add(o)}return!1}_occludedVisibility(i,t,e,s){const r=Math.max(this._minAltitudeDifference,Math.abs(e-s))-this._minAltitudeDifference;return 0===i||t-i<=this._baseOccludedVisibility+this._altitudeFactor*r}_resetIterators(){this._checkOcclusionIterator=null,this._activeIterator=null}_ensureCheckOcclusionIterator(){return this._checkOcclusionIterator??=this._checkOcclusion.values(),this._checkOcclusionIterator}_ensureActiveGraphicsIterator(){return this._activeIterator??=this._active.values(),this._activeIterator}_ensureOcclusionQuery(){return this._occlusionQuery??=new H({view:this.view}),this._occlusionQueryUids.length||this._occlusionQuery.init(this._checkOcclusion.size,this._viewState.camera.eye),this._occlusionQuery}_projectHudLayer(i,t,e){const s=i.stageObject,r=s.geometries[0],o=r.material;l(z,s.boundingVolumeWorldSpace.bounds.center,t.viewMatrix);const c=r.attributes,n=c.get("normal").data,a=c.get("centerOffsetAndDistance").data;o.applyShaderOffsetsView(z,n,s.transformation,a,t,e.screenSizePerspectiveEvaluators,z),y(B,z[0],z[1],z[2],1),f(W,B,t.projectionMatrix),h(e.positionNDC,W,1/W[3]),o.applyShaderOffsetsNDC(e.positionNDC,a,t,e.positionNDC,L),e.distanceWithoutPolygonOffset=t.depthNDCToWorld(L[2]),e.distance=L[2]===e.positionNDC[2]?e.distanceWithoutPolygonOffset:t.depthNDCToWorld(e.positionNDC[2]),y(W,e.positionNDC[0],e.positionNDC[1],e.positionNDC[2],1),f(B,W,t.inverseProjectionMatrix),g(B,B,1/B[3]),u(e.positionView,z[0],z[1],z[2])}_isCulledBySlice(i,t){return i.slicePlaneEnabled&&this._viewState.slicePlaneEnabled&&Q(this._viewState.slicePlane,t)}_expandBoundingRect(i,t,s,r,{positionNDC:o,screenSizePerspectiveEvaluators:c}){const n=s.getScreenSize(ri);c.evaluator.applyVec2(n,n),n[0]*=t.pixelRatio,n[1]*=t.pixelRatio;const a=G(r.calculateRelativeScreenBounds(n,c.alignmentEvaluator.apply(t.pixelRatio),X),e(0,t.fullWidth,.5+.5*o[0]),e(0,t.fullHeight,.5+.5*o[1])),l=this.marginFactor;if(0!==l){const i=l*Math.min(I(a),j(a));a[0]-=i,a[1]-=i,a[2]+=i,a[3]+=i}k(i,a,i)}_setGraphicVisibility(i,t){const e=i?.graphics3DGraphic;e&&!e.destroyed&&(e.setVisibilityFlag(this.visibilityGroup,8,t),16===this.visibilityGroup&&this.view.labeler.setLabelGraphicVisibility(e,t))}};function si(i,t){const e=i.graphics3DGraphic;e.destroyed||e.setVisibilityFlag(t,8,!0)}i([r({constructOnly:!0})],ei.prototype,"view",void 0),i([r({type:Boolean,readOnly:!0})],ei.prototype,"_readyToRun",null),i([r({type:Boolean,readOnly:!0})],ei.prototype,"updating",null),i([r({readOnly:!0})],ei.prototype,"_updatingHandles",void 0),ei=i([o("esri.views.3d.layers.graphics.Deconflictor")],ei);const ri=a();class oi{constructor(){this.positionView=_(),this.positionNDC=_(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.distanceWithoutPolygonOffset=0,this.screenSizePerspectiveEvaluators=new M}get isOutsideScreen(){const i=this.positionNDC;return i[0]<-1||i[1]<-1||i[2]<-1||i[0]>=1||i[1]>=1||i[2]>=1}}function ci(i,t,e){return d(J.direction,i.positionView),u(J.origin,0,0,0),!!t.intersectRay(J,K)&&i.distanceWithoutPolygonOffset>e}function ni(i,t){return 16===t?i.labelLayers:i.layers}const ai=new oi;export{ei as Deconflictor,ii as DeconflictorGraphic,ti as DeconflictorViewState};
|
|
5
|
+
import{__decorate as i}from"tslib";import t from"../../../../core/Accessor.js";import{lerp as e}from"../../../../core/mathUtils.js";import{destroyMaybe as s}from"../../../../core/maybe.js";import{property as r,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{transpose as c}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{p as l,j as h,h as u,d}from"../../../../chunks/vec32.js";import{ZEROS as p,create as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c as y,t as f,s as g}from"../../../../chunks/vec42.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as v}from"../../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as b}from"../../../../geometry/ellipsoidUtils.js";import{create as O,empty as w,copy as D,offset as G,width as I,height as j,expand as k}from"../../../../geometry/support/aaBoundingRect.js";import{e as Q,a as P,d as C}from"../../../../chunks/boundedPlane.js";import{create as S}from"../../../../geometry/support/ray.js";import{Sphere as T,sphereCSO as V}from"../../../../geometry/support/sphere.js";import{DeconflictAABR as x}from"./DeconflictAABR.js";import{prepare as R,drawPoly as A}from"./deconflictorDebug.js";import U from"../../webgl/RenderCamera.js";import{GPUPointOcclusionQuery as H}from"../../webgl-engine/lib/GPUPointOcclusionQuery.js";import{SeparateScreenSizePerspectiveEvaluators as M}from"../../webgl-engine/lib/screenSizePerspectiveUtils.js";import{HUDMaterial as N}from"../../webgl-engine/materials/HUDMaterial.js";import{Yield as E}from"../../../support/Yield.js";const z=_(),F=_(),B=m(),W=m(),L=_(),q=n(),Y=new T,J=S(),K=_(),X=O();class Z{constructor(i){this.id=i,this.aabr=O(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.culled=!1,this.visible=!1,this.priority=0}}function $(i,t){const e=0!==i.distanceToOccluder&&i.distance>i.distanceToOccluder,s=0!==t.distanceToOccluder&&t.distance>t.distanceToOccluder;return e!==s?+e-+s:i.priority!==t.priority?t.priority-i.priority:i.distance!==t.distance?i.distance-t.distance:i.visible!==t.visible?+t.visible-+i.visible:i.id-t.id}class ii{constructor(i,t){this.graphics3DGraphic=i,this.slicePlaneEnabled=t,this._info=null,this._labelInfo=null}ensureInfo(i){let t=this.getInfo(i);return t||(t=new Z(this.graphics3DGraphic.graphic.uid),this._setInfo(i,t)),t}getInfo(i){return 16===i?this._labelInfo:this._info}removeInfo(i){this._setInfo(i,null)}_setInfo(i,t){16===i?this._labelInfo=t:this._info=t}}class ti{constructor(){this.camera=new U,this.slicePlane=P(),this.slicePlaneEnabled=!1}copyFrom(i){this.camera.equals(i.camera)||this.camera.copyFrom(i.camera),C(i.slicePlane,this.slicePlane),this.slicePlaneEnabled=i.slicePlaneEnabled}}let ei=class extends t{get dirty(){return this._dirty}get state(){return this._state}constructor(i){super(i),this._dirty=!1,this._viewState=new ti,this._state=0,this._checkOcclusion=new Map,this._active=new Map,this._checkOcclusionIterator=null,this._activeIterator=null,this._occlusionQueryUids=new Array,this._updatingHandles=new v,this._deconflictor=new x((i,t)=>{i.visible=t,this._setGraphicVisibility(this._active.get(i.id),t)},(i,t)=>i.id!==t.id,$),this._baseOccludedVisibility=10,this._altitudeFactor=2,this._minAltitudeDifference=100}initialize(){this._updatingHandles.add(()=>(this.view?.map?.ground?.opacity??0)>0,()=>this.setDirty()),this._updatingHandles.add(()=>this.view.ready,()=>{this._occlusionQuery=null,this.setDirty()})}destroy(){this._occlusionQuery=null,this._updatingHandles.destroy(),this._deconflictor.destroy(),this._checkOcclusion.clear(),this._active.clear()}setDirty(){!this._dirty&&(this._active.size>0||this._checkOcclusion.size>0)&&(this._dirty=!0,this.notifyChange("_readyToRun"))}setPriority(i,t){const e=this._active.get(i.graphic.uid)?.getInfo(this.visibilityGroup);e&&(e.priority=t)}get _readyToRun(){return 0!==this._state||this._dirty}get updating(){return this._readyToRun||this._updatingHandles.updating}get updatingProgress(){if(!this.updating)return 1;const i=this._state/5;return this._dirty?.5*i:i}get readyToRun(){return this.view.ready&&null!=this.view.state&&this._readyToRun}get usedMemory(){return this._occlusionQuery?.usedMemory??0+4*(this._occlusionQueryUids?.length??0)}runTask(i){switch(this._state){case 0:this._startUpdate(),i.madeProgress();case 1:if(this._state=1,!this._processCheckOcclusion(i))return;case 2:if(this._state=2,this._occlusionQuery&&!this._occlusionQuery.done)return E;this._readOcclusionQueryResult(),i.madeProgress();case 3:if(this._state=3,!this._collectActiveGraphics(i))return;case 4:if(this._state=4,this._deconflictor.run(i),!this._deconflictor.done)return;default:this._state=0,this.notifyChange("_readyToRun")}}setGraphicsActive(i,t){t?i.forEach(i=>this.addToActiveGraphics(i)):i.forEach(i=>this.removeFromActiveGraphics(i))}layerSupportsDeconfliction(i){if(null==i||!("hiddenIfDeconflicted"in i)||!i.hiddenIfDeconflicted)return!1;const t=i.stageObject;if(1!==(t?.geometries.length??0))return!1;const e=t?.geometries[0],s=e?.material;return s instanceof N}_startUpdate(){R(this.view),this._dirty=!1,this._viewState.copyFrom(this.viewState);const{fullWidth:i,fullHeight:t}=this._viewState.camera;this._deconflictor.reset(i,t),this._resetIterators(),this._occlusionQueryUids.length=0,this._checkOcclusion.size||(this._occlusionQuery=s(this._occlusionQuery))}addToActiveGraphics(i){i.ensureInfo(this.visibilityGroup),this._active.set(i.graphics3DGraphic.graphic.uid,i),this.setDirty()}removeFromActiveGraphics(i){si(i,this.visibilityGroup),i.removeInfo(this.visibilityGroup),this._active.delete(i.graphics3DGraphic.graphic.uid),this.setDirty()}addToCheckOcclusion(i){this._checkOcclusion.set(i.graphics3DGraphic.graphic.uid,i),this.setDirty()}removeFromCheckOcclusion(i){this._checkOcclusion.delete(i.graphics3DGraphic.graphic.uid)}_processCheckOcclusion(i){if(0===this._checkOcclusion.size)return!0;const t=this._ensureCheckOcclusionIterator(),e=this._viewState.camera,r=c(q,e.viewInverseTransposeMatrix),o=this.view.map.ground.opacity>0,n="global"===this.view.viewingMode&&o&&e.relativeElevation>0?Y:null;let a=0;null!=n&&(l(n.center,p,e.viewMatrix),n.radius=b(this.view.spatialReference).radius,a=V.distanceToSilhouette(n,p));const h=O();for(;;){if(i.done)return!1;i.madeProgress();const s=t.next();if(!0===s.done)break;const o=s.value,c=o.graphics3DGraphic;if(c.destroyed)continue;if(!c.isVisible(1,8))continue;const u=ni(c,this.visibilityGroup);let d=null,p=!0;for(const i of u){if(!this.layerSupportsDeconfliction(i))continue;d=ai,this._projectHudLayer(i,e,d),w(h);const t=i.stageObject.geometries[0].material;if(this._expandBoundingRect(h,e,i,t,d),d.isOutsideScreen){p=!1;break}if(this._isCulledBySlice(o,d.positionView)){p=!1;break}if(null!=n&&ci(d,n,a)){p=!1;break}l(F,d.positionView,r),d.altitude=this.view.renderCoordsHelper.getAltitude(F);const s=o.ensureInfo(this.visibilityGroup);if(s.altitude=d.altitude,s.distance=d.distance,s.distanceToOccluder=d.distanceToOccluder,s.culled=!1,D(s.aabr,h),t.parameters.occlusionTest)break;this._ensureOcclusionQuery().addPosition(F)===this._occlusionQueryUids.length&&this._occlusionQueryUids.push(c.graphic.uid);break}if(this._active.has(c.graphic.uid)&&(!p||!d)){const i=o.ensureInfo(this.visibilityGroup);i.visible=!d,i.culled=!0}}return this._checkOcclusionIterator=null,this._occlusionQueryUids.length||(this._occlusionQuery=s(this._occlusionQuery)),this._occlusionQuery?.start(),!0}_readOcclusionQueryResult(){if(!this._occlusionQuery||!this._occlusionQueryUids.length)return;const i=this._viewState.camera,t=this.view.renderCoordsHelper.getAltitude(i.eye);for(let e=0;e<this._occlusionQueryUids.length;e++){const i=this._occlusionQueryUids[e],s=this._checkOcclusion.get(i);if(!s)continue;const r=this._occlusionQuery.getOcclusion(e)??-1,o=s.getInfo(this.visibilityGroup);o&&(o.distanceToOccluder=r>0?o.distance-r:0);const c=r<=0||this._occludedVisibility(o?.distanceToOccluder??0,o?.distance??r,o?.altitude??0,t);this._active.has(i)?o&&(o.culled=!c,o.visible=c):this._setGraphicVisibility(s,c)}this._occlusionQueryUids.length=0}_collectActiveGraphics(i){const t=this._ensureActiveGraphicsIterator(),e=16===this.visibilityGroup;for(;!i.done;){i.madeProgress();const s=t.next();if(!0===s.done)return this._activeIterator=null,!0;const r=s.value,o=r.getInfo(this.visibilityGroup);if(!o)continue;!(!e||r.graphics3DGraphic.isVisible())||o.culled?(A(o.aabr,!1,!0),this._setGraphicVisibility(r,o.visible)):this._deconflictor.add(o)}return!1}_occludedVisibility(i,t,e,s){const r=Math.max(this._minAltitudeDifference,Math.abs(e-s))-this._minAltitudeDifference;return 0===i||t-i<=this._baseOccludedVisibility+this._altitudeFactor*r}_resetIterators(){this._checkOcclusionIterator=null,this._activeIterator=null}_ensureCheckOcclusionIterator(){return this._checkOcclusionIterator??=this._checkOcclusion.values(),this._checkOcclusionIterator}_ensureActiveGraphicsIterator(){return this._activeIterator??=this._active.values(),this._activeIterator}_ensureOcclusionQuery(){return this._occlusionQuery??=new H({view:this.view}),this._occlusionQueryUids.length||this._occlusionQuery.init(this._checkOcclusion.size,this._viewState.camera.eye),this._occlusionQuery}_projectHudLayer(i,t,e){const s=i.stageObject,r=s.geometries[0],o=r.material;l(z,s.boundingVolumeWorldSpace.bounds.center,t.viewMatrix);const c=r.attributes,n=c.get("normal").data,a=c.get("centerOffsetAndDistance").data;o.applyShaderOffsetsView(z,n,s.transformation,a,t,e.screenSizePerspectiveEvaluators,z),y(B,z[0],z[1],z[2],1),f(W,B,t.projectionMatrix),h(e.positionNDC,W,1/W[3]),o.applyShaderOffsetsNDC(e.positionNDC,a,t,e.positionNDC,L),e.distanceWithoutPolygonOffset=t.depthNDCToWorld(L[2]),e.distance=L[2]===e.positionNDC[2]?e.distanceWithoutPolygonOffset:t.depthNDCToWorld(e.positionNDC[2]),y(W,e.positionNDC[0],e.positionNDC[1],e.positionNDC[2],1),f(B,W,t.inverseProjectionMatrix),g(B,B,1/B[3]),u(e.positionView,z[0],z[1],z[2])}_isCulledBySlice(i,t){return i.slicePlaneEnabled&&this._viewState.slicePlaneEnabled&&Q(this._viewState.slicePlane,t)}_expandBoundingRect(i,t,s,r,{positionNDC:o,screenSizePerspectiveEvaluators:c}){const n=s.getScreenSize(ri);c.evaluator.applyVec2(n,n),n[0]*=t.pixelRatio,n[1]*=t.pixelRatio;const a=G(r.calculateRelativeScreenBounds(n,c.alignmentEvaluator.apply(t.pixelRatio),X),e(0,t.fullWidth,.5+.5*o[0]),e(0,t.fullHeight,.5+.5*o[1])),l=this.marginFactor;if(0!==l){const i=l*Math.min(I(a),j(a));a[0]-=i,a[1]-=i,a[2]+=i,a[3]+=i}k(i,a,i)}_setGraphicVisibility(i,t){const e=i?.graphics3DGraphic;e&&!e.destroyed&&(e.setVisibilityFlag(this.visibilityGroup,8,t),16===this.visibilityGroup&&this.view.labeler.setLabelGraphicVisibility(e,t))}};function si(i,t){const e=i.graphics3DGraphic;e.destroyed||e.setVisibilityFlag(t,8,!0)}i([r({constructOnly:!0})],ei.prototype,"view",void 0),i([r({type:Boolean,readOnly:!0})],ei.prototype,"_readyToRun",null),i([r({type:Boolean,readOnly:!0})],ei.prototype,"updating",null),i([r({readOnly:!0})],ei.prototype,"_updatingHandles",void 0),ei=i([o("esri.views.3d.layers.graphics.Deconflictor")],ei);const ri=a();class oi{constructor(){this.positionView=_(),this.positionNDC=_(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.distanceWithoutPolygonOffset=0,this.screenSizePerspectiveEvaluators=new M}get isOutsideScreen(){const i=this.positionNDC;return i[0]<-1||i[1]<-1||i[2]<-1||i[0]>=1||i[1]>=1||i[2]>=1}}function ci(i,t,e){return d(J.direction,i.positionView),u(J.origin,0,0,0),!!t.intersectRay(J,K)&&i.distanceWithoutPolygonOffset>e}function ni(i,t){return 16===t?i.labelLayers:i.layers}const ai=new oi;export{ei as Deconflictor,ii as DeconflictorGraphic,ti as DeconflictorViewState};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{emptyArray as e}from"../../../../core/arrayUtils.js";import{forEach as t}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import{estimateAttributesMemory as i}from"../../../../core/memoryEstimations.js";import r from"../../../../core/ObjectPool.js";import{scale as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{j as o}from"../../../../chunks/vec32.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import n from"../../../../geometry/Polygon.js";import{projectBoundingRect as
|
|
5
|
+
import{emptyArray as e}from"../../../../core/arrayUtils.js";import{forEach as t}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import{estimateAttributesMemory as i}from"../../../../core/memoryEstimations.js";import r from"../../../../core/ObjectPool.js";import{scale as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{j as o}from"../../../../chunks/vec32.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import n from"../../../../geometry/Polygon.js";import{projectBoundingRect as c}from"../../../../geometry/projection/projectBoundingRect.js";import{empty as h,expandWithAABB as p,allFinite as d,toRect as m,create as y,set as u,zero as g}from"../../../../geometry/support/aaBoundingBox.js";import{create as b,allFinite as f}from"../../../../geometry/support/aaBoundingRect.js";import{equals as _}from"../../../../geometry/support/spatialReferenceUtils.js";import{computeAABR as E}from"../../../../layers/graphics/dehydratedFeatures.js";import{convertFromGeometry as v}from"../../../../layers/graphics/featureConversionUtils.js";const L=new r(()=>y(),e=>u(e,g),null,10,5),j=b();class G{get labelLayers(){return this._labelLayers||e}get extent(){return this._extent}get isElevationSource(){return this.layers.some(e=>e?.isElevationSource)}constructor(e,t,i){this.graphic=e,this.graphics3DSymbol=t,this.layers=i,this._visibleFlags=255,++t.referenced;i.every(e=>e&&"hiddenIfDeconflicted"in e&&e.hiddenIfDeconflicted)&&(this._visibleFlags|=256)}initialize(e){this._layer=e,this._forEachSymbolLayerGraphic(t=>{t.initialize(e),x(this._visibleFlags,1,t)})}destroy(){this._forEachSymbolLayerGraphic(e=>e.destroy()),this._calloutLayer=null,--this.graphics3DSymbol.referenced,this.graphics3DSymbol=null}get destroyed(){return null==this.layers}clearLabelGraphics(){this._forEachLabelGraphic(e=>e.destroy()),this._labelLayers=null}addLabelGraphic(e,t){this._labelLayers||(this._labelLayers=new Array),this._labelLayers.push(e),e.initialize(t),x(this._visibleFlags,16,e)}setCalloutGraphic(e){this._calloutLayer=e,this._layer&&(e.initialize(this._layer),x(this._visibleFlags,1,e))}get calloutLayer(){return this._calloutLayer}get isDraped(){let e=!1;return this._forEachSymbolLayerGraphic(t=>{"draped"===t.type&&(e=!0)}),e}isVisible(e=1,t=0){const i=this._visibleFlags;return S(i,e,t|16*t|(256&i?0:8))}setVisibilityFlag(e,t,i){const r=e*t;return i!==((this._visibleFlags&r)===r)&&(i?this._visibleFlags|=r:this._visibleFlags&=~r,1===e&&this._forEachSymbolLayerGraphic(e=>x(this._visibleFlags,1,e)),this._forEachLabelGraphic(e=>x(this._visibleFlags,16,e)),!0)}getVisibilityFlag(e,t){return 0!==(this._visibleFlags&e*t)}computeExtent(e){if(!this._extent){const t=this.graphic.geometry;if(null==t)return!1;this._extent=b(),E(t,this._extent);const i=t.spatialReference;if(!_(i,e)&&!c(this._extent,i,this._extent,e))return this._extent=null,!1}return!0}getAsOptimizedGeometry(e,t){return this._optimizedGeometry||(this._optimizedGeometry=this._convertGraphicToOptimizedGeometry(this.graphic,e,t)),this._optimizedGeometry}_convertGraphicToOptimizedGeometry(e,t,i){let r=e.geometry;return"mesh"!==r.type&&"extent"!==r.type||(r=n.fromExtent("mesh"===r.type?r.extent:r)),v(r,t,i)}get usedMemory(){let e=i(this.graphic.attributes);return this._forEachSymbolLayerGraphic(t=>e+=t.usedMemory),e}computeAttachmentOrigin(){const e={render:{origin:l(),num:0},draped:{origin:a(),num:0}};for(const t of this.layers)null!=t&&t.computeAttachmentOrigin(e);return e.render.num>1&&o(e.render.origin,e.render.origin,1/e.render.num),e.draped.num>1&&s(e.draped.origin,e.draped.origin,1/e.draped.num),e}async getProjectedBoundingBox(e,i,r,s,a){return a||(a={boundingBox:null,requiresDrapedElevation:!1,screenSpaceObjects:[]}),a.boundingBox?h(a.boundingBox):a.boundingBox=h(),a.requiresDrapedElevation=!1,await t(this.layers,async t=>{if(null==t)return;const o="draped"===t.type?i:e,l=L.acquire(),n=await t.getProjectedBoundingBox(o,r,a.screenSpaceObjects,s,l);isFinite(n[2])&&isFinite(n[5])||(a.requiresDrapedElevation=!0),n&&p(a.boundingBox,l),L.release(l)}),d(a.boundingBox)||f(m(a.boundingBox,j))?a:null}needsElevationUpdates(){for(const e of this.layers)if(null!=e&&("object3d"===e.type||"lod-instance"===e.type)&&e.needsElevationUpdates)return!0;return this._labelLayers?.some(e=>e?.needsElevationUpdates??!1)??!1}alignWithElevation(e,t,i){this._forEachRenderedGraphic(r=>{"object3d"!==r.type&&"lod-instance"!==r.type||r.alignWithElevation(e,t,i)})}alignWithAbsoluteElevation(e,t,i){this._forEachRenderedGraphic(r=>{"object3d"===r.type&&r.alignWithAbsoluteElevation(e,t,i)})}addObjectStateSet(e){this._forEachSymbolLayerGraphic(t=>t.addObjectState(e))}removeObjectState(e){this._forEachSymbolLayerGraphic(t=>t.removeObjectState(e))}updateHighlights(e){this._forEachSymbolLayerGraphic(t=>t.updateHighlights(e))}_forEachGraphicList(e,t){e?.forEach(e=>e&&t(e))}_forEachSymbolLayerGraphic(e){this._forEachGraphicList(this.layers,e),this._calloutLayer&&e(this._calloutLayer)}_forEachLabelGraphic(e){this._forEachGraphicList(this.labelLayers,e)}_forEachRenderedGraphic(e){this._forEachSymbolLayerGraphic(e),this._forEachLabelGraphic(e)}get test(){}}function x(e,t,i){const r=1===t?"hiddenIfDeconflicted"in i&&i.hiddenIfDeconflicted?0:8:256&e?0:8;i.setVisibility(S(e,t,r))}function S(e,t,i=0){const r=(1===t?15:255)&~i;return(e&r)===r}export{G as Graphics3DGraphic};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import{result as t,createTask as r}from"../../../../core/asyncUtils.js";import i from"../../../../core/Error.js";import has from"../../../../core/has.js";import{clone as s}from"../../../../core/lang.js";import{abortMaybe as o,releaseMaybe as a}from"../../../../core/maybe.js";import{throwIfAbortError as n,throwIfAborted as l}from"../../../../core/promiseUtils.js";import{pt2px as c,px2pt as h}from"../../../../core/screenUtils.js";import{numericHash as u}from"../../../../core/string.js";import{dataComponents as m}from"../../../../core/urlUtils.js";import{fromValues as d,create as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as _,create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as y,ZEROS as g,fromValues as x}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectPointToVector as b}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as v}from"../../../../geometry/support/aaBoundingBox.js";import S from"../../../../layers/support/FieldsIndex.js";import{createRendererExpression as P}from"../../../../support/ArcadeExpression.js";import{CIMSymbolHelper as w}from"../../../../symbols/cim/CIMSymbolHelper.js";import{evaluateValueOrFunction as z}from"../../../../symbols/cim/utils.js";import{scaleCIMSymbol as C}from"../../../../symbols/support/cimSymbolUtils.js";import{defaultPrimitive as R}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{Symbol3DAnchorPosition2D as M}from"../../../../symbols/support/Symbol3DAnchorPosition2D.js";import{getIconHref as I}from"../../../../symbols/support/utils.js";import{transparentUnit as O}from"./constants.js";import{perObjectElevationAligner as j}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as T,needsElevationUpdates2D as F}from"./elevationAlignmentUtils.js";import{focusAreaHUDColor as E}from"./focusAreaStyle.js";import{Graphics3DDrapedGraphicLayer as U}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as D}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as V}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as G}from"./graphicUtils.js";import{namedAnchorToHUDMaterialAnchorPos as L}from"./placementUtils.js";import{placePointOnGeometry as A,updateStageObjectGeometry as H,getLocalOriginForPoint as k,extendPointGraphicElevationContext as B,createStageObject as $}from"./pointUtils.js";import{initFastSymbolUpdatesState as N,updateFastSymbolUpdatesState as q,evaluateModelTransformScale as J,ConvertOptions as Z}from"../support/FastSymbolUpdates.js";import{createTexture as W,requiresHalfTexelOffset as K,defaultBoundingBox as Q,defaultSymbolSizeRatio as X,defaultTexSize as Y}from"../../support/engineContent/sdfPrimitives.js";import{drapedZ as ee}from"../../terrain/OverlayRenderer.js";import{VerticalOffsetParameters as te}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{createPointGeometry as re}from"../../webgl-engine/lib/GeometryUtil.js";import{ManagedTexture as ie}from"../../webgl-engine/lib/ManagedTexture.js";import{RenderGeometry as se}from"../../webgl-engine/lib/RenderGeometry.js";import{HUDMaterial as oe}from"../../webgl-engine/materials/HUDMaterial.js";const ae=_(0,0,1),ne=16,le=1.5,ce=[Y*X,Y*X];class he extends V{static{this.PRIMITIVE_SIZE=ce}getCachedSize(){return{size:this._getIconSize()}}static{this.elevationModeChangeTypes={definedChanged:1,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,r,i){super(e,t,r,i,ye(t)),this._cimData=null,this._overrideHelperClass=null,this._arcadeInfo=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimScaleFactorOrFunction=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._textureHandle=null,this._patchTask=null,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),r=this._getPrimitive();if(null!=r)this._prepareResourcesPrimitive(t,r);else{const r=I(this.symbolLayer),i=de(r);null!=i?await this._prepareResourcesCIM(t,JSON.parse(i),e):await this._prepareResourcesHref(t,r,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=G(this._getIconSize());if(e)throw new i("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?c(e.size):ne);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e,t){const r=this._overrideHelperClass;let i=this._cimData;if(r&&i&&i.symbol||this.logger.error("Can't create texture, CIM data is undefined"),i.primitiveOverrides){i=s(i);const o=i.primitiveOverrides;r.evaluateOverrides(o,e,this._arcadeInfo.geometryType,null,null,t.layer.fieldsIndex),r.applyOverrides(i.symbol,o)}const o=u(JSON.stringify(i));let a=this._cimSymbolTextures.get(o);if(a)return a;const n=this._context.sharedResources.cimSymbolRasterizer,l=this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null;l&&r.applyDictionaryTextOverrides(i.symbol,e,l,null);const c=null!=this._cimScaleFactorOrFunction?z(this._cimScaleFactorOrFunction,e):1;1!==c&&i.symbol&&C(i.symbol,c,!0);const h=w.getEnvelope(i,null,n.resourceManager);if(h?.width&&h.height){const e=h.x+h.width/2,t=h.y+h.height/2,r=n.rasterize({type:"cim",data:i},h.width,h.height,e,t,1,"esriGeometryPoint",0,null,this._context.graphicsCoreOwner.view.state.rasterPixelRatio),s=new M({x:-h.x/h.width-.5,y:(h.height+h.y)/h.height-.5});this._cimMaterialParametersInfo.anchorPosition=pe("relative",s),a=new ie(r,{width:r?.width??1,height:r?.height??1,reloadable:!0})}else a=new ie(new ImageData(1,1),{width:1,height:1,reloadable:!0});return this._cimSymbolTextures.set(o,a),this._context.stage.addTexture(a),a}_prepareMaterialParameters(){const e={anchorPosition:pe(this.symbolLayer.anchor,this.symbolLayer.anchorPosition),rotation:this.symbolLayer.angle},t=this.symbol;ue(t)&&(e.verticalOffset=new te(t.verticalOffset)),this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this.view.screenSizePerspective.parameters),(0!==e.rotation||this._drivenProperties.rotation)&&(e.hasRotation=!0);const r=!!has("enable-feature:non-occluded-hud");return e.occlusionTest=!r,e.occludedFragmentFade=r,e.horizonCullingEnabled=r&&this._context.spherical,e.hasSlicePlane=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const r=this._getOutlineSize();if(me(t)&&0===r)throw new Error("Nothing to render");if(this._outlineSize=r,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,null!=this._context.sharedResources.textures){const r=this._context.sharedResources.textures.fromData(`${t}-icon`,()=>W(t));this._textureHandle=r,e.textureId=r.managedTexture.id}e.textureIsSignedDistanceField=!0,e.sampleSignedDistanceFieldTexelCenter=K(t),e.distanceFieldBoundingBox=Q;const i=this._getIconSize();this._size=[i,i],this._symbolTextureRatio=1/X,this._createMaterial(e)}async _prepareResourcesHref(e,r,s){this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),a=o*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(null!=this._context.sharedResources.textures){const l=await t(this._context.sharedResources.textures.fromUrl(r,a,{signal:s}));if(!1===l.ok){n(l.error);throw new i("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${r})`)}this._textureHandle=l.value;const c=l.value.managedTexture;this._size=_e(c,o),e.textureId=c.id}this._createMaterial(e)}async _prepareResourcesCIM(e,t,r){const{OverrideHelper:i}=await import("../../../../symbols/cim/OverrideHelper.js");if(this._overrideHelperClass=i,this._cimData=t,!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;l(r),this._context.sharedResources.cimSymbolRasterizer??=new e(this._context.renderCoordsHelper.spatialReference)}const s=this._context.sharedResources.cimSymbolRasterizer,o=[],a=t,n=a?.symbol;w.fetchResources(n,s.resourceManager,o,r),w.fetchFonts(n,s.resourceManager,o);const c=this._context.layer.fields?this._context.layer.fields.map(e=>e.toJSON()):[],h=this._context.renderCoordsHelper.spatialReference;if(this._arcadeInfo={spatialReference:h,fields:c,geometryType:"esriGeometryPoint"},a?.primitiveOverrides&&o.push(i.createRenderExpressions(a.primitiveOverrides,this._arcadeInfo)),o.length>0&&(await Promise.all(o),l(r)),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(e.scaleExpression){const t=e.scaleExpression,r=await P(t,this._context.layer.spatialReference),{default:i}=await import("../../../2d/arcade/callExpressionWithFeature.js"),s=new S(c);this._cimScaleFactorOrFunction=(e,t,o)=>{const a=i(r,e,{$view:o},"esriGeometryPoint",s,t);return null!==a?a:1}}}l(r),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return fe(this.symbolLayer)}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(null!=t.outline?.size)return Math.max(c(t.outline.size),0);return e=me(this._getPrimitive())?le:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),r=this.symbolLayer,i=r?.outline?.color;if(null!=i){const r=e.toUnitRGB(i),s=i.a*t;return[r[0],r[1],r[2],s]}return[0,0,0,0]}_getFillColor(){if(me(this._getPrimitive()))return O;const e=null==this._getPrimitive(),t=this._materialColor;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}get _materialColor(){return this.symbolLayer.material?.color}get _fastVisualVariableFallbackColor(){const t=this._materialColor;if(null==t){return null==this._getPrimitive()?y:g}return e.toUnitRGBA(t)}_getFallbackSize(){const e=this._getIconSize(),{symbolLayer:{size:t}}=this;return(null!=t?Math.round(c(t)):ne)/e}_createMaterial(e){const t=this._context.spherical;if(this._cimData){this._fastUpdates=null;let r=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;return r||(r=new oe(e,t),this._cimSymbolMaterials.set(e.textureId??0,r)),r}this._fastUpdates=N(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),this._materials[0]=new oe(e,t),e.isFocused=!1;const r=this.view.map?.focusAreas.style;return e.color=E(e.color,r),e.outlineColor=E(e.outlineColor,r),this._materials[1]=new oe(e,t),this._materials[0]}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial(e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,hasSlicePlane:!1,shaderPolygonOffset:0,draped:this.draped})}),this.layerOpacityChanged())}destroy(){super.destroy(),this._patchTask=o(this._patchTask),this._materials.length=0,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach(e=>this._context.stage.removeTexture(e)),this._cimSymbolTextures.clear(),this._textureHandle=a(this._textureHandle)}_getScaleFactor({size:e},t){if(!this._drivenProperties.size)return 1;if(null==e)return this._getFallbackSize();const[r,i,s]=e;return"symbol-value"===r?1:"number"==typeof r&&isFinite(r)?c(r)/t:"number"==typeof s&&isFinite(s)?c(s)/t:1}_getDrivenRotation(e){return this._drivenProperties.rotation?e.heading??0:0}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const r=A(t.geometry);if(null==r)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;let i,s=[0,0];const o=this.view.focusAreasView?.containsGeometry(r)??!0;if(this._cimData){if(!this._cimData.symbol)return null;const r=this._generateTextureCIM(t,e),a={textureId:r.id,isFocused:o,...this._cimMaterialParametersInfo};i=this._createMaterial(a);const n=this._context.graphicsCoreOwner.view.state.rasterPixelRatio;s=[r.parameters.width/n,r.parameters.height/n]}else s=this._size,i=o?this._materials[0]:this._materials[1];if(null==r)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const a=e.renderingInfo,n=this._getDrivenUInt8Color(a,this._materialColor,null==this._getPrimitive()),l=this._getDrivenRotation(a);let c=1;if(!this._fastUpdates?.visualVariables.size){const e=s[0]>s[1]?s[0]:s[1];c=this._getScaleFactor(a,e)}c*=this._symbolTextureRatio;const h=d(s[0]*c,s[1]*c),u=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus("on-the-ground"===u.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,r,i,n,l,h):this._createAs3DShape(t,r,i,n,l,h,u,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial(r=>{r.setParameters({color:e}),r.setParameters({outlineColor:t})})}layerScreenSizePerspectiveChanged(){const e=this._context.screenSizePerspectiveEnabled&&!this.draped?this.view.screenSizePerspective.parameters:null;this._forEachMaterial(t=>{t.setParameters({screenSizePerspective:e})})}updateGeometry(e,t){const r=e.geometry;if(this.draped||!r||!this._validateGeometry(r))return!1;const{elevationContext:i,stageObject:s}=t;if(i.mode!==this.getGeometryElevationMode(r))return!1;const o=A(r);if(!o)return!1;i.updateFeatureExpressionFeature(e,this._context.layer);const a=H(s,this._context,o,i);if(null==a)return!1;const n=k(this._context,o);return s.geometries[0].localOrigin===n&&(t.alignedSampledElevation=a,B(t,o,this._context.elevationProvider),!0)}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=T(he.elevationModeChangeTypes,r,i);if(1!==s)return s;const o=F(i)||"absolute-height"===i;return this.updateGraphics3DGraphicElevationInfo(e,t,()=>o)}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial(e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return null!=this._getPrimitive()}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return 0;if(!q(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return 0;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return 2}get needsUpdateFocus(){return!0}prepareSymbolLayerPatch(e){if(this._patchTask?.abort(),"partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchResource(e,t),this._preparePatchRotation(e,t)}_preparePatchResource(e,s){if(!s.resource||"partial"!==s.resource.type)return;const c=s.resource.diff;if("complete"!==c?.href?.type)return;const h=c.href.newValue,{textures:u}=this._context.sharedResources;if(null==h||null==u||null!=de(h))return;const m=this._getIconSize(),d=m*this._context.graphicsCoreOwner.view.state.pixelRatio;e.symbolLayerStatePatches.push(()=>{this._patchTask=o(this._patchTask),this._patchTask=r(e=>this._context.schedule(async(e,r)=>{const s=await t(u.fromUrl(h,d,{signal:r}));l(r);const o=!s.ok;if(o&&n(s.error),this._textureHandle=a(this._textureHandle),this._patchTask=null,o){this._forEachMaterial(e=>{e.visible=!1,e.setParameters({textureId:null})});const e=`Failed to load (Request for icon resource failed: ${h})`;return void this.logger.error(new i("graphics3diconsymbollayer:request-failed",e))}this._textureHandle=s.value;const c=s.value.managedTexture;this._size=_e(c,m),this._forEachMaterial(e=>{e.setParameters({textureId:c.id}),e.visible=!0})},e))}),delete c.href}_preparePatchRotation(e,t){if(!t.angle||"complete"!==t.angle.type)return;const r=t.angle.newValue??0,i=0!==r||this._drivenProperties.rotation;e.symbolLayerStatePatches.push(()=>{this._forEachMaterial(e=>e.setParameters({rotation:r,hasRotation:i}))}),delete t.angle}_defaultElevationInfoNoZ(){return ge}_createAs3DShape(e,t,r,i,s,o,a,n){const l=this.getFastUpdateAttrValues(e),c=this._context.layerViewUid,h=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerViewUid:c}),u=re(r,{normal:ae,color:i,rotation:s,size:o,centerOffsetAndDistance:xe,featureAttribute:l,olidColor:h}),m=$(this._context,t,u,a,n);if(null==m)return null;const d=new D(this,m.object,null,j,a);return d.alignedSampledElevation=m.sampledElevation,d.needsElevationUpdates=F(a.mode)||"absolute-height"===a.mode,d.getScreenSize=this._createScreenSizeGetter(o,l),d.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(d.getScreenSize(),1,e),B(d,t,this._context.elevationProvider),d}_createAsOverlay(e,t,r,i,s,o){r.renderPriority=this._renderPriority;const a=f();b(t,a,this._context.overlaySR),a[2]=ee;const n=this._context.clippingExtent;if(null!=n&&!v(n,a))return null;const l=this.getFastUpdateAttrValues(e),c=e.uid,h=this._context.layerViewUid,u=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerViewUid:h}),m=re(r,{normal:ae,position:a,color:i,rotation:s,size:o,featureAttribute:l,olidColor:u}),d=new se(m,{layerViewUid:h,graphicUid:c}),p=new U(this,[d],null,this._context.drapeSourceRenderer);return p.getScreenSize=this._createScreenSizeGetter(o,l),p.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(p.getScreenSize(),1,e),p}_createScreenSizeGetter(e,t){const r=this._outlineSize+2;if(this._fastUpdates&&t){const i=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=p())=>{const[o,a]=J(be,this._fastUpdates.materialParameters,t);return e[0]=o*i+r,e[1]=a*s+r,e}}const i=e[0]/this._symbolTextureRatio+r,s=e[1]/this._symbolTextureRatio+r;return(e=p())=>(e[0]=i,e[1]=s,e)}_fastVisualVariableConvertOptions(){const e=Math.max(this._size[0],this._size[1]),t=_(e,e,e),r=h(1),i=e*r,s=_(i,i,i),o=this._getFallbackSize();return new Z({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:t,symbolSize:s,unitInMeters:r,fallbackColor:this._fastVisualVariableFallbackColor,fallbackSize:_(o,o,o)})}_forEachMaterial(e){this._materials.forEach(e),this._cimSymbolMaterials.forEach(e)}test(){return{...super.test(),material:this._materials[0]}}}function ue(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function me(e){return null!=e&&("cross"===e||"x"===e)}function de(e){const t=m(e);return"application/json"===t?.mediaType?t.data:void 0}function pe(e,t){return"relative"===e?d((t.x||0)+.5,.5-(t.y||0)):e in L?L[e]:L.center}function _e({parameters:e},t){const r=(e.width??1)/(e.height??1);return r>1?[t,Math.round(t/r)]:[Math.round(t*r),t]}function fe(e){return e.resource?.href?null:e.resource?.primitive??R}function ye(e){return 1===(e.material?.color?.a??0)&&null!=fe(e)}const ge={mode:"relative-to-ground",offset:0},xe=x(0,0,0,1),be=f();export{he as Graphics3DIconSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import{result as t,createTask as r}from"../../../../core/asyncUtils.js";import i from"../../../../core/Error.js";import has from"../../../../core/has.js";import{clone as s}from"../../../../core/lang.js";import{abortMaybe as o,releaseMaybe as a}from"../../../../core/maybe.js";import{throwIfAbortError as n,throwIfAborted as l}from"../../../../core/promiseUtils.js";import{pt2px as c,px2pt as h}from"../../../../core/screenUtils.js";import{numericHash as u}from"../../../../core/string.js";import{dataComponents as m}from"../../../../core/urlUtils.js";import{fromValues as d,create as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as _,create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as y,ZEROS as g,fromValues as x}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectPointToVector as b}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as v}from"../../../../geometry/support/aaBoundingBox.js";import S from"../../../../layers/support/FieldsIndex.js";import{createRendererExpression as P}from"../../../../support/ArcadeExpression.js";import{CIMSymbolHelper as w}from"../../../../symbols/cim/CIMSymbolHelper.js";import{evaluateValueOrFunction as z}from"../../../../symbols/cim/utils.js";import{scaleCIMSymbol as C}from"../../../../symbols/support/cimSymbolUtils.js";import{defaultPrimitive as R}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{Symbol3DAnchorPosition2D as M}from"../../../../symbols/support/Symbol3DAnchorPosition2D.js";import{getIconHref as I}from"../../../../symbols/support/utils.js";import{transparentUnit as O}from"./constants.js";import{perObjectElevationAligner as j}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as T,needsElevationUpdates2D as F}from"./elevationAlignmentUtils.js";import{focusAreaHUDColor as E}from"./focusAreaStyle.js";import{Graphics3DDrapedGraphicLayer as U}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as D}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as V}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as G}from"./graphicUtils.js";import{namedAnchorToHUDMaterialAnchorPos as L}from"./placementUtils.js";import{placePointOnGeometry as A,updateStageObjectGeometry as H,getLocalOriginForPoint as k,extendPointGraphicElevationContext as B,createStageObject as $}from"./pointUtils.js";import{initFastSymbolUpdatesState as N,updateFastSymbolUpdatesState as q,evaluateModelTransformScale as J,ConvertOptions as Z}from"../support/FastSymbolUpdates.js";import{createTexture as W,requiresHalfTexelOffset as K,defaultBoundingBox as Q,defaultSymbolSizeRatio as X,defaultTexSize as Y}from"../../support/engineContent/sdfPrimitives.js";import{drapedZ as ee}from"../../terrain/OverlayRenderer.js";import{VerticalOffsetParameters as te}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{createPointGeometry as re}from"../../webgl-engine/lib/GeometryUtil.js";import{ManagedTexture as ie}from"../../webgl-engine/lib/ManagedTexture.js";import{RenderGeometry as se}from"../../webgl-engine/lib/RenderGeometry.js";import{HUDMaterial as oe}from"../../webgl-engine/materials/HUDMaterial.js";const ae=_(0,0,1),ne=16,le=1.5,ce=[Y*X,Y*X];class he extends V{static{this.PRIMITIVE_SIZE=ce}getCachedSize(){return{size:this._getIconSize()}}static{this.elevationModeChangeTypes={definedChanged:1,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,r,i){super(e,t,r,i,ye(t)),this._cimData=null,this._overrideHelperClass=null,this._arcadeInfo=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimScaleFactorOrFunction=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._textureHandle=null,this._patchTask=null,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),r=this._getPrimitive();if(null!=r)this._prepareResourcesPrimitive(t,r);else{const r=I(this.symbolLayer),i=de(r);null!=i?await this._prepareResourcesCIM(t,JSON.parse(i),e):await this._prepareResourcesHref(t,r,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=G(this._getIconSize());if(e)throw new i("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?c(e.size):ne);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e,t){const r=this._overrideHelperClass;let i=this._cimData;if(r&&i&&i.symbol||this.logger.error("Can't create texture, CIM data is undefined"),i.primitiveOverrides){i=s(i);const o=i.primitiveOverrides;r.evaluateOverrides(o,e,this._arcadeInfo.geometryType,null,null,t.layer.fieldsIndex),r.applyOverrides(i.symbol,o)}const o=u(JSON.stringify(i));let a=this._cimSymbolTextures.get(o);if(a)return a;const n=this._context.sharedResources.cimSymbolRasterizer,l=this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null;l&&r.applyDictionaryTextOverrides(i.symbol,e,l,null);const c=null!=this._cimScaleFactorOrFunction?z(this._cimScaleFactorOrFunction,e):1;1!==c&&i.symbol&&C(i.symbol,c,!0);const h=w.getEnvelope(i,null,n.resourceManager);if(h?.width&&h.height){const e=h.x+h.width/2,t=h.y+h.height/2,r=n.rasterize({type:"cim",data:i},h.width,h.height,e,t,1,"esriGeometryPoint",0,null,this._context.graphicsCoreOwner.view.state.rasterPixelRatio),s=new M({x:-h.x/h.width-.5,y:(h.height+h.y)/h.height-.5});this._cimMaterialParametersInfo.anchorPosition=pe("relative",s),a=new ie(r,{width:r?.width??1,height:r?.height??1,reloadable:!0})}else a=new ie(new ImageData(1,1),{width:1,height:1,reloadable:!0});return this._cimSymbolTextures.set(o,a),this._context.stage.addTexture(a),a}_prepareMaterialParameters(){const e={anchorPosition:pe(this.symbolLayer.anchor,this.symbolLayer.anchorPosition),rotation:this.symbolLayer.angle},t=this.symbol;ue(t)&&(e.verticalOffset=new te(t.verticalOffset)),this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this.view.screenSizePerspective.parameters),(0!==e.rotation||this._drivenProperties.rotation)&&(e.hasRotation=!0);const r=!!has("enable-feature:non-occluded-hud");return e.occlusionTest=!r,e.occludedFragmentFade=r,e.horizonCullingEnabled=r&&this._context.spherical,e.hasSlicePlane=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const r=this._getOutlineSize();if(me(t)&&0===r)throw new Error("Nothing to render");if(this._outlineSize=r,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,null!=this._context.sharedResources.textures){const r=this._context.sharedResources.textures.fromData(`${t}-icon`,()=>W(t));this._textureHandle=r,e.textureId=r.managedTexture.id}e.textureIsSignedDistanceField=!0,e.sampleSignedDistanceFieldTexelCenter=K(t),e.distanceFieldBoundingBox=Q;const i=this._getIconSize();this._size=[i,i],this._symbolTextureRatio=1/X,this._createMaterial(e)}async _prepareResourcesHref(e,r,s){this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),a=o*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(null!=this._context.sharedResources.textures){const l=await t(this._context.sharedResources.textures.fromUrl(r,a,{signal:s}));if(!1===l.ok){n(l.error);throw new i("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${r})`)}this._textureHandle=l.value;const c=l.value.managedTexture;this._size=_e(c,o),e.textureId=c.id}this._createMaterial(e)}async _prepareResourcesCIM(e,t,r){const{OverrideHelper:i}=await import("../../../../symbols/cim/OverrideHelper.js");if(this._overrideHelperClass=i,this._cimData=t,!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;l(r),this._context.sharedResources.cimSymbolRasterizer??=new e(this._context.renderCoordsHelper.spatialReference)}const s=this._context.sharedResources.cimSymbolRasterizer,o=[],a=t,n=a?.symbol;w.fetchResources(n,s.resourceManager,o,r),w.fetchFonts(n,s.resourceManager,o);const c=this._context.layer.fields?this._context.layer.fields.map(e=>e.toJSON()):[],h=this._context.renderCoordsHelper.spatialReference;if(this._arcadeInfo={spatialReference:h,fields:c,geometryType:"esriGeometryPoint"},a?.primitiveOverrides&&o.push(i.createRenderExpressions(a.primitiveOverrides,this._arcadeInfo)),o.length>0&&(await Promise.all(o),l(r)),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(e.scaleExpression){const t=e.scaleExpression,r=await P(t,this._context.layer.spatialReference),{default:i}=await import("../../../2d/arcade/callExpressionWithFeature.js"),s=new S(c);this._cimScaleFactorOrFunction=(e,t,o)=>{const a=i(r,e,{$view:o},"esriGeometryPoint",s,t);return null!==a?a:1}}}l(r),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return fe(this.symbolLayer)}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(null!=t.outline?.size)return Math.max(c(t.outline.size),0);return e=me(this._getPrimitive())?le:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),r=this.symbolLayer,i=r?.outline?.color;if(null!=i){const r=e.toUnitRGB(i),s=i.a*t;return[r[0],r[1],r[2],s]}return[0,0,0,0]}_getFillColor(){if(me(this._getPrimitive()))return O;const e=null==this._getPrimitive(),t=this._materialColor;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}get _materialColor(){return this.symbolLayer.material?.color}get _fastVisualVariableFallbackColor(){const t=this._materialColor;if(null==t){return null==this._getPrimitive()?y:g}return e.toUnitRGBA(t)}_getFallbackSize(){const e=this._getIconSize(),{symbolLayer:{size:t}}=this;return(null!=t?Math.round(c(t)):ne)/e}_createMaterial(e){const t=this._context.spherical;if(this._cimData){this._fastUpdates=null;let r=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;return r||(r=new oe(e,t),this._cimSymbolMaterials.set(e.textureId??0,r)),r}this._fastUpdates=N(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),this._materials[0]=new oe(e,t),e.isFocused=!1;const r=this.view.map?.focusAreas.style;return e.color=E(e.color,r),e.outlineColor=E(e.outlineColor,r),this._materials[1]=new oe(e,t),this._materials[0]}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial(e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,hasSlicePlane:!1,shaderPolygonOffset:0,draped:this.draped})}),this.layerOpacityChanged())}destroy(){super.destroy(),this._patchTask=o(this._patchTask),this._materials.length=0,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach(e=>this._context.stage.removeTexture(e)),this._cimSymbolTextures.clear(),this._textureHandle=a(this._textureHandle)}_getScaleFactor({size:e},t){if(!this._drivenProperties.size)return 1;if(null==e)return this._getFallbackSize();const[r,i,s]=e;return"symbol-value"===r?1:"number"==typeof r&&isFinite(r)?c(r)/t:"number"==typeof s&&isFinite(s)?c(s)/t:1}_getDrivenRotation(e){return this._drivenProperties.rotation?e.heading??0:0}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const r=A(t.geometry);if(null==r)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;let i,s=[0,0];const o=this.view.focusAreasView?.containsGeometry(r)??!0;if(this._cimData){if(!this._cimData.symbol)return null;const r=this._generateTextureCIM(t,e),a={textureId:r.id,isFocused:o,...this._cimMaterialParametersInfo};i=this._createMaterial(a);const n=this._context.graphicsCoreOwner.view.state.rasterPixelRatio;s=[r.parameters.width/n,r.parameters.height/n]}else s=this._size,i=o?this._materials[0]:this._materials[1];if(null==r)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const a=e.renderingInfo,n=this._getDrivenUInt8Color(a,this._materialColor,null==this._getPrimitive()),l=this._getDrivenRotation(a);let c=1;if(!this._fastUpdates?.visualVariables.size){const e=s[0]>s[1]?s[0]:s[1];c=this._getScaleFactor(a,e)}c*=this._symbolTextureRatio;const h=d(s[0]*c,s[1]*c),u=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus("on-the-ground"===u.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,r,i,n,l,h):this._createAs3DShape(t,r,i,n,l,h,u,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial(r=>{r.setParameters({color:e}),r.setParameters({outlineColor:t})})}layerScreenSizePerspectiveChanged(){const e=this._context.screenSizePerspectiveEnabled&&!this.draped?this.view.screenSizePerspective.parameters:null;this._forEachMaterial(t=>{t.setParameters({screenSizePerspective:e})})}updateGeometry(e,t){const r=e.geometry;if(this.draped||!r||!this._validateGeometry(r))return!1;const{elevationContext:i,stageObject:s}=t;if(i.mode!==this.getGeometryElevationMode(r))return!1;const o=A(r);if(!o)return!1;i.updateFeatureExpressionFeature(e,this._context.layer);const a=H(s,this._context,o,i);if(null==a)return!1;const n=k(this._context,o);return s.geometries[0].localOrigin===n&&(t.alignedSampledElevation=a,B(t,o,this._context.elevationProvider),!0)}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=T(he.elevationModeChangeTypes,r,i);if(1!==s)return s;const o=F(i)||"absolute-height"===i;return this.updateGraphics3DGraphicElevationInfo(e,t,()=>o)}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial(e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return null!=this._getPrimitive()}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return 0;if(!q(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return 0;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return 2}get needsUpdateFocus(){return!0}prepareSymbolLayerPatch(e){if(this._patchTask?.abort(),"partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchResource(e,t),this._preparePatchRotation(e,t)}_preparePatchResource(e,s){if(!s.resource||"partial"!==s.resource.type)return;const c=s.resource.diff;if("complete"!==c?.href?.type)return;const h=c.href.newValue,{textures:u}=this._context.sharedResources;if(null==h||null==u||null!=de(h))return;const m=this._getIconSize(),d=m*this._context.graphicsCoreOwner.view.state.pixelRatio;e.symbolLayerStatePatches.push(()=>{this._patchTask=o(this._patchTask),this._patchTask=r(e=>this._context.schedule(async(e,r)=>{const s=await t(u.fromUrl(h,d,{signal:r}));l(r);const o=!s.ok;if(o&&n(s.error),this._textureHandle=a(this._textureHandle),this._patchTask=null,o){this._forEachMaterial(e=>{e.visible=!1,e.setParameters({textureId:null})});const e=`Failed to load (Request for icon resource failed: ${h})`;return void this.logger.error(new i("graphics3diconsymbollayer:request-failed",e))}this._textureHandle=s.value;const c=s.value.managedTexture;this._size=_e(c,m),this._forEachMaterial(e=>{e.setParameters({textureId:c.id}),e.visible=!0})},e))}),delete c.href}_preparePatchRotation(e,t){if(!t.angle||"complete"!==t.angle.type)return;const r=t.angle.newValue??0,i=0!==r||this._drivenProperties.rotation;e.symbolLayerStatePatches.push(()=>{this._forEachMaterial(e=>e.setParameters({rotation:r,hasRotation:i}))}),delete t.angle}_defaultElevationInfoNoZ(){return ge}_createAs3DShape(e,t,r,i,s,o,a,n){const l=this.getFastUpdateAttrValues(e),c=this._context.layerViewUid,h=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerViewUid:c}),u=re(r,{normal:ae,color:i,rotation:s,size:o,centerOffsetAndDistance:xe,featureAttribute:l,olidColor:h}),m=$(this._context,t,u,a,n);if(null==m)return null;const d=new D(this,m.object,null,j,a);return d.hiddenIfDeconflicted=!0,d.alignedSampledElevation=m.sampledElevation,d.needsElevationUpdates=F(a.mode)||"absolute-height"===a.mode,d.getScreenSize=this._createScreenSizeGetter(o,l),d.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(d.getScreenSize(),1,e),B(d,t,this._context.elevationProvider),d}_createAsOverlay(e,t,r,i,s,o){r.renderPriority=this._renderPriority;const a=f();b(t,a,this._context.overlaySR),a[2]=ee;const n=this._context.clippingExtent;if(null!=n&&!v(n,a))return null;const l=this.getFastUpdateAttrValues(e),c=e.uid,h=this._context.layerViewUid,u=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerViewUid:h}),m=re(r,{normal:ae,position:a,color:i,rotation:s,size:o,featureAttribute:l,olidColor:u}),d=new se(m,{layerViewUid:h,graphicUid:c}),p=new U(this,[d],null,this._context.drapeSourceRenderer);return p.getScreenSize=this._createScreenSizeGetter(o,l),p.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(p.getScreenSize(),1,e),p}_createScreenSizeGetter(e,t){const r=this._outlineSize+2;if(this._fastUpdates&&t){const i=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=p())=>{const[o,a]=J(be,this._fastUpdates.materialParameters,t);return e[0]=o*i+r,e[1]=a*s+r,e}}const i=e[0]/this._symbolTextureRatio+r,s=e[1]/this._symbolTextureRatio+r;return(e=p())=>(e[0]=i,e[1]=s,e)}_fastVisualVariableConvertOptions(){const e=Math.max(this._size[0],this._size[1]),t=_(e,e,e),r=h(1),i=e*r,s=_(i,i,i),o=this._getFallbackSize();return new Z({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:t,symbolSize:s,unitInMeters:r,fallbackColor:this._fastVisualVariableFallbackColor,fallbackSize:_(o,o,o)})}_forEachMaterial(e){this._materials.forEach(e),this._cimSymbolMaterials.forEach(e)}test(){return{...super.test(),material:this._materials[0]}}}function ue(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function me(e){return null!=e&&("cross"===e||"x"===e)}function de(e){const t=m(e);return"application/json"===t?.mediaType?t.data:void 0}function pe(e,t){return"relative"===e?d((t.x||0)+.5,.5-(t.y||0)):e in L?L[e]:L.center}function _e({parameters:e},t){const r=(e.width??1)/(e.height??1);return r>1?[t,Math.round(t/r)]:[Math.round(t*r),t]}function fe(e){return e.resource?.href?null:e.resource?.primitive??R}function ye(e){return 1===(e.material?.color?.a??0)&&null!=fe(e)}const ge={mode:"relative-to-ground",offset:0},xe=x(0,0,0,1),be=f();export{he as Graphics3DIconSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import has from"../../../../core/has.js";import{pt2px as t}from"../../../../core/screenUtils.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as n,ZEROS as i}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{RenderingInfo as s}from"../../../../renderers/support/RenderingInfo.js";import{textSymbolLayerSupportsVerticalOffset as a}from"../../../../symbols/callouts/calloutUtils.js";import{perObjectElevationAligner as o}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as l,needsElevationUpdates2D as c}from"./elevationAlignmentUtils.js";import{Graphics3DGraphicCreationContext as h}from"./Graphics3DGraphicCreationContext.js";import{Graphics3DObject3DGraphicLayer as p}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DObjectMetadata as m}from"./Graphics3DObjectMetadata.js";import{Graphics3DSymbolLayer as d}from"./Graphics3DSymbolLayer.js";import{computeCentroid as f}from"./graphicUtils.js";import{createStageObject as u,extendPointGraphicElevationContext as g}from"./pointUtils.js";import{SymbolComplexity as v}from"./SymbolComplexity.js";import{Attribute as y}from"../../webgl-engine/lib/Attribute.js";import{Geometry as b}from"../../webgl-engine/lib/Geometry.js";import{LineCalloutMaterial as x,Parameters as _,uniqueMaterialIdentifier as C}from"../../webgl-engine/materials/LineCalloutMaterial.js";class O extends d{static{this.elevationModeChangeTypes={definedChanged:1,staysOnTheGround:1,onTheGroundChanged:2}}constructor(e,t){super(e,null,t,w),this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!1},this.ensureDrapedStatus(!1)}async doLoad(){this._materials[0]=new x(this._materialParameters,this._context.spherical)}_perInstanceMaterialParameters(e){const t=this._materialParameters;return t.horizontalScreenOffset=e.horizontalScreenOffset??0,t.centerOffsetUnits=e.centerOffsetUnits||"world",t}get _materialParameters(){const r=new _,n=this.symbol,s=n.callout;if(s.color){const t=e.toUnitRGBA(s.color);t[3]*=this._getLayerOpacity(),r.color=t}else r.color=i;if(r.size=t(s.size||0),n.verticalOffset){const{screenLength:e,minWorldLength:i,maxWorldLength:s}=n.verticalOffset;r.verticalOffset={screenLength:t(e),minWorldLength:i||0,maxWorldLength:null!=s?s:1/0}}r.borderColor=null!=s.border?.color?e.toUnitRGBA(s.border.color):null;const a="object"===n.symbolLayers.at(0).type,o="label-3d"===n.type;return r.occlusionTest=!a&&!has("enable-feature:non-occluded-hud"),a&&(r.shaderPolygonOffset=0),r.hudDepthAlignStart=o,r.hasSlicePlane=this._context.slicePlaneEnabled,r.screenSizePerspective=this._context.screenSizePerspectiveEnabled?this.view.screenSizePerspective.parameters:null,r}_defaultElevationInfoNoZ(){return G}createGraphics3DGraphic(e,t){const r=e.renderingInfo,n=e.graphic,i=this.createElevationContextForGraphic(n,r.elevationOffset||0),s=r.symbol,o="on-the-ground"===this._elevationContext.mode&&("cim"===s.type||!s.symbolLayers.some(e=>"object"===e.type||"text"===e.type));if("label-3d"!==s.type&&o)return null;if("point-3d"===s.type&&s.symbolLayers.every(e=>"text"===e.type&&!a(e)))return null;const l=f(n.geometry);return null==l?null:this._createAs3DShape(l,i,r,n.uid,t)}layerOpacityChanged(){this._materials[0]?.setParameters(this._materialParameters)}layerScreenSizePerspectiveChanged(){const e=this._context.screenSizePerspectiveEnabled?this.view.screenSizePerspective.parameters:null;this._materials[0]?.setParameters({screenSizePerspective:e})}layerElevationInfoChanged(e,t,r){const n=this._elevationContext.mode,i=l(O.elevationModeChangeTypes,r,n);return 1!==i||e?.forEach(e=>{const r=t(e);null!=r&&this.graphics3DGraphicLayerElevationInfoChanged(e.graphic,r)}),i}slicePlaneEnabledChanged(){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return!0}createElevationContextForGraphic(e,t=0){const r=super.createElevationContextForGraphic(e);return r.addOffsetRenderUnits(t),r}updateElevationContextForGraphic(e,t,r=0){super.updateElevationContextForGraphic(e,t),e.addOffsetRenderUnits(r)}graphics3DGraphicLayerElevationInfoChanged(e,t){const{elevationContext:r,metadata:n}=t;this.updateElevationContextForGraphic(r,e,n?.elevationOffset??0),t.needsElevationUpdates=c(r.mode)}computeComplexity(){return new v({verticesPerFeature:6})}_getOrCreateMaterial(e,t){const r=this._perInstanceMaterialParameters(e),n=C(r);if(n===this._materials[0]?.uniqueMaterialIdentifier)return this._materials[0];if(t){let e=t.get(n);return null==e&&(e=new x(r,this._context.spherical),t.set(n,e)),e}return new x(r,this._context.spherical)}_createAs3DShape(e,t,r,n,i){const s=this._context.layerViewUid,a=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerViewUid:s}),l=this._getOrCreateMaterial(r,i),h=new b(l,j(r),null,1,a),d=u(this._context,e,h,t,n);if(null==d)return null;const f=new p(this,d.object,null,o,t);return f.metadata=new m(r.elevationOffset),f.alignedSampledElevation=d.sampledElevation,f.needsElevationUpdates=c(t.mode),g(f,e,this._context.elevationProvider),f}}function j(e){const{translation:t,centerOffset:r}=e,n=new y(t?[t[0],t[1],t[2]]:[0,0,0],P,3,!0),i=new y(r?[r[0],r[1],r[2],r[3]]:[0,0,0,1],P,4,!0);return[["position",n],["normal",new y([0,0,1],P,3,!0)],["centerOffsetAndDistance",i]]}const P=[0],G={mode:"relative-to-ground",offset:0},w={ignoreDrivers:!0,renderPriority:0,renderPriorityStep:1};class E extends s{constructor(e,t,i=r(),s=n(),a=0,o="world",l=0){super(e,t),this.translation=i,this.centerOffset=s,this.horizontalScreenOffset=a,this.centerOffsetUnits=o,this.elevationOffset=l}}class S extends h{}export{O as Graphics3DLineCalloutSymbolLayer,S as LineCalloutCreationContext,E as LineCalloutSymbolLayerRenderingInfo};
|
|
5
|
+
import e from"../../../../Color.js";import has from"../../../../core/has.js";import{pt2px as t}from"../../../../core/screenUtils.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as n,ZEROS as i}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{RenderingInfo as s}from"../../../../renderers/support/RenderingInfo.js";import{textSymbolLayerSupportsVerticalOffset as a}from"../../../../symbols/callouts/calloutUtils.js";import{perObjectElevationAligner as o}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as l,needsElevationUpdates2D as c}from"./elevationAlignmentUtils.js";import{Graphics3DGraphicCreationContext as h}from"./Graphics3DGraphicCreationContext.js";import{Graphics3DObject3DGraphicLayer as p}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DObjectMetadata as m}from"./Graphics3DObjectMetadata.js";import{Graphics3DSymbolLayer as d}from"./Graphics3DSymbolLayer.js";import{computeCentroid as f}from"./graphicUtils.js";import{createStageObject as u,extendPointGraphicElevationContext as g}from"./pointUtils.js";import{SymbolComplexity as v}from"./SymbolComplexity.js";import{Attribute as y}from"../../webgl-engine/lib/Attribute.js";import{Geometry as b}from"../../webgl-engine/lib/Geometry.js";import{LineCalloutMaterial as x,Parameters as _,uniqueMaterialIdentifier as C}from"../../webgl-engine/materials/LineCalloutMaterial.js";class O extends d{static{this.elevationModeChangeTypes={definedChanged:1,staysOnTheGround:1,onTheGroundChanged:2}}constructor(e,t){super(e,null,t,w),this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!1},this.ensureDrapedStatus(!1)}async doLoad(){this._materials[0]=new x(this._materialParameters,this._context.spherical)}_perInstanceMaterialParameters(e){const t=this._materialParameters;return t.horizontalScreenOffset=e.horizontalScreenOffset??0,t.centerOffsetUnits=e.centerOffsetUnits||"world",t}get _materialParameters(){const r=new _,n=this.symbol,s=n.callout;if(s.color){const t=e.toUnitRGBA(s.color);t[3]*=this._getLayerOpacity(),r.color=t}else r.color=i;if(r.size=t(s.size||0),n.verticalOffset){const{screenLength:e,minWorldLength:i,maxWorldLength:s}=n.verticalOffset;r.verticalOffset={screenLength:t(e),minWorldLength:i||0,maxWorldLength:null!=s?s:1/0}}r.borderColor=null!=s.border?.color?e.toUnitRGBA(s.border.color):null;const a="object"===n.symbolLayers.at(0).type,o="label-3d"===n.type;return r.occlusionTest=!a&&!has("enable-feature:non-occluded-hud"),a&&(r.shaderPolygonOffset=0),r.hudDepthAlignStart=o,r.hasSlicePlane=this._context.slicePlaneEnabled,r.screenSizePerspective=this._context.screenSizePerspectiveEnabled?this.view.screenSizePerspective.parameters:null,r}_defaultElevationInfoNoZ(){return G}createGraphics3DGraphic(e,t){const r=e.renderingInfo,n=e.graphic,i=this.createElevationContextForGraphic(n,r.elevationOffset||0),s=r.symbol,o="on-the-ground"===this._elevationContext.mode&&("cim"===s.type||!s.symbolLayers.some(e=>"object"===e.type||"text"===e.type));if("label-3d"!==s.type&&o)return null;if("point-3d"===s.type&&s.symbolLayers.every(e=>"text"===e.type&&!a(e)))return null;const l=f(n.geometry);return null==l?null:this._createAs3DShape(l,i,r,n.uid,t)}layerOpacityChanged(){this._materials[0]?.setParameters(this._materialParameters)}layerScreenSizePerspectiveChanged(){const e=this._context.screenSizePerspectiveEnabled?this.view.screenSizePerspective.parameters:null;this._materials[0]?.setParameters({screenSizePerspective:e})}layerElevationInfoChanged(e,t,r){const n=this._elevationContext.mode,i=l(O.elevationModeChangeTypes,r,n);return 1!==i||e?.forEach(e=>{const r=t(e);null!=r&&this.graphics3DGraphicLayerElevationInfoChanged(e.graphic,r)}),i}slicePlaneEnabledChanged(){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return!0}createElevationContextForGraphic(e,t=0){const r=super.createElevationContextForGraphic(e);return r.addOffsetRenderUnits(t),r}updateElevationContextForGraphic(e,t,r=0){super.updateElevationContextForGraphic(e,t),e.addOffsetRenderUnits(r)}graphics3DGraphicLayerElevationInfoChanged(e,t){const{elevationContext:r,metadata:n}=t;this.updateElevationContextForGraphic(r,e,n?.elevationOffset??0),t.needsElevationUpdates=c(r.mode)}computeComplexity(){return new v({verticesPerFeature:6})}_getOrCreateMaterial(e,t){const r=this._perInstanceMaterialParameters(e),n=C(r);if(n===this._materials[0]?.uniqueMaterialIdentifier)return this._materials[0];if(t){let e=t.get(n);return null==e&&(e=new x(r,this._context.spherical),t.set(n,e)),e}return new x(r,this._context.spherical)}_createAs3DShape(e,t,r,n,i){const s=this._context.layerViewUid,a=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerViewUid:s}),l=this._getOrCreateMaterial(r,i),h=new b(l,j(r),null,1,a),d=u(this._context,e,h,t,n);if(null==d)return null;const f=new p(this,d.object,null,o,t);return f.hiddenIfDeconflicted=!0,f.metadata=new m(r.elevationOffset),f.alignedSampledElevation=d.sampledElevation,f.needsElevationUpdates=c(t.mode),g(f,e,this._context.elevationProvider),f}}function j(e){const{translation:t,centerOffset:r}=e,n=new y(t?[t[0],t[1],t[2]]:[0,0,0],P,3,!0),i=new y(r?[r[0],r[1],r[2],r[3]]:[0,0,0,1],P,4,!0);return[["position",n],["normal",new y([0,0,1],P,3,!0)],["centerOffsetAndDistance",i]]}const P=[0],G={mode:"relative-to-ground",offset:0},w={ignoreDrivers:!0,renderPriority:0,renderPriorityStep:1};class E extends s{constructor(e,t,i=r(),s=n(),a=0,o="world",l=0){super(e,t),this.translation=i,this.centerOffset=s,this.horizontalScreenOffset=a,this.centerOffsetUnits=o,this.elevationOffset=l}}class S extends h{}export{O as Graphics3DLineCalloutSymbolLayer,S as LineCalloutCreationContext,E as LineCalloutSymbolLayerRenderingInfo};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{p as e,i as t}from"../../../../chunks/vec32.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as s,setMin as a,setMax as n,isPoint as r,empty as l,center as g,offset as c}from"../../../../geometry/support/aaBoundingBox.js";import{evaluateElevationInfoAtPoint as o}from"./elevationAlignmentUtils.js";import{demResolutionForBoundingBox as h}from"./graphicUtils.js";class d{constructor(e,t,i){this.baseMaterial=e,this.edgeMaterial=t,this.hasSlicePlane=i}}class b{_getFlag(e){return(this._flags&e)===e}_setFlag(e,t){t?this._flags|=e:this._flags&=~e}get needsElevationUpdates(){return this._getFlag(2)}set needsElevationUpdates(e){this._setFlag(2,e)}get useObjectOriginAsAttachmentOrigin(){return this._getFlag(4)}set useObjectOriginAsAttachmentOrigin(e){this._setFlag(4,e)}get isElevationSource(){return!!this.stageObject.lastValidElevationBB}constructor(e,t,i,s,a,n=null){this.graphics3DSymbolLayer=e,this.stageObject=t,this._sharedResource=i,this.elevationAligner=s,this.elevationContext=a,this._edgeState=n,this.type="object3d",this._stageLayer=null,this._flags=0,this.alignedSampledElevation=0}initialize(e){this._stageLayer=e}destroy(){if(!this._stageLayer)return;const e=this._stageLayer.stage;this._getFlag(1)&&(this._stageLayer.remove(this.stageObject),this._setFlag(1,!1)),e.renderer.edgeView?.removeObject(this.stageObject),this.stageObject.dispose(),this._sharedResource?.release(),this._stageLayer=null}get usedMemory(){return this.graphics3DSymbolLayer.usedMemory}layerOpacityChanged(e,t){const{stageObject:i,_edgeState:s,_stageLayer:a}=this;if(null==s)return;const n=u(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&&(i.visible=e,e&&!this._getFlag(1)&&(s.add(i),this._setFlag(1,!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._getFlag(1)&&this.stageObject.visible}alignWithElevation(e,t,i){if(null==this.elevationAligner)return;const s=(i,s)=>o(i,e,this.elevationContext,t,s);this.alignedSampledElevation=this.elevationAligner(this,this.elevationContext,e.spatialReference,s,t),this.resetEdgeObject(i)}alignWithAbsoluteElevation(e,t,i){const s=(t,i)=>{i.sampledElevation=e,i.verticalDistanceToGround=0,i.z=e};this.alignedSampledElevation=this.elevationAligner(this,this.elevationContext,this.graphics3DSymbolLayer.view.spatialReference,s,t),this.resetEdgeObject(i)}getCenterObjectSpace(){return this.stageObject.boundingVolumeObjectSpace.bounds.center}getBoundingBoxObjectSpace(e=s()){const t=this.stageObject.boundingVolumeObjectSpace;return a(e,t.min),n(e,t.max),e}computeAttachmentOrigin(i){const s=this.stageObject.effectiveTransformation;if(this.useObjectOriginAsAttachmentOrigin)i.render.origin[0]+=s[12],i.render.origin[1]+=s[13],i.render.origin[2]+=s[14],i.render.num++;else for(const a of this.stageObject.geometries)a.computeAttachmentOrigin(m)&&(e(m,m,s),t(i.render.origin,i.render.origin,m),i.render.num++)}async getProjectedBoundingBox(t,i,s,a,n){const o=this.getBoundingBoxObjectSpace(n),d=p,b=r(o)?1:d.length;for(let r=0;r<b;r++){const t=d[r];j[0]=o[t[0]],j[1]=o[t[1]],j[2]=o[t[2]],e(j,j,this.stageObject.transformation),O[3*r]=j[0],O[3*r+1]=j[1],O[3*r+2]=j[2]}if(!t(O,0,b))return null;l(o);let u=null;this.calculateRelativeScreenBounds&&(u=this.calculateRelativeScreenBounds());for(let e=0;e<3*b;e+=3){for(let t=0;t<3;t++)o[t]=Math.min(o[t],O[e+t]),o[t+3]=Math.max(o[t+3],O[e+t]);u&&s.push({location:O.slice(e,e+3),screenSpaceBoundingRect:u})}if(i?.service&&"absolute-height"!==this.elevationContext.mode){g(o,m);const e="relative-to-scene"===this.elevationContext.mode?"scene":"ground";let t=0;if(i.useViewElevation)t=i.service.getElevation(m[0],m[1],e)??0;else try{const s=h(o,i.service.spatialReference,i);t=await i.service.queryElevation(m[0],m[1],a,s,e)??0}catch(v){}c(o,0,0,-this.alignedSampledElevation+t)}return o}addObjectState(e){0===e.stateType&&e.addObject(this.stageObject,this.stageObject.highlight(e.highlightName)),1===e.stateType&&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=u(e.baseMaterial);e.edgeMaterial.objectTransparency=s,t.addOrUpdateObject3D(this.stageObject,e.edgeMaterial,e.hasSlicePlane,!i).then(()=>this._stageLayer?.sync())}}function u(e){return e.transparent?0:1}const O=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],j=i(),m=i(),p=[[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{b as Graphics3DObject3DGraphicLayer,d as Object3DEdgeState};
|
|
5
|
+
import{p as e,i as t}from"../../../../chunks/vec32.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as s,setMin as a,setMax as n,isPoint as r,empty as l,center as g,offset as c}from"../../../../geometry/support/aaBoundingBox.js";import{evaluateElevationInfoAtPoint as o}from"./elevationAlignmentUtils.js";import{demResolutionForBoundingBox as h}from"./graphicUtils.js";class d{constructor(e,t,i){this.baseMaterial=e,this.edgeMaterial=t,this.hasSlicePlane=i}}class b{_getFlag(e){return(this._flags&e)===e}_setFlag(e,t){t?this._flags|=e:this._flags&=~e}get needsElevationUpdates(){return this._getFlag(2)}set needsElevationUpdates(e){this._setFlag(2,e)}get useObjectOriginAsAttachmentOrigin(){return this._getFlag(4)}set useObjectOriginAsAttachmentOrigin(e){this._setFlag(4,e)}get hiddenIfDeconflicted(){return this._getFlag(8)}set hiddenIfDeconflicted(e){this._setFlag(8,e)}get isElevationSource(){return!!this.stageObject.lastValidElevationBB}constructor(e,t,i,s,a,n=null){this.graphics3DSymbolLayer=e,this.stageObject=t,this._sharedResource=i,this.elevationAligner=s,this.elevationContext=a,this._edgeState=n,this.type="object3d",this._stageLayer=null,this._flags=0,this.alignedSampledElevation=0}initialize(e){this._stageLayer=e}destroy(){if(!this._stageLayer)return;const e=this._stageLayer.stage;this._getFlag(1)&&(this._stageLayer.remove(this.stageObject),this._setFlag(1,!1)),e.renderer.edgeView?.removeObject(this.stageObject),this.stageObject.dispose(),this._sharedResource?.release(),this._stageLayer=null}get usedMemory(){return this.graphics3DSymbolLayer.usedMemory}layerOpacityChanged(e,t){const{stageObject:i,_edgeState:s,_stageLayer:a}=this;if(null==s)return;const n=u(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&&(i.visible=e,e&&!this._getFlag(1)&&(s.add(i),this._setFlag(1,!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._getFlag(1)&&this.stageObject.visible}alignWithElevation(e,t,i){if(null==this.elevationAligner)return;const s=(i,s)=>o(i,e,this.elevationContext,t,s);this.alignedSampledElevation=this.elevationAligner(this,this.elevationContext,e.spatialReference,s,t),this.resetEdgeObject(i)}alignWithAbsoluteElevation(e,t,i){const s=(t,i)=>{i.sampledElevation=e,i.verticalDistanceToGround=0,i.z=e};this.alignedSampledElevation=this.elevationAligner(this,this.elevationContext,this.graphics3DSymbolLayer.view.spatialReference,s,t),this.resetEdgeObject(i)}getCenterObjectSpace(){return this.stageObject.boundingVolumeObjectSpace.bounds.center}getBoundingBoxObjectSpace(e=s()){const t=this.stageObject.boundingVolumeObjectSpace;return a(e,t.min),n(e,t.max),e}computeAttachmentOrigin(i){const s=this.stageObject.effectiveTransformation;if(this.useObjectOriginAsAttachmentOrigin)i.render.origin[0]+=s[12],i.render.origin[1]+=s[13],i.render.origin[2]+=s[14],i.render.num++;else for(const a of this.stageObject.geometries)a.computeAttachmentOrigin(m)&&(e(m,m,s),t(i.render.origin,i.render.origin,m),i.render.num++)}async getProjectedBoundingBox(t,i,s,a,n){const o=this.getBoundingBoxObjectSpace(n),d=p,b=r(o)?1:d.length;for(let r=0;r<b;r++){const t=d[r];j[0]=o[t[0]],j[1]=o[t[1]],j[2]=o[t[2]],e(j,j,this.stageObject.transformation),O[3*r]=j[0],O[3*r+1]=j[1],O[3*r+2]=j[2]}if(!t(O,0,b))return null;l(o);let u=null;this.calculateRelativeScreenBounds&&(u=this.calculateRelativeScreenBounds());for(let e=0;e<3*b;e+=3){for(let t=0;t<3;t++)o[t]=Math.min(o[t],O[e+t]),o[t+3]=Math.max(o[t+3],O[e+t]);u&&s.push({location:O.slice(e,e+3),screenSpaceBoundingRect:u})}if(i?.service&&"absolute-height"!==this.elevationContext.mode){g(o,m);const e="relative-to-scene"===this.elevationContext.mode?"scene":"ground";let t=0;if(i.useViewElevation)t=i.service.getElevation(m[0],m[1],e)??0;else try{const s=h(o,i.service.spatialReference,i);t=await i.service.queryElevation(m[0],m[1],a,s,e)??0}catch(v){}c(o,0,0,-this.alignedSampledElevation+t)}return o}addObjectState(e){0===e.stateType&&e.addObject(this.stageObject,this.stageObject.highlight(e.highlightName)),1===e.stateType&&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=u(e.baseMaterial);e.edgeMaterial.objectTransparency=s,t.addOrUpdateObject3D(this.stageObject,e.edgeMaterial,e.hasSlicePlane,!i).then(()=>this._stageLayer?.sync())}}function u(e){return e.transparent?0:1}const O=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],j=i(),m=i(),p=[[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{b as Graphics3DObject3DGraphicLayer,d 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/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../core/Error.js";import has from"../../../../core/has.js";import{releaseMaybe as t}from"../../../../core/maybe.js";import{isPromiseLike as r}from"../../../../core/promiseUtils.js";import{pt2px as s}from"../../../../core/screenUtils.js";import{fromValues as n,ZEROS as i,create as o}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{freeze as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as l}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{hasCalloutSupport as c,textSymbolLayerSupportsVerticalOffset as m}from"../../../../symbols/callouts/calloutUtils.js";import{perObjectElevationAligner as f}from"./ElevationAligners.js";import{needsElevationUpdates2D as h}from"./elevationAlignmentUtils.js";import{focusAreaHUDColor as p}from"./focusAreaStyle.js";import{Graphics3DObject3DGraphicLayer as
|
|
5
|
+
import e from"../../../../core/Error.js";import has from"../../../../core/has.js";import{releaseMaybe as t}from"../../../../core/maybe.js";import{isPromiseLike as r}from"../../../../core/promiseUtils.js";import{pt2px as s}from"../../../../core/screenUtils.js";import{fromValues as n,ZEROS as i,create as o}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{freeze as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as l}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{hasCalloutSupport as c,textSymbolLayerSupportsVerticalOffset as m}from"../../../../symbols/callouts/calloutUtils.js";import{perObjectElevationAligner as f}from"./ElevationAligners.js";import{needsElevationUpdates2D as h}from"./elevationAlignmentUtils.js";import{focusAreaHUDColor as p}from"./focusAreaStyle.js";import{Graphics3DObject3DGraphicLayer as d}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DObjectMetadata as u}from"./Graphics3DObjectMetadata.js";import{Graphics3DSymbolLayer as g}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as y}from"./graphicUtils.js";import{LabelPlacement as v,LabelParameters as x}from"./LabelParameters.js";import{verticalScreenOffsetFromAlignment as b,verticalPlacementFromAlignment as O,textRenderAlignmentFromHorizontalPlacement as P,horizontalPlacementToAnchorX as w,anchorFromPlacements as j,namedAnchorToHUDMaterialAnchorPos as S}from"./placementUtils.js";import{placePointOnGeometry as _,updateStageObjectGeometry as E,getLocalOriginForPoint as z,extendPointGraphicElevationContext as C,createStageObject as F}from"./pointUtils.js";import{getFontMetrics as G}from"../../webgl-engine/lib/FontMetrics.js";import{createPointGeometry as L}from"../../webgl-engine/lib/GeometryUtil.js";import{TextRenderParameters as A}from"../../webgl-engine/lib/TextRenderParameters.js";import U from"../../webgl-engine/lib/TextTextureFactory.js";import{HUDMaterial as D}from"../../webgl-engine/materials/HUDMaterial.js";const R=a(0,0,1);class T extends g{constructor(e,t,r,s){super(e,t,r,s),this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!1},this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const t=y(this.symbolLayer.size);if(t)throw new e("graphics3dtextsymbollayer:invalid-size",t)}await this._createTextRenderParameters()}async _createTextRenderParameters(){const e=this._context.graphicsCoreOwner.view.state.rasterPixelRatio;this._textRenderParameters=await A.fromSymbol(this.symbolLayer,e)}destroy(){super.destroy()}createGraphics3DGraphic(e){const t=e.graphic,r=_(t.geometry);if(null==r)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;const s=this.view.focusAreasView?.containsGeometry(r)??!0,n=this.symbolLayer.text;if(null==n||""===n)return null;const i=c(this.symbol)&&this.symbol.hasVisibleVerticalOffset()?this.symbol.verticalOffset:null;if(null!=i&&!m(this.symbolLayer))return this.logger.errorOncePerTick(`Callouts and vertical offset on text symbols are currently only supported with 'center' horizontal alignment (not with '${this.symbolLayer.horizontalAlignment}' alignment)`),null;const{verticalAlignment:o}=this.symbolLayer,a=new v(i);b(o,a.screenOffset);const l=new x(a,this.symbolLayer.horizontalAlignment,O(o));return l.isFocused=s??l.isFocused,this._createAs3DShape(t,r,n,l)}get needsUpdateFocus(){return!0}createLabel(e,t,r,s,n){const i=e.graphic,o=_(i.geometry);if(null==o)return this.logger.warn(`unsupported geometry type for label: ${i.geometry.type}`),null;const a=this.view.focusAreasView?.containsGeometry(o)??!0,l=t.text;return!l||/^\s+$/.test(l)?null:(t.isFocused=a??t.isFocused,this._createAs3DShape(i,o,l,t,r,s,n))}createElevationContextForGraphic(e,t=0){const r=super.createElevationContextForGraphic(e);return r.addOffsetRenderUnits(t),r}updateElevationContextForGraphic(e,t,r=0){super.updateElevationContextForGraphic(e,t),e.addOffsetRenderUnits(r)}layerOpacityChanged(){return this.logger.warn("layer opacity change not yet implemented in Graphics3DTextSymbolLayer"),!1}layerScreenSizePerspectiveChanged(e,t){const r=!this.draped&&this._context.screenSizePerspectiveEnabled,s=r?this.view.screenSizePerspective.labelParameters:null,n=r?this.view.screenSizePerspective.parameters:null;I(e,t,e=>{for(const t of e.stageObject.geometries)t.material.setParameters({screenSizePerspective:s,screenSizePerspectiveAlignment:n})})}layerElevationInfoChanged(e,t){return I(e,t,(e,t)=>{this.graphics3DGraphicLayerElevationInfoChanged(t,e)}),1}slicePlaneEnabledChanged(e,t){return I(e,t,e=>{for(const t of e.stageObject.geometries)t.material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return!1}graphics3DGraphicLayerElevationInfoChanged(e,t){const{elevationContext:r,metadata:s}=t;this.updateElevationContextForGraphic(r,e,s?.elevationOffset??0),t.needsElevationUpdates=h(r.mode)||"absolute-height"===r.mode}updateGeometry(e,t){const r=e.geometry;if(this.draped||!r||!this._validateGeometry(r))return!1;const{elevationContext:s,stageObject:n}=t;if(s.mode!==this.getGeometryElevationMode(r))return!1;const i=_(r);if(!i)return!1;s.updateFeatureExpressionFeature(e,this._context.layer);const o=E(n,this._context,i,s);if(null==o)return!1;const a=z(this._context,i);return n.geometries[0].localOrigin===a&&(t.alignedSampledElevation=o,C(t,i,this._context.elevationProvider),!0)}_defaultElevationInfoNoZ(){return H}_createAs3DShape(e,a,c,m,g,y=null,v=()=>m.placement.elevationOffset){const x=this.createElevationContextForGraphic(e,m.placement.elevationOffset),b=e.uid;let O=null,w=null;if(null==y){const e=P(m.horizontalPlacement);O=new U(c,e,this._textRenderParameters);let s=null;if(null!=this._context.sharedResources.textures){w=this._context.sharedResources.textures.fromData(O.key,()=>O.create()),w.managedTexture.events.on("unloaded",()=>s=t(s));const e=this._context.stage.renderView.textures.acquire(w.managedTexture.id);if(null==e||r(e))return w.release(),null;s=e}}const j=!!has("enable-feature:non-occluded-hud"),S=V(O,m),_={occlusionTest:!j,occludedFragmentFade:j,horizonCullingEnabled:j&&this._context.spherical,screenOffset:m.placement.screenOffset,anchorPosition:S,polygonOffset:!0,color:[1,1,1,1],centerOffsetUnits:m.placement.centerOffsetUnits,depthEnabled:!1,drawAsLabel:!0,isLabel:!0,isFocused:m.isFocused};if("polyline"===e.geometry?.type&&(_.shaderPolygonOffset=1e-4),y?_.textureId=y.id:w&&(_.textureId=w.managedTexture.id),null!=m.placement.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=m.placement.verticalOffset;_.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0}}const E=this._context.graphicsCoreOwner.view.focusAreasView?.polygons.length,z={screenOffset:_.screenOffset,anchorPosition:S,centerOffsetUnits:_.centerOffsetUnits,verticalOffset:_.verticalOffset,shaderPolygonOffset:_.shaderPolygonOffset,occlusionTest:_.occlusionTest,isFocused:m.isFocused,focusStyle:this.view.map?.focusAreas.style??"none"};if(this._context.screenSizePerspectiveEnabled){const{parameters:e,labelParameters:t}=this.view.screenSizePerspective,r=G(this._textRenderParameters);_.screenSizePerspective=t,_.screenSizePerspectiveMinPixelReferenceSize=r.maxHeight,_.screenSizePerspectiveAlignment=e,z.fontHeight=r.maxHeight}_.hasSlicePlane=this._context.slicePlaneEnabled;const A=this._context.spherical,T=g?JSON.stringify(z):"";let I=g?.get(T);if(null==I){if(!m.isFocused&&E){const e=this.view.map?.focusAreas.style;_.color=p(_.color,e),_.outlineColor=p(_.outlineColor,e)}I=new D(_,A),g?.set(T,I)}const H=m.placement.translation,W=O?n(O.displayWidth,O.displayHeight):i,M=m.placement.centerOffset,$=R,k=y?l(0,0,0,0):null,N=L(I,{normal:$,position:H,size:W,centerOffsetAndDistance:M,uvi:k}),q=F(this._context,a,N,x,b);if(null==q)return null;const B=(t,r,s,n,i,o)=>{const a=v()||m.placement.elevationOffset;return this.updateElevationContextForGraphic(r,e,a),f(t,r,s,n,i,o)},J=new d(this,q.object,w,B,x);J.alignedSampledElevation=q.sampledElevation,J.hiddenIfDeconflicted=!0,J.needsElevationUpdates=h(x.mode)||"absolute-height"===x.mode,J.getScreenSize=(e=o())=>(e[0]=O?O.displayWidth:m.displaySize[0],e[1]=O?O.displayHeight:m.displaySize[1],e);const Y=new u(m.placement.elevationOffset,c);return J.metadata=Y,C(J,a,this._context.elevationProvider),J}}function I(e,t,r){e?.forEach(e=>{const s=t(e);null!=s&&r(s,e.graphic)})}function V(e,t){if("baseline"===t.verticalPlacement){const r=w[t.horizontalPlacement],s=null!=e?e.baselineAnchorY:0;return n(r,s)}const r=j(t.horizontalPlacement,t.verticalPlacement);return S[r]}const H={mode:"relative-to-ground",offset:0};export{T as Graphics3DTextSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{acosClamped as e,lerp as t,clamp as i}from"../../../core/mathUtils.js";import{getMetersPerUnitForSR as r}from"../../../core/units.js";import{b as n,n as s,j as a,g as o,e as m}from"../../../chunks/vec32.js";import{create as
|
|
5
|
+
import{acosClamped as e,lerp as t,clamp as i}from"../../../core/mathUtils.js";import{getMetersPerUnitForSR as r}from"../../../core/units.js";import{b as n,n as s,j as a,g as o,e as m}from"../../../chunks/vec32.js";import{create as c}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as l}from"../../../geometry/ellipsoidUtils.js";import h from"../../../geometry/Extent.js";import{create as u,fromValues as p}from"../../../geometry/support/ray.js";import{Sphere as f}from"../../../geometry/support/sphere.js";import{computeInnerAltitudeFade as x}from"../environment/atmosphereUtils.js";import{DepthRange as _}from"../webgl-engine/lib/DepthRange.js";function M(e,t,i){return 1===e?new y(t,i):new d(t,i)}class d{constructor(e,t){this._elevationProvider=e,this._referenceEllipsoid=l(t),this._unitInMeters=r(t,this._referenceEllipsoid.metersPerDegree)}compute(e,r,n,a){const{eye:c,center:l}=e;let u=c[2]*this._unitInMeters;const p=u,f=u-a,x=this._elevationProvider?.visibleElevationRange;x&&(u=f>=0?p-this._unitInMeters*x.minElevation:this._unitInMeters*x.maxElevation-p),r??=new h({xmin:0,ymin:0,zmin:0,xmax:0,ymax:0,zmax:0});const _={x:r.xmax-r.xmin,y:r.ymax-r.ymin,z:4*Math.max(r.xmax-r.xmin,r.ymax-r.ymin)},M=Math.max(_.x,_.y,_.z);m(P,l,c),F[0]=P[0]>0?r.xmax:r.xmin,F[1]=P[1]>0?r.ymax:r.ymin,F[2]=P[2]>0?M/2:-M/2,m(F,F,c),s(P,P);const d=1.1*o(F,P)*this._unitInMeters,y=Math.sqrt(u*(u+2*this._referenceEllipsoid.radius)),E=Math.max(r.xmax-r.xmin,r.ymax-r.ymin),g=E*w*this._unitInMeters,j=E*D*this._unitInMeters,b=i((u-j)/(g-j),0,1)**3,R=Math.min(t(y,d,b),y)*Math.max(Math.log(Math.abs(f)),1);return v(Math.min(R,Math.max(34064e4,M))/this._unitInMeters,I,this._unitInMeters,z)}}class y{constructor(e,t){this._elevationProvider=e,this._referenceEllipsoid=l(t)}compute(r,c,l,h){const{eye:u}=r,f=n(u),M=f-this._referenceEllipsoid.radius,d=this._computeVirtualAltitude(M,h),y=this._elevationProvider?.visibleElevationRange.maxElevation??0,w=x(d),D=this._computeFarDistanceInternal(f,d,h),A=(Math.log(d)-E)/(g-E);v(D,i(I-A*(I-j),j,I),1,z);const V=this._referenceEllipsoid.radius+y,q=this._referenceEllipsoid.radius+this._referenceEllipsoid.atmosphereHeight,k=Math.max(V,q),H=f-k;if(w>0&&H>b){const i=s(F,a(F,r.eye,-1)),c=s(P,r.viewForward),h=e(o(i,c)),u=.5*r.fovY,f=Math.cos(u);let x=_.Infinite.near;if(h<=u)x=H*f;else{const e=s(F,r.viewUp),t=Math.tan(u),i=a(F,e,t),o=s(F,m(F,c,i)),l=p(r.eye,o,U);if(R.radius=k,R.intersectRay(l,F)){const e=m(F,F,r.eye);x=n(e)*f}}const M=.99*Math.min(l.near,x);if(M<_.Infinite.near&&M>z.near){const e=t(z.near,M,w);z.near=e}}return z}computeFarDistance(e,t){const i=n(e),r=i-this._referenceEllipsoid.radius,s=this._computeVirtualAltitude(r,t);return this._computeFarDistanceInternal(i,s,t)}_computeFarDistanceInternal(e,i,r){const n=this._referenceEllipsoid.radius+Math.min(0,r),s=x(i),a=Math.sqrt(i*(i+2*n)),o=e+this._referenceEllipsoid.radius;return 1.2*t(a,o,s)}_computeVirtualAltitude(e,t){const i=Math.abs(e-t);return Math.max(i,Math.abs(e))}}function v(e,t,i,r){const n=b/i,s=e/t;return s>n?(r.far=e,r.near=s):(r.near=n,r.far=r.near*t),r}const E=7.983,g=16.994,I=2e4,j=100,b=2,w=.001,D=1e-4,F=c(),P=c(),z={near:0,far:0},R=new f,U=u();export{y as NearFarHeuristicGlobal,M as createNearFarHeuristic,b as minNearDistanceInMeters};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{unique as r}from"../../../core/arrayUtils.js";import{EventEmitter as t}from"../../../core/Evented.js";import"../../../core/has.js";import{someMap as s,everyMap as i}from"../../../core/MapUtils.js";import{disposeMaybe as n}from"../../../core/maybe.js";import o from"../../../core/PooledArray.js";import{watch as a,on as h,syncAndInitial as d,initial as l}from"../../../core/reactiveUtils.js";import{someSet as c}from"../../../core/SetUtils.js";import{property as u,subclass as p}from"../../../core/accessorSupport/decorators.js";import{ortho as _,fromTranslation as g}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{h as m}from"../../../chunks/vec32.js";import{ones as y}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{debugFlags as f}from"../support/debugFlags.js";import{Overlay as R}from"./Overlay.js";import{OverlayRenderTargets as v}from"./OverlayRenderTargets.js";import w from"../webgl/RenderCamera.js";import{T as x}from"../../../chunks/TextureOnly.glsl.js";import{SyncRenderPlugin as T}from"../webgl-engine/effects/RenderPlugin.js";import{trackHighlightOptions as O,renderHighlightBuffer as S}from"../webgl-engine/effects/highlight/Highlight.js";import{GLMaterialRepository as b}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as D}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderContext as C,defaultRenderOccludedMask as P}from"../webgl-engine/lib/RenderContext.js";import{ShadowMap as j}from"../webgl-engine/lib/ShadowMap.js";import{TextureTechnique as E}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as M}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{AmbientLight as F}from"../webgl-engine/lighting/Lightsources.js";import{O as W}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as q}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as V,noBudget as A}from"../../support/Scheduler.js";import{Texture as k}from"../../webgl/Texture.js";import{TextureDescriptor as G}from"../../webgl/TextureDescriptor.js";let I=class extends T{constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new W,this.hasHighlights=!1,this.renderOccludedFlags=1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new o,this._passParameters=new x,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new w,this.events=new t,this.longitudeCyclical=null,this.produces=new Map([[19,e=>8!==e||this.hasHighlights],[20,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1,this._hasDrapedFlowSource=!1}initialize(){const e=this._view,r=e.stage,t=r.renderer.fboCache,{waterTextures:s,techniques:i}=r.renderView;this._renderContext=new C(this._rctx,new j(t,e.state.viewingMode),i);const n=this._bindParameters;this.addHandles([a(()=>s.updating,()=>this.events.emit("content-changed"),d),a(()=>this._spatialReference,e=>this._localOriginFactory=new D(e),d),h(()=>e.allLayerViews,"after-changes",()=>this._sortedDrapeSourceRenderersDirty=!0),a(()=>O(e.state.highlights),()=>this._sortedDrapeSourceRenderersDirty=!0,l),a(()=>e.state.highlights,r=>{n.highlights=r,n.highlightOrderMap=e.state.highlightOrderMap},l),e.resourceController.scheduler.registerTask(V.OVERLAY_RENDERER,this)]);const o=this._camera;o.near=1,o.far=1e4,o.relativeElevation=null,n.slot=19,n.camera=o,n.updateLighting([new F(y())],0,0,0)}destroy(){this._renderers.forEach(e=>e.destroy()),this._renderers.clear(),this._passParameters.texture=n(this._passParameters.texture),this.disposeOverlays(),this._renderContext=null,this._sortedRenderers.prune()}get _bindParameters(){return this._renderContext.bind}get _rctx(){return this._stage.renderView.renderingContext}get _view(){return this.parent.view}get _stage(){return this.parent.view.stage}get _spatialReference(){return this.parent.spatialReference}get _techniques(){return this._stage.renderView.techniques}get rctx(){return this._rctx}get materials(){return this._pluginContext.materials}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}get pluginContext(){return this._pluginContext}initializeRenderContext(e){const r=new b(this._view.stage.renderView.textures,this._techniques,()=>{this._onMaterialOrContentChanged(),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")},()=>this.events.emit("content-changed"));this._pluginContext={...e,materials:r},this._techniques.precompile(q)}uninitializeRenderContext(){}acquireTechniques(){return[]}render(){}get updating(){return this._sortedDrapeSourceRenderersDirty||s(this._renderers,e=>e.updating||e.canCompact)}get hasOverlays(){return null!=this._overlays&&null!=this._renderTargets}getMaterialRenderer(e){for(const r of this._renderers.values()){const t=r.getMaterialRenderer(e);if(t)return t}return null}get layers(){return this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers(),r(this._sortedRenderers.map(e=>e.drapeSource.layer).filter(e=>!!e))}registerDrapeSource(e,r){const t=this._renderers.get(e);null!=t&&t.destroy(),this._renderers.set(e,r),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(a(()=>e.fullOpacity,()=>this.events.emit("content-changed")),e)}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._renderTargets?.computeValidity()??0}releaseRenderTargets(e){this._renderTargets?.dispose(e)}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&c(e,e=>1===e.drapeTargetType)}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=c(e,e=>1===e.drapeSourceType),this._hasDrapedRasterSource=c(e,e=>0===e.drapeSourceType),this._hasDrapedFlowSource=c(e,e=>2===e.drapeSourceType)):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=this._hasDrapedFlowSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new v(this._stage.renderer.fboCache),this._overlays=[new R,new R]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets?.dispose(1),this._renderTargets=null,this.events.emit("textures-disposed")}_useOverlayColorInsteadOfColorNoRasterImage(e){return 1===e&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource}getTexture(e){const r=this._useOverlayColorInsteadOfColorNoRasterImage(e);return this._renderTargets?.getTexture(r?0:e)}get readyToRun(){return this.updating}runTask(e){this._processDrapeSources(e,()=>!0)}_onMaterialOrContentChanged(){this.renderOccludedFlags=s(this._renderers,e=>e.hasOccluders)?L:1}_processDrapeSources(e,r){let t=!1;for(const[s,i]of this._renderers){if(e.done)break;(s.destroyed||r(s))&&(i.commitChanges()&&(t=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,t=!0,this._updateSortedDrapeSourceRenderers(),e.madeProgress()),this.compact(e),t&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this._onMaterialOrContentChanged(),this.hasHighlights=s(this._renderers,e=>e.hasHighlights),this.events.emit("content-changed"))}compact(e){let r=!1;for(const t of this._renderers.values()){if(e.done)break;r=t.compact(e)||r}return r&&this.notifyChange("updating"),r}hasHighlight(e){return s(this._renderers,r=>r.hasHighlight(e))}processSyncDrapeSources(){this._processDrapeSources(A,e=>1===e.updatePolicy)}get isEmpty(){return!f.OVERLAY_DRAW_DEBUG_TEXTURE&&i(this._renderers,e=>e.isEmpty)}get hasWater(){const e=s(this._renderers,({hasWater:e})=>e);return e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water")),this._hasWater}renders(e){if(f.OVERLAY_DRAW_DEBUG_TEXTURE&&4!==e&&2!==e)return!0;if(!this._overlays)return!1;const r=this._overlays[0];for(const i of this._overlays)i.setupGeometryViews(this.longitudeCyclical);if(!r.hasSomeSizedView())return!1;const t=this._setOutput(this._renderTargets?.targets.find(r=>r.content===e)?.output??0);++this._techniques.precompiling;const s=this._sortedRenderers.some(({renderer:e})=>e.precompile(this._renderContext));return--this._techniques.precompiling,this._setOutput(t),s}_setOutput(e){const r=this._renderContext.output;return this._renderContext.output=e,this._bindParameters.slot=2===e?20:19,r}get mode(){return this.isEmpty?0:this.hasWater&&this.renders(3)?2:this._renderTargets?.getTexture(0)?1:0}updateAnimation(e){let r=!1;return this._renderers.forEach(t=>r=t.updateAnimation(e)||r),r&&this.parent.requestRender(0),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}precompileShaders(e){if(!this._overlays||!this._renderTargets)return!1;const r=this._bindParameters;r.alignPixelEnabled=e.alignPixelEnabled,++this._techniques.precompiling;for(const t of this._renderTargets.targets){if(1===t.content&&!this._needsColorWithoutRasterImage)continue;const{output:e}=t;this._setOutput(e),8===e&&(r.highlightMixTexture=r.highlights.length>1?this._rctx.emptyTexture:null);const s=this._renderContext.renderOccludedMask;4===t.content&&(this._renderContext.renderOccludedMask=L),this._sortedRenderers.forAll(({drapeSource:e,renderer:r})=>{1===t.content&&0===e.drapeSourceType||4===t.content&&r.hasOnlyOccluders||r.precompile(this._renderContext)}),this._renderContext.renderOccludedMask=s,r.highlightMixTexture=null}return--this._techniques.precompiling,!0}drawOverlays(e,r){if(!this._overlays||!this._renderTargets)return;for(const s of this._overlays)s.setupGeometryViews(this.longitudeCyclical);this._bindParameters.alignPixelEnabled=e.alignPixelEnabled;const t=this.allSourcesOccluders;for(const s of this._renderTargets.targets){if(!(0===s.content&&this._hasDrapedFlowSource)&&!s.handleRenderRequest(r)||1===s.content&&!this._needsColorWithoutRasterImage||4===s.content&&t)continue;const e=this._drawTarget(0,s),i=this._drawTarget(1,s);(e||i)&&s.fbo.generateMipMap()}}_drawTarget(e,r){const t=this._overlays[e],s=t.canvasGeometries;if(0===s.numViews)return!1;const i=this._view.state.contentPixelRatio;this._screenToWorldRatio=i*t.mapUnitsPerPixel/this._bindParameters.overlayStretch;const{output:n,content:o}=r;if(this.isEmpty||2===n&&!this.hasWater||!t.hasSomeSizedView())return!1;const{_rctx:a,_camera:h,_renderContext:d,_bindParameters:l}=this;if(h.pixelRatio=t.pixelRatio*i,this._setOutput(n),l.screenToWorldRatio=this._screenToWorldRatio,l.screenToPCSRatio=this._screenToWorldRatio*this.parent.worldToPCSRatio,4===o&&(d.renderOccludedMask=L),!this.renders(o))return d.renderOccludedMask=P,!1;const{resolution:c}=t,u=0===e,p=u?0:c;a.setViewport(p,0,c,c),this._bindTargetFBO(r),u&&(8===n?a.gl.clearBufferuiv(a.gl.COLOR,0,[0,0,0,0]):(a.setClearColor(0,0,0,0),a.clear(16384)));if(f.OVERLAY_DRAW_DEBUG_TEXTURE&&4!==o&&2!==o){this._techniques.precompile(E,z);const r=this._techniques.get(E,z);for(let i=0;i<s.numViews;i++)this._setViewParameters(s.extents[i],t),this._ensureDebugPatternResources(t.resolution,B[e]),a.bindTechnique(r,l,this._passParameters),a.screen.draw()}if(8===n){const{fboCache:t}=this._stage.renderer,s=this._resolution;this._bindTargetFBO(r),S(a,t,{width:s,height:s},l,()=>this._renderAllGeometry(e,r),p)}else this._renderAllGeometry(e,r);return a.bindFramebuffer(null),d.renderOccludedMask=P,!0}get allSourcesOccluders(){return i(this._renderers,e=>e.hasOnlyOccluders)}_renderAllGeometry(e,r){const t=this._overlays[e],s=t.canvasGeometries;this._sortedRenderers.forAll(({drapeSource:i,renderer:n})=>{if(1===r.content&&0===i.drapeSourceType)return;const{fullOpacity:o}=i,a=null!=o&&o<1&&0===r.output&&this._bindTemporaryFBO();for(let e=0;e<s.numViews;e++)this._setViewParameters(s.extents[e],t),n.render(this._renderContext);if(a){this._bindTargetFBO(r),this._overlayParameters.texture=a.getTexture(),this._overlayParameters.opacity=o,this._overlayParameters.overlayIndex=e;const t=this._techniques.get(q);this._rctx.bindTechnique(t,this._bindParameters,this._overlayParameters),this._rctx.screen.draw(),a.release()}})}_bindTargetFBO(e){const r=this._resolution,t=2*r;e.fbo.ensureFramebuffer(t,r),e.fbo.bind(this._rctx)}_bindTemporaryFBO(){const e=this._resolution,r=2*e,t=this._stage.renderer.fboCache,s=t.acquire(r,e,"overlay tmp");return t.rctx.bindFramebuffer(s.fbo),t.rctx.clear(16384),s}get _resolution(){return this._overlays?.[0].resolution??0}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:n}of this._sortedRenderers)i=n.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this._view.map.allLayers.map(e=>e.uid),r=e.length;this._renderers.forEach((t,s)=>{const i=e.indexOf(s.layer?.uid),n=i>=0,o=s.renderGroup??(n?0:1),a=s.drapeSourcePriorityOffset??0,h=r*o+(n?i:0)+a;this._sortedRenderers.push(new U(s,t,h))}),this._sortedRenderers.sort((e,r)=>e.index-r.index)}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],_(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),g(t.viewMatrix,[-e[0],-e[1],0])}_ensureDebugPatternResources(e,r){if(m(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let n=0;n<e;n++)for(let r=0;r<e;r++){const i=Math.floor(r/10),o=Math.floor(n/10);i<2||o<2||10*i>e-20||10*o>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&o?1&r^1&n?0:255:1&i^1&o?0:128)}const i=new G(e);i.samplingMode=9728,this._passParameters.texture=new k(this._rctx,i,t)}get test(){}};e([u()],I.prototype,"hasHighlights",void 0),e([u()],I.prototype,"renderOccludedFlags",void 0),e([u()],I.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([u({constructOnly:!0})],I.prototype,"parent",void 0),e([u({readOnly:!0})],I.prototype,"_techniques",null),e([u({type:Boolean,readOnly:!0})],I.prototype,"updating",null),e([u()],I.prototype,"isEmpty",null),I=e([p("esri.views.3d.terrain.OverlayRenderer")],I);class U{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const B=[[1,.5,.5],[.5,.5,1]],H=-2,L=4,z=new M;z.hasAlpha=!0;export{I as OverlayRenderer,H as drapedZ,L as overlayRenderOccludedFlag};
|
|
5
|
+
import{__decorate as e}from"tslib";import{unique as r}from"../../../core/arrayUtils.js";import{EventEmitter as t}from"../../../core/Evented.js";import"../../../core/has.js";import{someMap as s,everyMap as i}from"../../../core/MapUtils.js";import{disposeMaybe as n}from"../../../core/maybe.js";import o from"../../../core/PooledArray.js";import{watch as a,on as h,syncAndInitial as d,initial as l}from"../../../core/reactiveUtils.js";import{someSet as c}from"../../../core/SetUtils.js";import{property as u,subclass as p}from"../../../core/accessorSupport/decorators.js";import{ortho as _,fromTranslation as g}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{h as m}from"../../../chunks/vec32.js";import{ones as y}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{debugFlags as f}from"../support/debugFlags.js";import{Overlay as R}from"./Overlay.js";import{OverlayRenderTargets as v}from"./OverlayRenderTargets.js";import w from"../webgl/RenderCamera.js";import{T as x}from"../../../chunks/TextureOnly.glsl.js";import{SyncRenderPlugin as T}from"../webgl-engine/effects/RenderPlugin.js";import{trackHighlightOptions as b,renderHighlightBuffer as O}from"../webgl-engine/effects/highlight/Highlight.js";import{GLMaterialRepository as S}from"../webgl-engine/lib/GLMaterialRepository.js";import{GridLocalOriginFactory as D}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderContext as C,defaultRenderOccludedMask as P}from"../webgl-engine/lib/RenderContext.js";import{ShadowMap as j}from"../webgl-engine/lib/ShadowMap.js";import{TextureTechnique as E}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as M}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{AmbientLight as F}from"../webgl-engine/lighting/Lightsources.js";import{O as W}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as q}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as V,noBudget as A}from"../../support/Scheduler.js";import{Texture as k}from"../../webgl/Texture.js";import{TextureDescriptor as G}from"../../webgl/TextureDescriptor.js";let I=class extends T{constructor(e){super(e),this._overlays=null,this._renderTargets=null,this._overlayParameters=new W,this.hasHighlights=!1,this.renderOccludedFlags=1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new o,this._passParameters=new x,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new w,this.events=new t,this.longitudeCyclical=null,this.produces=new Map([[19,e=>8!==e||this.hasHighlights],[20,()=>this._hasWater]]),this._hasTargetWithoutRasterImage=!1,this._hasDrapedFeatureSource=!1,this._hasDrapedRasterSource=!1,this._hasDrapedFlowSource=!1}initialize(){const e=this._view,r=e.stage,t=r.renderer.fboCache,{waterTextures:s,techniques:i}=r.renderView;this._renderContext=new C(this._rctx,new j(t,e.state.viewingMode),i),this.addHandles([a(()=>s.updating,()=>this.events.emit("content-changed"),d),a(()=>this._spatialReference,e=>this._localOriginFactory=new D(e),d),h(()=>e.allLayerViews,"after-changes",()=>this._sortedDrapeSourceRenderersDirty=!0),a(()=>b(e.state.highlights),()=>this._sortedDrapeSourceRenderersDirty=!0,l),a(()=>e.state.highlights,r=>{this._bindParameters.highlights=r,this._bindParameters.highlightOrderMap=e.state.highlightOrderMap},l),e.resourceController.scheduler.registerTask(V.OVERLAY_RENDERER,this)]);const n=this._camera;n.near=1,n.far=1e4,n.relativeElevation=null,this._bindParameters.slot=19,this._bindParameters.camera=n,this._bindParameters.updateLighting([new F(y())],0,0,0)}destroy(){this._renderers.forEach(e=>e.destroy()),this._renderers.clear(),this._passParameters.texture=n(this._passParameters.texture),this.disposeOverlays(),this._renderContext=null,this._sortedRenderers.prune()}get _bindParameters(){return this._renderContext.bind}get _rctx(){return this._stage.renderView.renderingContext}get _view(){return this.parent.view}get _stage(){return this.parent.view.stage}get _spatialReference(){return this.parent.spatialReference}get _techniques(){return this._stage.renderView.techniques}get rctx(){return this._rctx}get materials(){return this._pluginContext.materials}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}get pluginContext(){return this._pluginContext}initializeRenderContext(e){const r=new S(this._view.stage.renderView.textures,this._techniques,()=>{this._onMaterialOrContentChanged(),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")},()=>this.events.emit("content-changed"));this._pluginContext={...e,materials:r},this._techniques.precompile(q)}uninitializeRenderContext(){}acquireTechniques(){return[]}render(){}get updating(){return this._sortedDrapeSourceRenderersDirty||s(this._renderers,e=>e.updating||e.canCompact)}get hasOverlays(){return null!=this._overlays&&null!=this._renderTargets}getMaterialRenderer(e){for(const r of this._renderers.values()){const t=r.getMaterialRenderer(e);if(t)return t}return null}get layers(){return this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers(),r(this._sortedRenderers.map(e=>e.drapeSource.layer).filter(e=>!!e))}registerDrapeSource(e,r){const t=this._renderers.get(e);null!=t&&t.destroy(),this._renderers.set(e,r),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(a(()=>e.fullOpacity,()=>this.events.emit("content-changed")),e)}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._renderTargets?.computeValidity()??0}releaseRenderTargets(e){this._renderTargets?.dispose(e)}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){this._hasTargetWithoutRasterImage=!!this._overlays&&c(e,e=>1===e.drapeTargetType)}ensureDrapeSources(e){this._overlays?(this._hasDrapedFeatureSource=c(e,e=>1===e.drapeSourceType),this._hasDrapedRasterSource=c(e,e=>0===e.drapeSourceType),this._hasDrapedFlowSource=c(e,e=>2===e.drapeSourceType)):this._hasDrapedFeatureSource=this._hasDrapedRasterSource=this._hasDrapedFlowSource=!1}get _needsColorWithoutRasterImage(){return this._hasDrapedRasterSource&&this._hasDrapedFeatureSource&&this._hasTargetWithoutRasterImage}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._renderTargets=new v(this._stage.renderer.fboCache),this._overlays=[new R,new R]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._renderTargets?.dispose(1),this._renderTargets=null,this.events.emit("textures-disposed")}_useOverlayColorInsteadOfColorNoRasterImage(e){return 1===e&&!this._needsColorWithoutRasterImage&&this._hasDrapedFeatureSource}getTexture(e){const r=this._useOverlayColorInsteadOfColorNoRasterImage(e);return this._renderTargets?.getTexture(r?0:e)}get readyToRun(){return this.updating}runTask(e){this._processDrapeSources(e,()=>!0)}_onMaterialOrContentChanged(){this.renderOccludedFlags=s(this._renderers,e=>e.hasOccluders)?L:1}_processDrapeSources(e,r){let t=!1;for(const[s,i]of this._renderers){if(e.done)break;(s.destroyed||r(s))&&(i.commitChanges()&&(t=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,t=!0,this._updateSortedDrapeSourceRenderers(),e.madeProgress()),this.compact(e),t&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this._onMaterialOrContentChanged(),this.hasHighlights=s(this._renderers,e=>e.hasHighlights),this.events.emit("content-changed"))}compact(e){let r=!1;for(const t of this._renderers.values()){if(e.done)break;r=t.compact(e)||r}return r&&this.notifyChange("updating"),r}hasHighlight(e){return s(this._renderers,r=>r.hasHighlight(e))}processSyncDrapeSources(){this._processDrapeSources(A,e=>1===e.updatePolicy)}get isEmpty(){return!f.OVERLAY_DRAW_DEBUG_TEXTURE&&i(this._renderers,e=>e.isEmpty)}get hasWater(){const e=s(this._renderers,({hasWater:e})=>e);return e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water")),this._hasWater}renders(e){if(f.OVERLAY_DRAW_DEBUG_TEXTURE&&4!==e&&2!==e)return!0;if(!this._overlays)return!1;const r=this._overlays[0];for(const i of this._overlays)i.setupGeometryViews(this.longitudeCyclical);if(!r.hasSomeSizedView())return!1;const t=this._setOutput(this._renderTargets?.targets.find(r=>r.content===e)?.output??0);++this._techniques.precompiling;const s=this._sortedRenderers.some(({renderer:e})=>e.precompile(this._renderContext));return--this._techniques.precompiling,this._setOutput(t),s}_setOutput(e){const r=this._renderContext.output;return this._renderContext.output=e,this._bindParameters.slot=2===e?20:19,r}get mode(){return this.isEmpty?0:this.hasWater&&this.renders(3)?2:this._renderTargets?.getTexture(0)?1:0}updateAnimation(e){let r=!1;return this._renderers.forEach(t=>r=t.updateAnimation(e)||r),r&&this.parent.requestRender(0),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}precompileShaders(e){if(!this._overlays||!this._renderTargets)return!1;const r=this._bindParameters;r.alignPixelEnabled=e.alignPixelEnabled,++this._techniques.precompiling;for(const t of this._renderTargets.targets){if(1===t.content&&!this._needsColorWithoutRasterImage)continue;const{output:e}=t;this._setOutput(e),8===e&&(r.highlightMixTexture=r.highlights.length>1?this._rctx.emptyTexture:null);const s=this._renderContext.renderOccludedMask;4===t.content&&(this._renderContext.renderOccludedMask=L),this._sortedRenderers.forAll(({drapeSource:e,renderer:r})=>{1===t.content&&0===e.drapeSourceType||4===t.content&&r.hasOnlyOccluders||r.precompile(this._renderContext)}),this._renderContext.renderOccludedMask=s,r.highlightMixTexture=null}return--this._techniques.precompiling,!0}drawOverlays(e,r){if(!this._overlays||!this._renderTargets)return;for(const s of this._overlays)s.setupGeometryViews(this.longitudeCyclical);this._bindParameters.alignPixelEnabled=e.alignPixelEnabled;const t=this.allSourcesOccluders;for(const s of this._renderTargets.targets){if(!(0===s.content&&this._hasDrapedFlowSource)&&!s.handleRenderRequest(r)||1===s.content&&!this._needsColorWithoutRasterImage||4===s.content&&t)continue;const e=this._drawTarget(0,s),i=this._drawTarget(1,s);(e||i)&&s.fbo.generateMipMap()}}_drawTarget(e,r){const t=this._overlays[e],s=t.canvasGeometries;if(0===s.numViews)return!1;const i=this._view.state.contentPixelRatio;this._screenToWorldRatio=i*t.mapUnitsPerPixel/this._bindParameters.overlayStretch;const{output:n,content:o}=r;if(this.isEmpty||2===n&&!this.hasWater||!t.hasSomeSizedView())return!1;const{_rctx:a,_camera:h,_renderContext:d,_bindParameters:l}=this;if(h.pixelRatio=t.pixelRatio*i,this._setOutput(n),l.screenToWorldRatio=this._screenToWorldRatio,l.screenToPCSRatio=this._screenToWorldRatio*this.parent.worldToPCSRatio,4===o&&(d.renderOccludedMask=L),!this.renders(o))return d.renderOccludedMask=P,!1;const{resolution:c}=t,u=0===e,p=u?0:c;a.setViewport(p,0,c,c),this._bindTargetFBO(r),u&&(8===n?a.gl.clearBufferuiv(a.gl.COLOR,0,[0,0,0,0]):(a.setClearColor(0,0,0,0),a.clear(16384)));if(f.OVERLAY_DRAW_DEBUG_TEXTURE&&4!==o&&2!==o){this._techniques.precompile(E,z);const r=this._techniques.get(E,z);for(let i=0;i<s.numViews;i++)this._setViewParameters(s.extents[i],t),this._ensureDebugPatternResources(t.resolution,B[e]),a.bindTechnique(r,l,this._passParameters),a.screen.draw()}if(8===n){const{fboCache:t}=this._stage.renderer,s=this._resolution;this._bindTargetFBO(r),O(a,t,{width:s,height:s},l,()=>this._renderAllGeometry(e,r),p)}else this._renderAllGeometry(e,r);return a.bindFramebuffer(null),d.renderOccludedMask=P,!0}get allSourcesOccluders(){return i(this._renderers,e=>e.hasOnlyOccluders)}_renderAllGeometry(e,r){const t=this._overlays[e],s=t.canvasGeometries;this._sortedRenderers.forAll(({drapeSource:i,renderer:n})=>{if(1===r.content&&0===i.drapeSourceType)return;const{fullOpacity:o}=i,a=null!=o&&o<1&&0===r.output&&this._bindTemporaryFBO();for(let e=0;e<s.numViews;e++)this._setViewParameters(s.extents[e],t),n.render(this._renderContext);if(a){this._bindTargetFBO(r),this._overlayParameters.texture=a.getTexture(),this._overlayParameters.opacity=o,this._overlayParameters.overlayIndex=e;const t=this._techniques.get(q);this._rctx.bindTechnique(t,this._bindParameters,this._overlayParameters),this._rctx.screen.draw(),a.release()}})}_bindTargetFBO(e){const r=this._resolution,t=2*r;e.fbo.ensureFramebuffer(t,r),e.fbo.bind(this._rctx)}_bindTemporaryFBO(){const e=this._resolution,r=2*e,t=this._stage.renderer.fboCache,s=t.acquire(r,e,"overlay tmp");return t.rctx.bindFramebuffer(s.fbo),t.rctx.clear(16384),s}get _resolution(){return this._overlays?.[0].resolution??0}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){this._sortedDrapeSourceRenderersDirty&&this._updateSortedDrapeSourceRenderers();let i=0;for(const{renderer:n}of this._sortedRenderers)i=n.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this._view.map.allLayers.map(e=>e.uid),r=e.length;this._renderers.forEach((t,s)=>{const i=e.indexOf(s.layer?.uid),n=i>=0,o=s.renderGroup??(n?0:1),a=s.drapeSourcePriorityOffset??0,h=r*o+(n?i:0)+a;this._sortedRenderers.push(new U(s,t,h))}),this._sortedRenderers.sort((e,r)=>e.index-r.index)}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],_(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),g(t.viewMatrix,[-e[0],-e[1],0])}_ensureDebugPatternResources(e,r){if(m(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let n=0;n<e;n++)for(let r=0;r<e;r++){const i=Math.floor(r/10),o=Math.floor(n/10);i<2||o<2||10*i>e-20||10*o>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&o?1&r^1&n?0:255:1&i^1&o?0:128)}const i=new G(e);i.samplingMode=9728,this._passParameters.texture=new k(this._rctx,i,t)}get test(){}};e([u()],I.prototype,"hasHighlights",void 0),e([u()],I.prototype,"renderOccludedFlags",void 0),e([u()],I.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([u({constructOnly:!0})],I.prototype,"parent",void 0),e([u({readOnly:!0})],I.prototype,"_techniques",null),e([u({type:Boolean,readOnly:!0})],I.prototype,"updating",null),e([u()],I.prototype,"isEmpty",null),I=e([p("esri.views.3d.terrain.OverlayRenderer")],I);class U{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const B=[[1,.5,.5],[.5,.5,1]],H=-2,L=4,z=new M;z.hasAlpha=!0;export{I as OverlayRenderer,H as drapedZ,L as overlayRenderOccludedFlag};
|
|
@@ -39,22 +39,22 @@ float absCosAngle;
|
|
|
39
39
|
return groundRelative;
|
|
40
40
|
}
|
|
41
41
|
`),u.draped&&!u.hasVerticalOffset||i(v),u.draped||(v.uniforms.add(new f("perDistancePixelRatio",e=>Math.tan(e.camera.fovY/2)/(e.camera.fullViewport[2]/2))),v.code.add(c`
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
void applyHUDVerticalGroundOffset(vec3 normalModel, inout vec3 posModel, inout vec3 posView) {
|
|
43
|
+
float distanceToCamera = length(posView);
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
// Compute offset in world units for a half pixel shift
|
|
46
|
+
float pixelOffset = distanceToCamera * perDistancePixelRatio * ${c.float(p)};
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
// Apply offset along normal in the direction away from the ground surface
|
|
49
|
+
vec3 modelOffset = normalModel * aboveGround * pixelOffset;
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
// Apply the same offset also on the view space position
|
|
52
|
+
vec3 viewOffset = (viewNormal * vec4(modelOffset, 1.0)).xyz;
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
posModel += modelOffset;
|
|
55
|
+
posView += viewOffset;
|
|
56
|
+
}
|
|
57
|
+
`)),u.screenCenterOffsetUnitsEnabled&&n(v),u.hasScreenSizePerspective&&o(v),v.code.add(c`
|
|
58
58
|
vec4 projectPositionHUD(out ProjectHUDAux aux) {
|
|
59
59
|
vec3 centerOffset = centerOffsetAndDistance.xyz;
|
|
60
60
|
float pointGroundDistance = centerOffsetAndDistance.w;
|