@arcgis/core 4.34.0-next.30 → 4.34.0-next.32
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/WebScene.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0ca8d6516323fc28dd58.js +1 -0
- package/assets/esri/core/workers/chunks/{031c4b4bf78079d0002d.js → 36024406932b0a44a74a.js} +1 -1
- package/assets/esri/core/workers/chunks/{4e267a813e8b10d10b3b.js → 37bfc1a771792b6697fd.js} +121 -140
- package/assets/esri/core/workers/chunks/42c5d957813080143e5a.js +1 -0
- package/assets/esri/core/workers/chunks/6269c4bbf0f224a954e9.js +1 -0
- package/assets/esri/core/workers/chunks/871da12fb3029177df6f.js +1 -0
- package/assets/esri/core/workers/chunks/8abcf9d3343dd8d45103.js +1 -0
- package/assets/esri/core/workers/chunks/ac88e0aabbd6c1f1ec98.js +1 -0
- package/assets/esri/core/workers/chunks/{e7209654ecdfde926272.js → eec36628e638e244f452.js} +1 -1
- package/chunks/ComponentShader.glsl.js +34 -33
- package/chunks/DefaultMaterial.glsl.js +25 -25
- package/chunks/Path.glsl.js +20 -24
- package/chunks/RealisticTree.glsl.js +18 -20
- package/chunks/Terrain.glsl.js +32 -33
- package/chunks/WaterSurface.glsl.js +16 -16
- package/config.js +1 -1
- package/core/workers/registry.js +1 -1
- package/interfaces.d.ts +22 -25
- package/kernel.js +1 -1
- package/layers/MapImageLayer.js +1 -1
- package/package.json +1 -1
- package/portal/schemas/definitions.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/layers/support/MediaLayerInteraction.js +1 -1
- package/views/3d/environment/Precipitation.js +1 -1
- package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DView.js +1 -1
- package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DView.js +1 -1
- package/views/3d/layers/FlowSubView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/MapImageLayerView3D.js +1 -1
- package/views/3d/layers/MediaLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Labeler.js +1 -1
- package/views/3d/layers/support/MediaLayerInteraction.js +1 -1
- package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
- package/views/3d/support/engineContent/line.js +1 -1
- package/views/3d/support/flow/FlowSubViewExtent3D.js +1 -1
- package/views/3d/support/flow/FlowSubViewTiles3D.js +1 -1
- package/views/3d/support/flow/FlowWorker.js +5 -0
- package/views/3d/support/flow/FlowWorkerHandle.js +5 -0
- package/views/3d/support/flow/geometryUtils.js +1 -1
- package/views/3d/support/flow/loadUtils.js +1 -1
- package/views/3d/support/hitTest.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentShader.glsl.js +1 -1
- package/views/3d/webgl-engine/core/material/RenderTexture.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js +3 -5
- package/views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepthToReadShadowMap.glsl.js +7 -0
- package/views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepthToWriteShadowMap.glsl.js +11 -0
- package/views/3d/webgl-engine/core/shaderLibrary/Transform.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +6 -2
- package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
- package/views/3d/webgl-engine/lib/TextureUpdater.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/Path.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/RealisticTree.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/Terrain.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/WaterSurface.glsl.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/View.js +1 -1
- package/views/draw/support/Box.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/webgl/RenderingContext.js +1 -1
- package/views/webgl/Util.js +1 -1
- package/views/webgl/checkWebGLError.js +1 -1
- package/views/webgl/testFloatBufferBlend.js +1 -1
- package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileInteraction.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileLineView.js +1 -1
- package/widgets/Feature/support/arcadeFeatureUtils.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/UtilityNetworkTrace.js +1 -1
- package/assets/esri/core/workers/chunks/278df50f2c557be81808.js +0 -1
- package/assets/esri/core/workers/chunks/2931fd6bb123200622c2.js +0 -1
- package/assets/esri/core/workers/chunks/4cf2894bda9e38af8790.js +0 -1
- package/assets/esri/core/workers/chunks/6a0777cf1270fcab4574.js +0 -1
- package/assets/esri/core/workers/chunks/9723512bc9db4a301c72.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{forEach as s,result as i}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import l from"../../../../core/Logger.js";import{disposeMaybe as a,abortMaybe as r}from"../../../../core/maybe.js";import{throwIfAborted as o,isAbortError as n}from"../../../../core/promiseUtils.js";import{watch as c}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/RandomLCG.js";import{subclass as b}from"../../../../core/accessorSupport/decorators/subclass.js";import{fromValues as u}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{hydrateGraphic as p}from"../../../../layers/graphics/hydratedFeatures.js";import{createLabelFunction as d}from"../../../../layers/support/labelFormatUtils.js";import{hasCalloutSupport as y}from"../../../../symbols/callouts/calloutUtils.js";import{make as g}from"./Graphics3DCalloutSymbolLayerFactory.js";import{LineCalloutCreationContext as f,LineCalloutSymbolLayerRenderingInfo as m}from"./Graphics3DLineCalloutSymbolLayer.js";import{getGraphics3DSymbol as x}from"./graphicSymbolUtils.js";import{LabelInfo as C}from"./LabelInfo.js";import{LabelParameters as _}from"./LabelParameters.js";import{horizontalPlacementFromAnchor as L,verticalPlacementFromAnchor as v,textRenderAlignmentFromHorizontalPlacement as G}from"./placementUtils.js";import{placePointOnGeometry as w}from"./pointUtils.js";import{TextRenderer as D}from"../../webgl-engine/lib/TextRenderer.js";import{TextRenderParameters as A}from"../../webgl-engine/lib/TextRenderParameters.js";import{TextTextureAtlas as T}from"../../webgl-engine/lib/TextTextureAtlas.js";import{WebGLLayer as I}from"../../webgl-engine/lib/WebGLLayer.js";import{hasLayerBasedScaleVisibility as S,isInEffectiveScaleRange as P}from"../../../support/layerViewUtils.js";import{TaskPriority as R}from"../../../support/Scheduler.js";import{Yield as j}from"../../../support/Yield.js";class V{constructor(e,t){this.labelingContext=e,this.graphics3DGraphic=t,this.hasGraphics3DResources=!1,this.visible=!1,this.textureAtlasHandles=[],this.textInitialized=!1,this.textRenderers=new Array,this.textLabelPlacements=new Array}}class O{constructor(e,t,s,i,l){this.labelClass=e,this.graphics3DSymbol=t,this.graphics3DCalloutSymbolLayer=s,this.textRenderParameters=i,this.labelFunction=l,this.calloutSymbolLayerIndex=0,this.graphics=new Map,this.scaleVisibility=null}}class z{constructor(e,t,s,i,l,a,r,o){this.layer=t,this.graphics3DCore=s,this.scaleVisibility=i,this.emptySymbolLabelSupported=l,this.elevationInfoOverride=a,this.disablePlacement=r,this.active=o,this.labelClassAbortController=new AbortController,this.labelClassContexts=new Array,this.graphics=new Map,this.labelsToInitialize=new Map,this.stageLayer=new I(e,{pickable:!0},s.owner.layerViewUid)}destroy(){this.stageLayer.destroy()}}let E=class extends t{constructor(e){super(e),this._hudMaterials=new Map,this._calloutMaterials=new Map,this._dirty=!1,this._labels=new Map,this._labelingContexts=new Array}setup(){this.dispose(),this.addHandles([c(()=>this.view.state?.camera,()=>this.setDirty()),c(()=>this.view.state?.rasterPixelRatio,()=>this._resetAllLabels()),c(()=>this.view.focusAreasView?.polygons,()=>this._updateFocus()),this.view.resourceController.scheduler.registerTask(R.LABELER,this)]),S()&&this.addHandles(c(()=>this.view.scale,()=>this._updateScaleVisibility())),this._textTextureAtlas=new T({view:this.view})}dispose(){this.removeAllHandles(),this._textTextureAtlas=a(this._textTextureAtlas),this._hudMaterials.clear(),this._calloutMaterials.clear(),this._labelingContexts.length=0,this._labels.clear()}destroy(){this.dispose(),B.graphic=null,B.renderingInfo=null,B.layer=null}_updateFocus(){this._labelingContexts.forEach(e=>{e.graphics.forEach(t=>{if(0===t.labelLayers.length)return;const s=w(t.graphic.geometry);if(null==s)return;const i=this.view.focusAreasView?.containsGeometry(s)??!0;t.labelLayers.forEach(s=>{s.stageObject.geometries.some(e=>e.material.parameters.isFocused!==i)&&(this._removeGraphic(e,t),this._addGraphic(e,t),this.setDirty())})})})}_activateLabelingContext(e){e.graphics.forEach((t,s)=>{const i=new V(e,t);this._labels.set(s,i),e.labelsToInitialize.set(s,i),t.setVisibilityFlag(16,1,!0)}),e.active=!0}_deactivateLabelingContext(e){e.graphics.forEach((e,t)=>{e.setVisibilityFlag(16,1,!1),this.setLabelGraphicVisibility(e,!1),e.clearLabelGraphics(),this._labels.delete(t)}),e.active=!1}_addLabelTextureToAtlas(e){if(this._textTextureAtlas)for(const t of e.graphics3DGraphic.labelLayers){if(!t.labelClass)continue;const s=e.textRenderers[t.labelClassContextIndex];s&&(e.textureAtlasHandles.push(this._textTextureAtlas.addText(s,e=>M(t.stageObject,e))),F(t.stageObject,s))}}_removeLabelTextureFromAtlas(e){e.textureAtlasHandles.forEach(e=>e.remove()),e.textureAtlasHandles.length=0}get running(){return this.view.ready&&(this._dirty||this.deconflictor.running)}runTask(e){return this._updateLabels(e),!this._dirty&&this.deconflictor.running&&this.deconflictor.runTask(e),j}_updateLabels(e){if(this._dirty){this._dirty=!1;for(const t of this._labelingContexts)if(t.active)if(H(t))this._dirty=!0;else if(U(t.labelClassContexts)){if(null===t.labelClassContexts){this._deactivateLabelingContext(t);continue}this._createLabelClassContext(t),this._dirty=!0}else for(const[s,i]of t.labelsToInitialize)if(this._ensureGraphics3DResources(i)&&(this._labels.set(s,i),this.deconflictor.setDirty(),e.madeProgress()),(i.visible&&i.textInitialized||!i.visible&&i.hasGraphics3DResources)&&(t.labelsToInitialize.delete(s),e.madeProgress()),e.done){this._dirty=!0;break}this._dirty||this.notifyChange("updating")}}async _createLabelClassContextAsync(e){const t=e.labelClassAbortController?.signal;e.layer.when&&await e.layer.when(),o(t),e.scaleVisibility?.updateScaleRangeActive();const a=e.graphics3DCore,r=a.layer,n=r.labelingInfo?.filter(e=>!!e.symbol);if(!n||0===n.length)return;let c=!1;await s(n,async(s,r)=>{const n=s.symbol,h=x(a.getOrCreateGraphics3DSymbol(n));if(null==h)return void l.getLogger(this).error("Failed to create Graphics3DSymbol for label");await h.load(),o(t);let b=null;y(n)&&n.hasVisibleCallout()&&(b=g(n,a.symbolCreationContext),await b.load(),o(t));const u=await i(d(s,e.layer.fieldsIndex,this.view.spatialReference));if(o(t),!0===u.ok){const i=await this._createTextRenderParameters(h.symbol);o(t);const l=new O(s,h,b,i,u.value);this._updateLabelClassContextVisibility(l),e.labelClassContexts[r]=l}else l.getLogger(this).error(`Label expression failed to evaluate: ${u.error}`),c=!0}),o(t)}async _createLabelClassContext(e){return null==e.labelClassPromise&&(e.labelClassPromise=this._createLabelClassContextAsync(e).catch(t=>{if(n(t))throw t;e.labelClassContexts.length=0}).then(()=>{e.labelClassAbortController=null,this.notifyChange("updating")}).catch(()=>{}),this.notifyChange("updating")),e.labelClassPromise}async _createTextRenderParameters(e){const t=e.symbolLayers.at(0);return"text"!==t?.type?null:A.fromSymbol(t,this.view.state.rasterPixelRatio)}_destroyLabelClassContext(e){for(const s of e.labelClassContexts)--s.graphics3DSymbol.referenced;const t=e.labelClassAbortController;e.labelClassAbortController=new AbortController,r(t),e.labelClassContexts.length=0,e.labelClassPromise=null,this.notifyChange("updating")}_createTextSymbolGraphic(e,t,s,i,l,a){if(!this._textTextureAtlas)return null;const r=new _(s,L(s.anchor),v(s.anchor),e.text,u(e.displayWidth,e.displayHeight));return B.graphic=t,B.layer=i,B.renderingInfo=null,l.createLabel(B,r,this._hudMaterials,this._textTextureAtlas,()=>a.placement?.elevationOffset??null)}_createLineCalloutGraphic(e,t,s,i,l){B.graphic=e,B.layer=l;const a=i.screenOffset[0];return B.renderingInfo=new m(null,t,i.translation,i.centerOffset,a,i.centerOffsetUnits,i.elevationOffset),s.createGraphics3DGraphic(B,this._calloutMaterials)}_ensureGraphics3DResources(e){if(e.hasGraphics3DResources)return!1;const t=e.graphics3DGraphic;if(t.destroyed)return!1;this._ensureTextTextureResources(e);const s=e.labelingContext,i=s.labelClassContexts;if(U(i)||!s.emptySymbolLabelSupported&&0===t.layers.length)return!1;let l=!1;const a=t.graphic,r=s.layer,o=W(s.layer);for(let n=0;n<i.length;n++){const c=e.textRenderers[n],h=e.textLabelPlacements[n];if(null==c||null==h)continue;const b=i[n],u=b.graphics3DSymbol,p=k(u),d=u.symbolLayers[0];if(!d)continue;d.setElevationInfoOverride(s.elevationInfoOverride);const y=new C(t,p,b.labelClass),g=this._createTextSymbolGraphic(c,a,h,r,d,y);if(null==g)return!1;g.labelClass=b.labelClass,g.labelClassContextIndex=n,t.addLabelGraphic(g,s.stageLayer),this.deconflictor.setPriority(t,b.textRenderParameters?.definition.size??0),t.setVisibilityFlag(16,1,o),t.setVisibilityFlag(16,2,b.scaleVisibility??!0),t.setVisibilityFlag(16,8,!1),S()&&b.graphics.set(a.uid,t),l=!0;const f=b.graphics3DCalloutSymbolLayer;if(f&&h.hasLabelVerticalOffset){f.setElevationInfoOverride(s.elevationInfoOverride);const e=this._createLineCalloutGraphic(a,p,f,h,r);null!=e&&(b.calloutSymbolLayerIndex=t.labelLayers.length,t.addLabelGraphic(e,s.stageLayer))}break}return l&&s.scaleVisibility?.updateGraphicLabelScaleVisibility(t),e.hasGraphics3DResources=!0,!0}_destroyGraphics3DResources(e){const t=e.labelingContext.labelClassContexts;for(const s of e.graphics3DGraphic.labelLayers){if(null==s.labelClass)continue;const e=t[s.labelClassContextIndex].graphics3DSymbol.symbolLayers[0];e?.onRemoveGraphic(s)}e.graphics3DGraphic.clearLabelGraphics(),e.hasGraphics3DResources=!1}_ensureTextTextureResources(e){if(e.textInitialized)return;const t=e.labelingContext,s=t.labelClassContexts;if(U(s))return;const i=e.graphics3DGraphic.graphic;for(let a=0;a<s.length;a++){const r=s[a];if(e.textRenderers[a]=null,e.textLabelPlacements[a]=null,null==r?.textRenderParameters)continue;const o=r.labelFunction;let n;if("arcade"===o.type)try{const e=o.needsHydrationToEvaluate()?p(i,t.layer):i;n=o.evaluate(e)}catch(l){n=null}else n=o.evaluate(i);if(null==n||""===n||/^\s+$/.test(n))continue;const c=r.graphics3DSymbol;if(!c.symbolLayers[0])continue;const h=e.graphics3DGraphic,b="label-3d"===c.symbol?.type?c.symbol:null,u=r.labelClass,d=t.disablePlacement,y=new C(h,b,u,d).placement;if(null==y)continue;const g=L(y.anchor),f=G(g);e.textRenderers[a]=new D(n,f,r.textRenderParameters,T.maxSize),e.textLabelPlacements[a]=y}e.textInitialized=!0}_destroyTextTextureResources(e){e.textInitialized=!1,e.textRenderers.length=0,e.textLabelPlacements.length=0}_addGraphic(e,t){const s=t.graphic.uid;if(e.graphics.set(s,t),e.active){const i=new V(e,t);this._labels.set(s,i),e.labelsToInitialize.set(s,i)}this.setDirty(),this.deconflictor.setDirty()}_updateGraphicGeometry(e,t){const s=t.graphic.uid,i=this._labels.get(s);if(!i)return!0;for(const l of i.graphics3DGraphic.labelLayers){if(null==l.labelClass)continue;if(!e.labelClassContexts[l.labelClassContextIndex].graphics3DSymbol.symbolLayers[0].updateGeometry(l,t.graphic.geometry))return!1}return this.setDirty(),this.deconflictor.setDirty(),!0}_removeGraphic(e,t){const s=t.graphic.uid,i=this._labels.get(s);e.graphics.delete(s),i&&(this._destroyGraphic(i,s),e.labelsToInitialize.delete(s),this.setDirty(),this.deconflictor.setDirty())}_destroyGraphic(e,t){this._labels.delete(t),e.textureAtlasHandles.length&&this._removeLabelTextureFromAtlas(e),this._destroyTextTextureResources(e),e.hasGraphics3DResources&&this._destroyGraphics3DResources(e)}async _labelingInfoChange(e,t){if(!t)return this._visibilityInfoChange(e),this._resetLabels(e),this._createLabelClassContext(e);for(const s of t){const t=e.graphics.get(s);t&&(this._removeGraphic(e,t),this._addGraphic(e,t))}}_globalPropertyChanged(e,t){for(const s of t.labelClassContexts){const i=new Map;t.graphics.forEach(e=>i.set(e.graphic.uid,e));const l=e=>e.labelLayers[0];if(s.graphics3DSymbol.symbolLayers[0].globalPropertyChanged(e,i,l),s.graphics3DCalloutSymbolLayer){const t=e=>e.labelLayers[s.calloutSymbolLayerIndex];s.graphics3DCalloutSymbolLayer.globalPropertyChanged(e,i,t)}}}_visibilityInfoChange(e){const t=W(e.layer);t&&!e.active&&this._activateLabelingContext(e),!t&&e.active&&this._deactivateLabelingContext(e),this.setDirty()}_resetAllLabels(){for(const e of this._labelingContexts)this._resetLabels(e)}_resetLabels(e){e.graphics.forEach((t,s)=>{const i=this._labels.get(s);i&&(this._destroyGraphic(i,s),i.visible=!1,e.labelsToInitialize.set(s,i))}),this._destroyLabelClassContext(e),this.setDirty(),this.deconflictor.setDirty()}_findLabelingContext(e){for(const t of this._labelingContexts)if(t.graphics3DCore===e)return t;return null}addGraphicsOwner(e,t,s){const i=s?.emptySymbolLabelSupported||!1,l=s?.elevationInfoOverride||null,a=s?.disablePlacement||null;if(this._findLabelingContext(e))return;const r=e.layer,o=new z(this.view.stage,r,e,t,i,l,a,W(r));return this._labelingContexts.push(o),this.setDirty(),{addGraphic:e=>this._addGraphic(o,e),removeGraphic:e=>this._removeGraphic(o,e),updateGraphicGeometry:e=>this._updateGraphicGeometry(o,e),layerLabelsEnabled:()=>W(o.layer),labelingInfoChange:e=>this._labelingInfoChange(o,e),elevationInfoChange:()=>this._globalPropertyChanged("elevationInfo",o),slicePlaneEnabledChange:()=>this._globalPropertyChanged("slicePlaneEnabled",o),visibilityInfoChange:()=>this._visibilityInfoChange(o),reset:()=>this._resetLabels(o),remove:()=>this._removeGraphicsOwner(e),setDirty:()=>this.setDirty()}}_removeGraphicsOwner(e){const t=this._findLabelingContext(e);if(!t)return;const s=this._labelingContexts.indexOf(t);this._labelingContexts.splice(s,1),t.graphics.forEach(e=>this._removeGraphic(t,e)),t.destroy(),this.setDirty()}_updateScaleVisibility(){for(const e of this._labelingContexts)if(e.active&&!H(e))for(const t of e.labelClassContexts)this._updateLabelClassContextVisibility(t)}_updateLabelClassContextVisibility(e){if(!S())return;const{labelClass:t,graphics:s}=e,i={minScale:t.minScale,maxScale:t.maxScale},l=P(i,this.view.scale),a=null==e.scaleVisibility||e.scaleVisibility!==l;e.scaleVisibility=l,a&&s.size&&(s.forEach(e=>e.setVisibilityFlag(16,2,l)),this.deconflictor.setDirty(),this.setDirty())}setLabelGraphicVisibility(e,t){const s=e.graphic.uid,i=this._labels.get(s);i&&i.visible!==t&&(t&&!i.textureAtlasHandles.length?(this._addLabelTextureToAtlas(i),i.textInitialized||i.labelingContext.labelsToInitialize.set(s,i)):!t&&i.textureAtlasHandles.length&&this._removeLabelTextureFromAtlas(i),i.visible=t,this.setDirty())}setDirty(){!this._dirty&&this._labelingContexts.length>0&&(this._dirty=!0,this.notifyChange("updating"))}get updating(){return this._dirty||this._textTextureAtlas?.updating||this.deconflictor.updating||this._labelingContexts.some(e=>H(e))}get updatingProgress(){if(!this.updating||!this._textTextureAtlas)return 1;const e=this._labelingContexts.length>0?this._labelingContexts.reduce((e,t)=>e+(H(t)?0:1),0)/this._labelingContexts.length:1;return(this._dirty?0:.3)+(this._textTextureAtlas.updating?0:.1)+.1*e+.5*this.deconflictor.updatingProgress}get usedMemory(){return this._textTextureAtlas?.usedMemory??0}get test(){}};function F(e,t){e.geometries[0].setAttributeData("size",[t.displayWidth,t.displayHeight]),e.geometryVertexAttributeUpdated(e.geometries[0],"size")}function M(e,t){e.geometries[0].setAttributeData("uvi",t),e.geometryVertexAttributeUpdated(e.geometries[0],"uvi",!0)}function H(e){return!!e.labelClassPromise&&!!e.labelClassAbortController}function U(e){return!e||0===e.length}function k(e){return"label-3d"===e.symbol?.type?e.symbol:null}function W(e){return!!e.labelsVisible&&!!e.labelingInfo?.some(e=>!!e.symbol)}e([h({constructOnly:!0})],E.prototype,"view",void 0),e([h({constructOnly:!0})],E.prototype,"deconflictor",void 0),e([h()],E.prototype,"_textTextureAtlas",void 0),e([h({type:Boolean,readOnly:!0})],E.prototype,"updating",null),E=e([b("esri.views.3d.layers.graphics.Labeler")],E);const B=new f(null,null,null);export{E as Labeler,W as areLabelsVisible};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{forEach as s,result as i}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import l from"../../../../core/Logger.js";import{disposeMaybe as a,abortMaybe as r}from"../../../../core/maybe.js";import{throwIfAborted as o,isAbortError as n}from"../../../../core/promiseUtils.js";import{watch as c}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/RandomLCG.js";import{subclass as b}from"../../../../core/accessorSupport/decorators/subclass.js";import{fromValues as u}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{hydrateGraphic as p}from"../../../../layers/graphics/hydratedFeatures.js";import{createLabelFunction as d}from"../../../../layers/support/labelFormatUtils.js";import{hasCalloutSupport as y}from"../../../../symbols/callouts/calloutUtils.js";import{make as g}from"./Graphics3DCalloutSymbolLayerFactory.js";import{LineCalloutCreationContext as f,LineCalloutSymbolLayerRenderingInfo as m}from"./Graphics3DLineCalloutSymbolLayer.js";import{getGraphics3DSymbol as C}from"./graphicSymbolUtils.js";import{LabelInfo as x}from"./LabelInfo.js";import{LabelParameters as _}from"./LabelParameters.js";import{horizontalPlacementFromAnchor as L,verticalPlacementFromAnchor as v,textRenderAlignmentFromHorizontalPlacement as G}from"./placementUtils.js";import{placePointOnGeometry as w}from"./pointUtils.js";import{TextRenderer as D}from"../../webgl-engine/lib/TextRenderer.js";import{TextRenderParameters as A}from"../../webgl-engine/lib/TextRenderParameters.js";import{TextTextureAtlas as T}from"../../webgl-engine/lib/TextTextureAtlas.js";import{WebGLLayer as I}from"../../webgl-engine/lib/WebGLLayer.js";import{hasLayerBasedScaleVisibility as S,isInEffectiveScaleRange as P}from"../../../support/layerViewUtils.js";import{TaskPriority as R}from"../../../support/Scheduler.js";import{Yield as j}from"../../../support/Yield.js";class V{constructor(e,t){this.labelingContext=e,this.graphics3DGraphic=t,this.hasGraphics3DResources=!1,this.visible=!1,this.textureAtlasHandles=[],this.textInitialized=!1,this.textRenderers=new Array,this.textLabelPlacements=new Array}}class O{constructor(e,t,s,i,l){this.labelClass=e,this.graphics3DSymbol=t,this.graphics3DCalloutSymbolLayer=s,this.textRenderParameters=i,this.labelFunction=l,this.calloutSymbolLayerIndex=0,this.graphics=new Map,this.scaleVisibility=null}}class z{constructor(e,t,s,i,l,a,r,o){this.layer=t,this.graphics3DCore=s,this.scaleVisibility=i,this.emptySymbolLabelSupported=l,this.elevationInfoOverride=a,this.disablePlacement=r,this.active=o,this.labelClassAbortController=new AbortController,this._labelClassContexts=new Array,this.graphics=new Map,this.labelsToInitialize=new Map,this.stageLayer=new I(e,{pickable:!0},s.owner.layerViewUid)}destroy(){this.stageLayer.destroy()}get labelClassContexts(){return this._labelClassContexts}setLabelClassContext(e,t){this._labelClassContexts[e]=t}resetLabelClassContext(){this._labelClassContexts.length=0}}let E=class extends t{constructor(e){super(e),this._hudMaterials=new Map,this._calloutMaterials=new Map,this._dirty=!1,this._labels=new Map,this._labelingContexts=new Array}setup(){this.dispose(),this.addHandles([c(()=>this.view.state?.camera,()=>this.setDirty()),c(()=>this.view.state?.rasterPixelRatio,()=>this._resetAllLabels()),c(()=>this.view.focusAreasView?.polygons,()=>this._updateFocus()),this.view.resourceController.scheduler.registerTask(R.LABELER,this)]),S()&&this.addHandles(c(()=>this.view.scale,()=>this._updateScaleVisibility())),this._textTextureAtlas=new T({view:this.view})}dispose(){this.removeAllHandles(),this._textTextureAtlas=a(this._textTextureAtlas),this._hudMaterials.clear(),this._calloutMaterials.clear(),this._labelingContexts.length=0,this._labels.clear()}destroy(){this.dispose(),B.graphic=null,B.renderingInfo=null,B.layer=null}_updateFocus(){this._labelingContexts.forEach(e=>{e.graphics.forEach(t=>{if(0===t.labelLayers.length)return;const s=w(t.graphic.geometry);if(null==s)return;const i=this.view.focusAreasView?.containsGeometry(s)??!0;t.labelLayers.forEach(s=>{s.stageObject.geometries.some(e=>e.material.parameters.isFocused!==i)&&(this._removeGraphic(e,t),this._addGraphic(e,t),this.setDirty())})})})}_activateLabelingContext(e){e.graphics.forEach((t,s)=>{const i=new V(e,t);this._labels.set(s,i),e.labelsToInitialize.set(s,i),t.setVisibilityFlag(16,1,!0)}),e.active=!0}_deactivateLabelingContext(e){e.graphics.forEach((e,t)=>{e.setVisibilityFlag(16,1,!1),this.setLabelGraphicVisibility(e,!1),e.clearLabelGraphics(),this._labels.delete(t)}),e.active=!1}_addLabelTextureToAtlas(e){if(this._textTextureAtlas)for(const t of e.graphics3DGraphic.labelLayers){if(!t.labelClass)continue;const s=e.textRenderers[t.labelClassContextIndex];s&&(e.textureAtlasHandles.push(this._textTextureAtlas.addText(s,e=>M(t.stageObject,e))),F(t.stageObject,s))}}_removeLabelTextureFromAtlas(e){e.textureAtlasHandles.forEach(e=>e.remove()),e.textureAtlasHandles.length=0}get running(){return this.view.ready&&(this._dirty||this.deconflictor.running)}runTask(e){return this._updateLabels(e),!this._dirty&&this.deconflictor.running&&this.deconflictor.runTask(e),j}_updateLabels(e){if(this._dirty){this._dirty=!1;for(const t of this._labelingContexts)if(t.active)if(H(t))this._dirty=!0;else if(U(t.labelClassContexts)){if(null===t.labelClassContexts){this._deactivateLabelingContext(t);continue}this._createLabelClassContext(t),this._dirty=!0}else for(const[s,i]of t.labelsToInitialize)if(this._ensureGraphics3DResources(i)&&(this._labels.set(s,i),this.deconflictor.setDirty(),e.madeProgress()),(i.visible&&i.textInitialized||!i.visible&&i.hasGraphics3DResources)&&(t.labelsToInitialize.delete(s),e.madeProgress()),e.done){this._dirty=!0;break}this._dirty||this.notifyChange("updating")}}async _createLabelClassContextAsync(e){const t=e.labelClassAbortController?.signal;e.layer.when&&await e.layer.when(),o(t),e.scaleVisibility?.updateScaleRangeActive();const a=e.graphics3DCore,r=a.layer,n=r.labelingInfo?.filter(e=>!!e.symbol);if(!n||0===n.length)return;let c=!1;await s(n,async(s,r)=>{const n=s.symbol,h=C(a.getOrCreateGraphics3DSymbol(n));if(null==h)return void l.getLogger(this).error("Failed to create Graphics3DSymbol for label");await h.load(),o(t);let b=null;y(n)&&n.hasVisibleCallout()&&(b=g(n,a.symbolCreationContext),await b.load(),o(t));const u=await i(d(s,e.layer.fieldsIndex,this.view.spatialReference));if(o(t),!0===u.ok){const i=await this._createTextRenderParameters(h.symbol);o(t);const l=new O(s,h,b,i,u.value);this._updateLabelClassContextVisibility(l),e.setLabelClassContext(r,l)}else l.getLogger(this).error(`Label expression failed to evaluate: ${u.error}`),c=!0}),o(t)}async _createLabelClassContext(e){return null==e.labelClassPromise&&(e.labelClassPromise=this._createLabelClassContextAsync(e).catch(t=>{if(n(t))throw t;e.resetLabelClassContext()}).then(()=>{e.labelClassAbortController=null,this.notifyChange("updating")}).catch(()=>{}),this.notifyChange("updating")),e.labelClassPromise}async _createTextRenderParameters(e){const t=e.symbolLayers.at(0);return"text"!==t?.type?null:A.fromSymbol(t,this.view.state.rasterPixelRatio)}_destroyLabelClassContext(e){for(const s of e.labelClassContexts)--s.graphics3DSymbol.referenced;const t=e.labelClassAbortController;e.labelClassAbortController=new AbortController,r(t),e.resetLabelClassContext(),e.labelClassPromise=null,this.notifyChange("updating")}_createTextSymbolGraphic(e,t,s,i,l,a){if(!this._textTextureAtlas)return null;const r=new _(s,L(s.anchor),v(s.anchor),e.text,u(e.displayWidth,e.displayHeight));return B.graphic=t,B.layer=i,B.renderingInfo=null,l.createLabel(B,r,this._hudMaterials,this._textTextureAtlas,()=>a.placement?.elevationOffset??null)}_createLineCalloutGraphic(e,t,s,i,l){B.graphic=e,B.layer=l;const a=i.screenOffset[0];return B.renderingInfo=new m(null,t,i.translation,i.centerOffset,a,i.centerOffsetUnits,i.elevationOffset),s.createGraphics3DGraphic(B,this._calloutMaterials)}_ensureGraphics3DResources(e){if(e.hasGraphics3DResources)return!1;const t=e.graphics3DGraphic;if(t.destroyed)return!1;this._ensureTextTextureResources(e);const s=e.labelingContext,i=s.labelClassContexts;if(U(i)||!s.emptySymbolLabelSupported&&0===t.layers.length)return!1;let l=!1;const a=t.graphic,r=s.layer,o=W(s.layer);for(let n=0;n<i.length;n++){const c=e.textRenderers[n],h=e.textLabelPlacements[n];if(null==c||null==h)continue;const b=i[n],u=b.graphics3DSymbol,p=k(u),d=u.symbolLayers[0];if(!d)continue;d.setElevationInfoOverride(s.elevationInfoOverride);const y=new x(t,p,b.labelClass),g=this._createTextSymbolGraphic(c,a,h,r,d,y);if(null==g)return!1;g.labelClass=b.labelClass,g.labelClassContextIndex=n,t.addLabelGraphic(g,s.stageLayer),this.deconflictor.setPriority(t,b.textRenderParameters?.definition.size??0),t.setVisibilityFlag(16,1,o),t.setVisibilityFlag(16,2,b.scaleVisibility??!0),t.setVisibilityFlag(16,8,!1),S()&&b.graphics.set(a.uid,t),l=!0;const f=b.graphics3DCalloutSymbolLayer;if(f&&h.hasLabelVerticalOffset){f.setElevationInfoOverride(s.elevationInfoOverride);const e=this._createLineCalloutGraphic(a,p,f,h,r);null!=e&&(b.calloutSymbolLayerIndex=t.labelLayers.length,t.addLabelGraphic(e,s.stageLayer))}break}return l&&s.scaleVisibility?.updateGraphicLabelScaleVisibility(t),e.hasGraphics3DResources=!0,!0}_destroyGraphics3DResources(e){const t=e.labelingContext.labelClassContexts;for(const s of e.graphics3DGraphic.labelLayers){if(null==s.labelClass)continue;const e=t[s.labelClassContextIndex].graphics3DSymbol.symbolLayers[0];e?.onRemoveGraphic(s)}e.graphics3DGraphic.clearLabelGraphics(),e.hasGraphics3DResources=!1}_ensureTextTextureResources(e){if(e.textInitialized)return;const t=e.labelingContext,s=t.labelClassContexts;if(U(s))return;const i=e.graphics3DGraphic.graphic;for(let a=0;a<s.length;a++){const r=s[a];if(e.textRenderers[a]=null,e.textLabelPlacements[a]=null,null==r?.textRenderParameters)continue;const o=r.labelFunction;let n;if("arcade"===o.type)try{const e=o.needsHydrationToEvaluate()?p(i,t.layer):i;n=o.evaluate(e)}catch(l){n=null}else n=o.evaluate(i);if(null==n||""===n||/^\s+$/.test(n))continue;const c=r.graphics3DSymbol;if(!c.symbolLayers[0])continue;const h=e.graphics3DGraphic,b="label-3d"===c.symbol?.type?c.symbol:null,u=r.labelClass,d=t.disablePlacement,y=new x(h,b,u,d).placement;if(null==y)continue;const g=L(y.anchor),f=G(g);e.textRenderers[a]=new D(n,f,r.textRenderParameters,T.maxSize),e.textLabelPlacements[a]=y}e.textInitialized=!0}_destroyTextTextureResources(e){e.textInitialized=!1,e.textRenderers.length=0,e.textLabelPlacements.length=0}_addGraphic(e,t){const s=t.graphic.uid;if(e.graphics.set(s,t),e.active){const i=new V(e,t);this._labels.set(s,i),e.labelsToInitialize.set(s,i)}this.setDirty(),this.deconflictor.setDirty()}_updateGraphicGeometry(e,t){const s=t.graphic.uid,i=this._labels.get(s);if(!i)return!0;for(const l of i.graphics3DGraphic.labelLayers){if(null==l.labelClass)continue;if(!e.labelClassContexts[l.labelClassContextIndex].graphics3DSymbol.symbolLayers[0].updateGeometry(l,t.graphic.geometry))return!1}return this.setDirty(),this.deconflictor.setDirty(),!0}_removeGraphic(e,t){const s=t.graphic.uid,i=this._labels.get(s);e.graphics.delete(s),e.labelClassContexts.forEach(e=>e.graphics.delete(s)),i&&(this._destroyGraphic(i,s),e.labelsToInitialize.delete(s),this.setDirty(),this.deconflictor.setDirty())}_destroyGraphic(e,t){this._labels.delete(t),e.textureAtlasHandles.length&&this._removeLabelTextureFromAtlas(e),this._destroyTextTextureResources(e),e.hasGraphics3DResources&&this._destroyGraphics3DResources(e)}async _labelingInfoChange(e,t){if(!t)return this._visibilityInfoChange(e),this._resetLabels(e),this._createLabelClassContext(e);for(const s of t){const t=e.graphics.get(s);t&&(this._removeGraphic(e,t),this._addGraphic(e,t))}}_globalPropertyChanged(e,t){for(const s of t.labelClassContexts){const i=new Map;t.graphics.forEach(e=>i.set(e.graphic.uid,e));const l=e=>e.labelLayers[0];if(s.graphics3DSymbol.symbolLayers[0].globalPropertyChanged(e,i,l),s.graphics3DCalloutSymbolLayer){const t=e=>e.labelLayers[s.calloutSymbolLayerIndex];s.graphics3DCalloutSymbolLayer.globalPropertyChanged(e,i,t)}}}_visibilityInfoChange(e){const t=W(e.layer);t&&!e.active&&this._activateLabelingContext(e),!t&&e.active&&this._deactivateLabelingContext(e),this.setDirty()}_resetAllLabels(){for(const e of this._labelingContexts)this._resetLabels(e)}_resetLabels(e){e.graphics.forEach((t,s)=>{const i=this._labels.get(s);i&&(this._destroyGraphic(i,s),i.visible=!1,e.labelsToInitialize.set(s,i))}),this._destroyLabelClassContext(e),this.setDirty(),this.deconflictor.setDirty()}_findLabelingContext(e){for(const t of this._labelingContexts)if(t.graphics3DCore===e)return t;return null}addGraphicsOwner(e,t,s){const i=s?.emptySymbolLabelSupported||!1,l=s?.elevationInfoOverride||null,a=s?.disablePlacement||null;if(this._findLabelingContext(e))return;const r=e.layer,o=new z(this.view.stage,r,e,t,i,l,a,W(r));return this._labelingContexts.push(o),this.setDirty(),{addGraphic:e=>this._addGraphic(o,e),removeGraphic:e=>this._removeGraphic(o,e),updateGraphicGeometry:e=>this._updateGraphicGeometry(o,e),layerLabelsEnabled:()=>W(o.layer),labelingInfoChange:e=>this._labelingInfoChange(o,e),elevationInfoChange:()=>this._globalPropertyChanged("elevationInfo",o),slicePlaneEnabledChange:()=>this._globalPropertyChanged("slicePlaneEnabled",o),visibilityInfoChange:()=>this._visibilityInfoChange(o),reset:()=>this._resetLabels(o),remove:()=>this._removeGraphicsOwner(e),setDirty:()=>this.setDirty()}}_removeGraphicsOwner(e){const t=this._findLabelingContext(e);if(!t)return;const s=this._labelingContexts.indexOf(t);this._labelingContexts.splice(s,1),t.graphics.forEach(e=>this._removeGraphic(t,e)),t.destroy(),this.setDirty()}_updateScaleVisibility(){for(const e of this._labelingContexts)if(e.active&&!H(e))for(const t of e.labelClassContexts)this._updateLabelClassContextVisibility(t)}_updateLabelClassContextVisibility(e){if(!S())return;const{labelClass:t,graphics:s}=e,i={minScale:t.minScale,maxScale:t.maxScale},l=P(i,this.view.scale),a=null==e.scaleVisibility||e.scaleVisibility!==l;e.scaleVisibility=l,a&&s.size&&(s.forEach(e=>e.setVisibilityFlag(16,2,l)),this.deconflictor.setDirty(),this.setDirty())}setLabelGraphicVisibility(e,t){const s=e.graphic.uid,i=this._labels.get(s);i&&i.visible!==t&&(t&&!i.textureAtlasHandles.length?(this._addLabelTextureToAtlas(i),i.textInitialized||i.labelingContext.labelsToInitialize.set(s,i)):!t&&i.textureAtlasHandles.length&&this._removeLabelTextureFromAtlas(i),i.visible=t,this.setDirty())}setDirty(){!this._dirty&&this._labelingContexts.length>0&&(this._dirty=!0,this.notifyChange("updating"))}get updating(){return this._dirty||this._textTextureAtlas?.updating||this.deconflictor.updating||this._labelingContexts.some(e=>H(e))}get updatingProgress(){if(!this.updating||!this._textTextureAtlas)return 1;const e=this._labelingContexts.length>0?this._labelingContexts.reduce((e,t)=>e+(H(t)?0:1),0)/this._labelingContexts.length:1;return(this._dirty?0:.3)+(this._textTextureAtlas.updating?0:.1)+.1*e+.5*this.deconflictor.updatingProgress}get usedMemory(){return this._textTextureAtlas?.usedMemory??0}get test(){}};function F(e,t){e.geometries[0].setAttributeData("size",[t.displayWidth,t.displayHeight]),e.geometryVertexAttributeUpdated(e.geometries[0],"size")}function M(e,t){e.geometries[0].setAttributeData("uvi",t),e.geometryVertexAttributeUpdated(e.geometries[0],"uvi",!0)}function H(e){return!!e.labelClassPromise&&!!e.labelClassAbortController}function U(e){return!e||0===e.length}function k(e){return"label-3d"===e.symbol?.type?e.symbol:null}function W(e){return!!e.labelsVisible&&!!e.labelingInfo?.some(e=>!!e.symbol)}e([h({constructOnly:!0})],E.prototype,"view",void 0),e([h({constructOnly:!0})],E.prototype,"deconflictor",void 0),e([h()],E.prototype,"_textTextureAtlas",void 0),e([h({type:Boolean,readOnly:!0})],E.prototype,"updating",null),E=e([b("esri.views.3d.layers.graphics.Labeler")],E);const B=new f(null,null,null);export{E as Labeler,W as areLabelsVisible};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import e from"../../../../core/Accessor.js";import{
|
|
5
|
+
import{__decorate as t}from"tslib";import e from"../../../../core/Accessor.js";import{destroyHandle as o,makeHandle as i}from"../../../../core/handleUtils.js";import{deg2rad as s}from"../../../../core/mathUtils.js";import{abortMaybe as r,destroyMaybe as a}from"../../../../core/maybe.js";import{debounce as n}from"../../../../core/promiseUtils.js";import{initial as l,watch as d,syncAndInitial as c}from"../../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as p}from"../../../../core/unitUtils.js";import{property as m}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import{fromRotation as _}from"../../../../core/libs/gl-matrix-2/math/mat2d.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/mat2df64.js";import{set as g,transformMat2d as y}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{UpdatingHandles as v}from"../../../../core/support/UpdatingHandles.js";import{ControlPointOperations as T}from"../../interactive/editingTools/media/ControlPointOperations.js";import{ViewEventPriorities as b}from"../../../input/InputManager.js";import{KeyBindings as j,mediaKeys as w}from"../../../interactive/keybindings.js";import{acquire as M}from"../../../interactive/snapping/SnappingManagerPool.js";import{loadAutomaticAreaMeasurementUtils as E}from"../../../support/automaticAreaMeasurementUtils.js";import{loadAutomaticLengthMeasurementUtils as O}from"../../../support/automaticLengthMeasurementUtils.js";const P=Symbol(),S=Symbol(),H=1,A=10;let U=class extends e{get editSourcePoints(){return!!this.options?.reshapeOptions.editSourcePoints!==this._isEditSourcePointsToggled}get updating(){return this._updatingHandles.updating}get _preferredInteractionTool(){return this.options?.tool??"transform"}get _toolType(){switch(this._preferredInteractionTool){case"transform":return"transform-3d";case"reshape":return"reshape-3d"}}get _validatedSelectedElement(){const t=this.selectedElement;if(!t)return null;const{layer:{source:e}}=this;return e?"hasElement"in e?e.hasElement(t)?t:null:e===t?t:null:null}constructor(t){super(t),this.enabled=!1,this._isEditSourcePointsToggled=!1,this._updatingHandles=new v,this._isOpacityToggled=!1,this._factor=H,this._tool=null,this._object=null,this._createToolAbortController=null,this._onPointerMove=n(async t=>{const e=await this._updatingHandles.addPromise(this._findElementAtScreenPoint(t));this.destroyed||(this.removeHandles(S),e&&e!==this.selectedElement&&this.addHandles(this.view.acquireCursor("pointer","high"),S))}),this._tmpMat2=u(),this._tmpVec2=f()}destroy(){this._createToolAbortController=r(this._createToolAbortController)}initialize(){this.addHandles([o(this._updatingHandles),this._updatingHandles.add(()=>this.enabled,t=>this._enableDisable(t),l),this._updatingHandles.add(()=>this._preferredInteractionTool,t=>this._preferredInteractionToolChanged(t))])}_enableDisable(t){if(!t)return void this.removeHandles(P);this._dynamicImports();const{view:e}=this,o=new j;o.add(w.undo,()=>{this._object?.operations?.undo(),this._object?.emit("modified-externally")}),o.add(w.redo,()=>{this._object?.operations?.redo(),this._object?.emit("modified-externally")}),o.addToggle(w.preserveAspectRatio,t=>{"transform-3d"===this._tool?.type&&(this._tool.preserveAspectRatio="key-down"===t.type)}),o.addToggle(w.editSourcePoints,t=>{"reshape-3d"===this._tool?.type&&(this._isEditSourcePointsToggled="key-down"===t.type)}),o.addToggle(w.rotateIncrements,t=>{"transform-3d"===this._tool?.type&&(this._tool.snapRotation="key-down"===t.type)}),o.add(w.toggleOpacity,()=>{const t=this._object?.element;t&&(t.opacity*=this._isOpacityToggled?2:.5,this._isOpacityToggled=!this._isOpacityToggled)}),o.add(w.moveUp,()=>this._move(0,this._factor)),o.add(w.moveDown,()=>this._move(0,-this._factor)),o.add(w.moveRight,()=>this._move(this._factor,0)),o.add(w.moveLeft,()=>this._move(-this._factor,0)),o.addToggle(w.factorModifier,t=>this._factor="key-down"===t.type?A:H),this._isOpacityToggled=!1,this.addHandles([o.register(e,b.TOOL),i(()=>{this._isOpacityToggled&&this.selectedElement&&(this.selectedElement.opacity*=2,this._isOpacityToggled=!1)}),e.on("immediate-click",t=>this._onClick(t),b.TOOL),e.on("pointer-move",t=>this._onPointerMove(t).catch(()=>{}),b.TOOL),this._updatingHandles.add(()=>this._validatedSelectedElement,(t,e)=>{e&&t!==e&&this._isOpacityToggled&&(e.opacity*=2,this._isOpacityToggled=!1),this._selectedElementChanged(t)},l),i(()=>{this.removeHandles(S),this._removeTool()})],P)}async _onClick(t){await this._updatingHandles.addPromise(t.defer(async()=>{const e=await this._findElementAtScreenPoint(t);this.destroyed||(e&&t.stopPropagation(),this.selectedElement=e,this.selectedElement&&this.removeHandles(S))}))}async _selectedElementChanged(t){t?.georeference?this._object?.element!==t&&await this._updatingHandles.addPromise(this._recreateTool()):this._removeTool()}async _recreateTool(){this._createToolAbortController=r(this._createToolAbortController),this._removeTool();const t=this._validatedSelectedElement;if(!t)return;const e=new AbortController;this._createToolAbortController=e;const{ManipulatedObject3DMediaElement:o,ExtentTransformTool:s,ReshapeTool3D:n,automaticAreaMeasurementUtils:l,automaticLengthMeasurementUtils:p}=await this._dynamicImports();if(e.signal.aborted)return;const{view:m,layer:h,_toolType:_}=this;switch(this._object=new o({view:m,layer:h,element:t,tool:this._preferredInteractionTool}),_){case"transform-3d":{this._tool=new s({view:m,object:this._object,automaticLengthMeasurementUtils:p});const t=m.inputManager;t.isModifierKeyDown(w.rotateIncrements.key)&&(this._tool.snapRotation=!0),t.isModifierKeyDown(w.preserveAspectRatio.key)&&(this._tool.preserveAspectRatio=!0)}break;case"reshape-3d":{const t=M(m),{snappingManager:e}=t;this._tool=new n({view:m,object:this._object,enableMidpoints:!1,enableZShape:!1,snappingManager:e,enableMoveObject:!1,autoHideManipulators:!0,enableDeleteVertices:!1,sketchOptions:{tooltips:{enabled:!0,inputEnabled:!0,visibleElements:{area:!1}}},automaticAreaMeasurementUtils:l,automaticLengthMeasurementUtils:p}),this.addHandles([t,d(()=>({editSourcePoints:this.editSourcePoints,operations:this._object?.operations}),t=>{t.operations instanceof T&&(t.operations.editSourcePoints=t.editSourcePoints)},c)],this._tool)}}this.addHandles([i(()=>{this._object=a(this._object),this._tool&&(m.tools.remove(this._tool),this._tool=null)})],this._tool),m.addAndActivateTool(this._tool)}_preferredInteractionToolChanged(t){const{_tool:e}=this;if(!e)return;if(this._toolType!==e.type)return void this._updatingHandles.addPromise(this._recreateTool());const{_object:o}=this;o&&(o.tool=t)}async _dynamicImports(){const[{ManipulatedObject3DMediaElement:t},{ExtentTransformTool:e,ReshapeTool3D:o},i,s]=await Promise.all([import("../../interactive/editingTools/ManipulatedObject3DMediaElement.js"),import("../../interactive/editingTools.js"),await E(),await O()]);return{ManipulatedObject3DMediaElement:t,ExtentTransformTool:e,ReshapeTool3D:o,automaticAreaMeasurementUtils:i,automaticLengthMeasurementUtils:s}}async _findElementAtScreenPoint(t){const e=(await this.view.hitTest(t,{include:[this.layer]})).results[0];return"media"===e?.type?e.element:null}_removeTool(){this._tool&&this.removeHandles(this._tool)}_move(t,e){const{view:o,_object:i}=this,r=i?.operations;if(!r)return;const a=o.overlayPixelSizeInMapUnits(o.pointsOfInterest.focus.location)*p(o.spatialReference)/p(r.data.spatialReference),{_tmpMat2:n,_tmpVec2:l}=this,d=_(n,s(360-this.view.camera.heading)),c=g(l,a*t,a*e);y(c,c,d),r.move(c[0],c[1],0),i.emit("modified-externally")}};t([m({constructOnly:!0})],U.prototype,"view",void 0),t([m({constructOnly:!0})],U.prototype,"layer",void 0),t([m()],U.prototype,"selectedElement",void 0),t([m()],U.prototype,"enabled",void 0),t([m()],U.prototype,"options",void 0),t([m()],U.prototype,"editSourcePoints",null),t([m()],U.prototype,"_isEditSourcePointsToggled",void 0),t([m()],U.prototype,"updating",null),t([m()],U.prototype,"_preferredInteractionTool",null),t([m()],U.prototype,"_validatedSelectedElement",null),U=t([h("esri.views.3d.layers.support.MediaLayerInteraction")],U);export{U as MediaLayerInteraction};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../../core/has.js";import e from"../../../../core/PooledArray.js";import{createRenderScreenPointArray3 as t,castRenderScreenPointArray3 as r}from"../../../../core/screenUtils.js";import{getMetersPerVerticalUnitForSR as
|
|
5
|
+
import"../../../../core/has.js";import e from"../../../../core/PooledArray.js";import{createRenderScreenPointArray3 as t,castRenderScreenPointArray3 as r}from"../../../../core/screenUtils.js";import{getMetersPerVerticalUnitForSR as n}from"../../../../core/unitUtils.js";import{f as i,n as s,e as o}from"../../../../chunks/vec32.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as a,copy as c,negativeInfinity as u,width as h,height as p,expandPointInPlace as d}from"../../../../geometry/support/aaBoundingRect.js";import{create as m}from"../../../../geometry/support/ray.js";import{sv3d as y}from"../../../../geometry/support/vectorStacks.js";import{getElevationOffsetInMeters as f}from"../../../../support/elevationInfoUtils.js";import{computeMapPointFromVec3d as g}from"../../support/hitTest.js";import{fromRenderAtEye as _,fromScreen as w}from"../../support/geometryUtils/ray.js";import{defaultTolerance as R,Intersector as b}from"../../webgl-engine/lib/Intersector.js";import{isValidIntersectorResult as v}from"../../webgl-engine/lib/IntersectorResult.js";import{sliceFilterPredicate as I}from"../../webgl-engine/lib/intersectorUtils.js";import{HUDMaterial as P}from"../../webgl-engine/materials/HUDMaterial.js";class j{constructor(t,r,n){this.viewingMode=t,this._forEachLayer=r,this._view=n,this._externalIntersectionHandlers=new e,this._tolerance=R,this._tmpRay=m(),this._tmpRegion=a(),this._validateHUDIntersector=new b(this.viewingMode),this._validateHUDIntersector.options.hud=!1}destroy(){this._externalIntersectionHandlers.prune()}intersectScreen(e,t,r){return this.intersectRay(this._getPickRay(e,this._tmpRay),L(this.viewingMode),t,r)}intersectScreenFreePointFallback(e,t,r){return this.intersectRayFreePointFallback(this._getPickRay(e,this._tmpRay),t,r)}intersectRayFreePointFallback(e,t,r){return this.intersectRay(e,L(this.viewingMode),t,r)||this._intersectRayFreePointLocal(e,t)}intersectRay(e,t,r,n){return t.options.selectionMode=!1,t.options.store=0,this.computeIntersection(e,t,!1,n),!!t.results.min&&t.results.min.getIntersectionPoint(r)}getCenterRayWithSubpixelOffset(e,t,r=.5,n=.5){return e.getRenderCenter(F,r,n),F[0]+=.0466,F[1]-=.0123,_(e,F,t)}intersectIntersectorScreen(e,t,r){this.computeIntersection(this._getPickRay(e,this._tmpRay),t,!1,r)}intersectToolIntersectorScreen(e,t,r){const n=this._getPickRay(e,this._tmpRay);this.intersectToolIntersectorRay(n,t,r)}intersectToolIntersectorRay(e,t,r){t.options.selectionMode=!0,this.computeIntersection(e,t,!1,r);const n=t.results.min;!!this._view.basemapTerrain&&this._view.basemapTerrain.opaque||v(n)&&2!==n.intersector||(t.options.selectionMode=!1,this.computeIntersection(e,t,!1,r))}setTolerance(e=R){this._tolerance=e}addIntersectionHandler(e){this._externalIntersectionHandlers.push(e),this._externalIntersectionHandlers.sort((e,t)=>2===e.type?1:2===t.type?-1:0)}removeIntersectionHandler(e){null!=this._externalIntersectionHandlers.removeUnordered(e)&&this._externalIntersectionHandlers.sort((e,t)=>2===e.type?1:2===t.type?-1:0)}_getPickRay(e,t){const r=this._view.state.camera;return w(r,e,t)}_intersectRayFreePointLocal(e,t){return 2!==this.viewingMode||null==e||i(t,e.origin,s(y.get(),e.direction)),!1}intersectElevationFromScreen(e,t,r=0,n=null){return this._intersectElevation(this._getPickRay(e,this._tmpRay),t,r,n)}_intersectElevation(e,t,l=0,a=null){if(null==e)return null;const c=this._view,{renderCoordsHelper:u}=c,h=n(c.spatialReference),p=null!=t?t.mode:"absolute-height",d=f(t)/h,m=("on-the-ground"!==p?d+l:0)*h/u.unitInMeters,{camera:_}=c.state;if("absolute-height"===p){const t=u?.getAltitude(_.eye),r=o(s(E,e.direction),u.worldUpAtPosition(_.eye,V));if(t<m&&r<0||t>=m&&r>0)return null;if(u.intersectInfiniteManifold(e,m,E)){const e=g(c,E);return e.z??=0,e.z-=d,e}return null}const w=r(y.get());_.projectToRenderScreen(e.origin,w);const R=new k(null,this._forEachLayer),{slice:{plane:v}}=c,P=null!=v?I(v):null,j=new b(this.viewingMode);j.options.store=0,j.options.verticalOffset=m,j.options.normalRequired=!1;const U=e.origin,x=i(y.get(),U,e.direction);j.reset(U,x,_),j.point=w;let M=null;if(a&&"type"in a&&"graphics"===a.type){const e=c.allLayerViews.find(e=>e.layer===a)?.uid;M=e?t=>t.layerViewUid===e:null}else a&&(M=e=>e.graphicUid!==a.uid);switch(p){case"relative-to-scene":{const e=e=>(!M||M(e))&&!!e.lastValidElevationBB;j.intersect(R.layers,w,this._tolerance,null,e),this._externalIntersectionHandlers.forAll(e=>{if(4===e.type||2===e.type||8===e.type){const t=e.slicePlaneEnabled?P:null;e.intersect(j,t,j.rayBegin,j.rayEnd,w,!1)}});break}case"on-the-ground":case"relative-to-ground":this._externalIntersectionHandlers.forAll(e=>{if(e.isGround){const t=e.slicePlaneEnabled?P:null;e.intersect(j,t,j.rayBegin,j.rayEnd,w,!1)}})}if(j.results.min.getIntersectionPoint(E)){const e=g(c,E);return e.z=l,e}return null}computeIntersection(e,t,n,s){if(null==e)return;const o=this._view.state.camera,l=r(y.get());o.projectToRenderScreen(e.origin,l);const a=new k(s,this._forEachLayer);t.options.selectOpaqueTerrainOnly=!s||!("include"in s||"exclude"in s);const c=e.origin,u=i(y.get(),e.origin,e.direction);t.reset(c,u,o),t.intersect(a.layers,l,this._tolerance);const h=this._view.slice.plane,p=null!=h?I(h):null;t.intersect(a.sliceableLayers,l,this._tolerance,p);const d=s&&(s.requiresGroundFeedback||s.enableDraped);this._externalIntersectionHandlers.forAll(e=>{const r=e.layerViewUid,i=e.sublayerId,s=Array.isArray(r),o=s?r:[r];s&&(t.options.filteredLayerViewUids=[]);let h=!1;for(const n of o)a.filterLayerViewUid(n,i)?h=!0:s&&t.options.filteredLayerViewUids.push(n);if(t.options.isFiltered=!h,e.isGround&&d||!t.options.isFiltered){const r=e.slicePlaneEnabled?p:null;e.intersect(t,r,c,u,l,n)}});const m=y.get(),f=this._view.basemapTerrain;if(s&&s.enableDraped&&null!=f.spatialReference&&t.results.ground.getIntersectionPoint(m)){const e=f.overlayManager.renderer,r=this._view.renderCoordsHelper.spatialReference,n=y.get();this._view.renderCoordsHelper.fromRenderCoords(m,n,f.spatialReference),n[2]=this._view.elevationProvider?.getElevation(m[0],m[1],m[2],r,"ground")??0,e.intersect(t,n,t.results.ground,e=>a.filterRenderGeometry(e))}t.sortResults(),this._processHUDResults(t)}_processHUDResults(e){const t=e.results.hud;c(this._tmpRegion,u);const r=this._view.state.camera,n=[],i=this._tmpRegion,s=e=>{const t=new M(e),s=t.result.target.object.geometries.every(e=>e.material instanceof P&&e.material.parameters.occlusionTest);n.push({item:t,occlusionTest:s}),s&&(r.projectToRenderScreen(e.target.center,t.screenPoint),t.screenPoint[0]=Math.floor(t.screenPoint[0]),t.screenPoint[1]=Math.floor(t.screenPoint[1]),d(i,t.screenPoint))};e.sortResults(t.all),null!=t.min.distance&&s(t.min);for(const c of t.all)t.min.target.object!==c.target.object&&t.max.target.object!==c.target.object&&s(c);if(null!=t.max.distance&&t.max.target.object!==t.min.target.object&&s(t.max),!n.length)return;i[0]===i[2]&&(i[2]+=1),i[1]===i[3]&&(i[3]+=1);const o=r.fullWidth,l=r.fullHeight,a=Math.max(0,i[0]-U),m=Math.max(0,i[1]-U),y=Math.min(h(i)+2*U,o-a),f=Math.min(p(i)+2*U,l-m),g=y>0&&f>0?new Uint8Array(y*f*4):null;g&&this._view.stage.renderer.readHUDVisibility(a,m,y,f,g);let _=!0;const w=null==e.results.max.distance;let R=0;for(const{item:c,occlusionTest:u}of n){let t=!u;if(u&&g)for(const e of x){const r=4*(Math.min(c.screenPoint[0]+e[0],o)-i[0]+(Math.min(c.screenPoint[1]+e[1],l)-i[1])*y);if(r>=0&&r<g.length&&g[r]){t=!0;break}}t&&(_&&(e.results.min.copy(c.result),_=!1),w&&e.results.max.copy(c.result),2===e.options.store&&e.results.all.splice(R++,0,c.result))}}}const U=1,x=(()=>{const e=[],t=U;for(let r=-t;r<=t;r++)for(let n=-t;n<=t;n++)e.push([n+t,r+t]);return e})();class M{constructor(e){this.result=e,this.screenPoint=t()}}let H;function L(e){return H&&H.viewingMode===e||(H=new b(e)),H}class k{constructor(e,t){this.layers=new Array,this.sliceableLayers=new Array,this.include=e?.include,this.exclude=e?.exclude,t(e=>{e.pickable&&this.filterLayerViewUid(e.apiLayerViewUid)&&(e.sliceable?this.sliceableLayers:this.layers).push(e)})}filterLayerViewUid(e,t){const{include:r,exclude:n}=this;if(null==e)return null==r&&null==n;const i=r instanceof Map?r.get(e)??!1:r?.has(e),s=n instanceof Map?n.get(e)??!1:n?.has(e);return(null==i||("boolean"==typeof i?i:null!=t&&i.has(t)))&&(null==s||!("boolean"==typeof s?s:null!=t&&s.has(t)))}filterRenderGeometry(e){return this.filterLayerViewUid(e.layerViewUid)}}function T(e){return"object"==typeof e&&"intersect"in e}const E=l(),V=l(),F=t();export{j as SceneIntersectionHelper,T as isIntersectionHandler};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{set as t,dist as e}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{ONES as o}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as n}from"../../../../geometry/ellipsoidUtils.js";import{lonLatToWebMercatorComparable as i}from"../../../../geometry/projection/projectors.js";import{newDoubleArray as a}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as l}from"../../../../geometry/support/FloatArray.js";import{newHalfFloatArray as u}from"../../../../geometry/support/HalfFloatArray.js";import{getZeroIndexArray as s}from"../../../../geometry/support/Indices.js";import{Attribute as c}from"../../webgl-engine/lib/Attribute.js";import{Geometry as p}from"../../webgl-engine/lib/Geometry.js";function f(t,e,r=null){const o=[],n=e.mapPositions;m(e,o);const i=o[0][1].data,a=o[0][1].indices.length,l=s(a);return
|
|
5
|
+
import{set as t,dist as e}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{ONES as o}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as n}from"../../../../geometry/ellipsoidUtils.js";import{lonLatToWebMercatorComparable as i}from"../../../../geometry/projection/projectors.js";import{newDoubleArray as a}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as l}from"../../../../geometry/support/FloatArray.js";import{newHalfFloatArray as u}from"../../../../geometry/support/HalfFloatArray.js";import{getZeroIndexArray as s}from"../../../../geometry/support/Indices.js";import{Attribute as c}from"../../webgl-engine/lib/Attribute.js";import{Geometry as p}from"../../webgl-engine/lib/Geometry.js";function f(t,e,r=null){const o=[],n=e.mapPositions;m(e,o);const i=o[0][1].data,a=o[0][1].indices.length,l=s(a);return g(e,o,l),y(e,o,l),h(e,o,l),b(e,o,l),D(e,o,l),w(e,o),j(e,o,l),F(e,o,i),new p(t,o,n,2,r)}function m(t,e){const{attributeData:{position:r},removeDuplicateStartEnd:o}=t,n=d(r)&&o,i=r.length/3-(n?1:0),a=new Array(2*(i-1)),l=n?r.slice(0,-3):r;let u=0;for(let s=0;s<i-1;s++)a[u++]=s,a[u++]=s+1;e.push(["position",new c(l,a,3,n)])}function g(t,e,r){if(null!=t.attributeData.colorFeature)return;const n=t.attributeData.color;e.push(["color",new c(n??o,r,4)])}function h(t,e,r){t.attributeData.normal&&e.push(["normal",new c(t.attributeData.normal,r,3)])}function b(t,e,r){null!=t.attributeData.colorFeature&&e.push(["colorFeatureAttribute",new c([t.attributeData.colorFeature],r,1,!0)])}function y(t,e,r){null==t.attributeData.sizeFeature&&e.push(["size",new c([t.attributeData.size??1],r,1,!0)])}function D(t,e,r){null!=t.attributeData.sizeFeature&&e.push(["sizeFeatureAttribute",new c([t.attributeData.sizeFeature],r,1,!0)])}function w(t,e){const{attributeData:{position:r,timeStamps:o}}=t;if(!o)return;const n=r.length/3,i=new Array(2*(n-1));let a=0;for(let l=0;l<n-1;l++)i[a++]=l,i[a++]=l+1;e.push(["timeStamps",new c(o,i,3)])}function j(t,e,r){null!=t.attributeData.opacityFeature&&e.push(["opacityFeatureAttribute",new c([t.attributeData.opacityFeature],r,1,!0)])}function F(r,o,u){if(null==r.overlayInfo||1!==r.overlayInfo.renderCoordsHelper.viewingMode||!r.overlayInfo.spatialReference.isGeographic)return;const s=a(u.length),p=n(r.overlayInfo.spatialReference);for(let t=0;t<s.length;t+=3)i(u,t,s,t,p);const f=u.length/3,m=l(f+1);let g=v,h=A,b=0,y=0;t(g,s[y++],s[y++]),y++,m[0]=0;for(let n=1;n<f+1;++n)n===f&&(y=0),t(h,s[y++],s[y++]),y++,b+=e(g,h),m[n]=b,[g,h]=[h,g];o.push(["distanceToStart",new c(m,o[0][1].indices,1,!0)])}function d(t){const e=t.length;return t[0]===t[e-3]&&t[1]===t[e-2]&&t[2]===t[e-1]}const v=r(),A=r();function z(t,e,r){if(null==t||0===t.length)return[];const o=[];return t.forEach((t,n)=>{const i=t.length,l=a(3*i);t.forEach((t,e)=>{l[3*e]=t[0],l[3*e+1]=t[1],l[3*e+2]=t[2]});const u=null!=r?I(r[n]):void 0,s={attributeData:{position:l,normal:e,timeStamps:u},removeDuplicateStartEnd:!1};o.push(s)}),o}function S(t,e=0,r=.01){const o=u(t.length);o[0]=0;for(let i=1;i<t.length;i++){const e=t[i-1],r=t[i],n=Math.sqrt((r[0]-e[0])**2+(r[1]-e[1])**2+(r[2]-e[2])**2);o[i]=o[i-1]+n}const n=o.map(t=>t*r);if(0!==e&&e<n.length){const t=n[e];for(let e=0;e<n.length;e++)n[e]-=t}return n}function I(t){const e=u(3*t.length),r=t[0],o=t[t.length-1];for(let n=0;n<t.length;n++)e[3*n]=t[n],e[3*n+1]=r,e[3*n+2]=o;return e}export{f as createGeometry,S as getLinearTimeStamps,z as lineStripsToParameters,I as timeStampsToAttribute};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import"../../../../core/Logger.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import"../../../../core/Error.js";import{subclass as
|
|
5
|
+
import{__decorate as t}from"tslib";import"../../../../core/Logger.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import"../../../../core/Error.js";import{subclass as e}from"../../../../core/accessorSupport/decorators/subclass.js";import{loadImagery as r}from"../../../2d/engine/flow/dataUtils.js";import s from"../../layers/FlowSubView3D.js";let i=class extends s{constructor(t){super(t)}initialize(){this.updatingHandles.add(()=>this.renderedTiles,()=>this.triggerLoad())}async fetchDataAndGenerateStreamlines(t,e){const{simulationSettings:s,workerHandle:i}=this,{size:o,extent:a,timeExtent:n}=t;if(null==s||null==i)return;const l=await r(this.layer,a,o[0],o[1],n,e);if(null==l)return null;const m={simulationSettings:s,size:o,flowData:l},{streamlines:u}=await i.generateStreamlines(m,e);return u}};i=t([e("esri.views.3d.support.flow.FlowSubViewExtent3D")],i);export{i as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as
|
|
5
|
+
import{__decorate as e}from"tslib";import"../../../../core/Logger.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import"../../../../core/Error.js";import{subclass as t}from"../../../../core/accessorSupport/decorators/subclass.js";import{fromExtent as s,clone as i}from"../../../../geometry/support/aaBoundingRect.js";import{toFlowData as a}from"../../../2d/engine/flow/dataUtils.js";import r from"../../layers/FlowSubView3D.js";import{FlowDataTile as l}from"./loadUtils.js";import{isRasterTile as o}from"../../terrain/TerrainData.js";let n=class extends r{constructor(e){super(e),this._flowDataTiles=d(),this._resetTileData=!0}initialize(){this.addHandles([this.surface.on("tile-data-changed",({tile:e,layerIndex:t,layerClass:s})=>{const{renderedTiles:i}=this;null!=i&&t===this._layerIndex&&1===s&&this._updateFlowDataTile(e)})]),this.updatingHandles.add(()=>this.renderedTiles,e=>{const t=d();e?.forEach(e=>{const s=this._flowDataTiles.get(h(e))??this._getFlowDataCopy(e);null!=s&&t.set(h(e),s)}),this._flowDataTiles=t,this._resetTileData=!0,this.triggerLoad()})}get _layerIndex(){return this.surface.getLayerIndexByUID(1,this.layerView.uid)}async fetchDataAndGenerateStreamlines(e,t){const{simulationSettings:i,_flowDataTiles:a,workerHandle:r}=this,{size:l}=e;if(null==i||null==r)return;const o=s(e.extent),n=this._resetTileData;this._resetTileData=!1;const h=d();a.forEach((e,t)=>{"delete"===e?(h.set(t,"delete"),a.delete(t)):(n||"on-worker"!==e)&&(h.set(t,e),a.set(t,"on-worker"))});const c={simulationSettings:i,size:l,flowDataTiles:h,reset:n,extent:o,pixelSize:this.surface.tilingScheme.pixelSize},{streamlines:u}=await r.generateTiledStreamlines(c,t);return u}_getFlowDataCopy(e){const{_layerIndex:t}=this;if(null==t)return null;const s=e.getLayerInfo(t,1);if(s.dataMissing||!e.hasLayerData(t,1))return null;const{data:r}=s;if(!o(r))return null;const n=a(this.layer.serviceRasterInfo.dataType,r.source),d=new Uint8Array(n.width*n.height);for(let i=0;i<d.length;i++)d[i]=n.mask[i];return new l(n.data,d,n.width,n.height,e.lij,i(e.extent))}async _updateFlowDataTile(e){if(this.renderedTiles?.has(e)){const t=this._getFlowDataCopy(e)??"delete";this._setTileData(e,t)}else this._setTileData(e,"delete");await this.triggerLoad()}_setTileData(e,t){this._flowDataTiles.set(h(e),t)}};function d(){return new Map}function h(e){return e.lij.join("-")}n=e([t("esri.views.3d.support.flow.FlowSubViewTiles3D")],n);export{n as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{__decorate as t}from"tslib";import"../../../../core/Logger.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import"../../../../core/Error.js";import{subclass as e}from"../../../../core/accessorSupport/decorators/subclass.js";import{createFlowFieldFromData as r,getStreamlines as s}from"../../../2d/engine/flow/dataUtils.js";import{createFlowFieldFromDataTiled as o}from"./loadUtils.js";let a=class{constructor(){this._tileData=new Map}async generateStreamlines(t){const{flowData:e,simulationSettings:s,size:o}=t,a=l(r(s,e),s,o);return{result:{streamlines:a},transferList:a?.map(t=>t.buffer)}}async generateTiledStreamlines(t){const{simulationSettings:e,size:r,reset:s,flowDataTiles:a,extent:i,pixelSize:n}=t;this._updateTileData(a,s);const c=l(o(e,this._tileData,r,i,n),e,r);return{result:{streamlines:c},transferList:c?.map(t=>t.buffer)??[]}}_updateTileData(t,e){e&&this._tileData.forEach((e,r)=>{null==t.get(r)&&this._tileData.delete(r)}),t.forEach((t,e)=>{"delete"===t?this._tileData.delete(e):"on-worker"!==t&&this._tileData.set(e,t)})}};a=t([e("esri.views.3d.support.flow.FlowWorker")],a);const i=a;function l(t,e,r){if(null==t)return;const o=s(e,t,r[0],r[1]),a=[];for(const s of o){const t=new Float32Array(3*s.length);for(let e=0;e<s.length;e++)t[3*e]=s[e].x,t[3*e+1]=s[e].y,t[3*e+2]=s[e].t;a.push(t)}return a}export{i as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{WorkerHandle as e}from"../../../../core/workers/WorkerHandle.js";class r extends e{constructor(e){super("FlowWorker","generateStreamlines",{generateStreamlines:e=>[e.flowData.data.buffer,e.flowData.mask.buffer],generateTiledStreamlines:e=>{const r=[];return e.flowDataTiles.forEach(e=>{"string"!=typeof e&&r.push(e.data.buffer,e.mask.buffer)}),r}},e,{strategy:"dedicated"})}generateStreamlines(e,r){return this.invokeMethod("generateStreamlines",e,r)}generateTiledStreamlines(e,r){return this.invokeMethod("generateTiledStreamlines",e,r)}}export{r as FlowWorkerHandle};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../../../Color.js";import
|
|
5
|
+
import t from"../../../../Color.js";import o from"../../../../core/RandomLCG.js";import{fromValues as e}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newHalfFloatArray as r}from"../../../../geometry/support/HalfFloatArray.js";import{zValueInAbsoluteHeightMode as n}from"../../../../support/elevationInfoUtils.js";import{lineStripsToParameters as i,createGeometry as l}from"../engineContent/line.js";function a(t,a,s,p,c){const{spatialReference:h}=t,u=s.map(o=>{const r=[];for(let i=0;i<o.length;i+=3){const l=[o[i],o[i+1]],[s,m]=f(l,a),{absoluteZ:c}=n(s,m,0,h,t,p),u=e(s,m,c);t.renderCoordsHelper.toRenderCoords(u,h,u),r.push(u)}return r}),g=new o,d=s.map(t=>{const o=Math.floor(t.length/3),e=r(o);for(let r=0;r<o;r++)e[r]=t[3*r+2];return m(e,Math.floor(g.getIntRange(0,e.length))),e});return i(u,void 0,d).map(t=>l(c,t))}function s(o){return null==o?{}:{color:t.toUnitRGBA(o.color),width:o.trailWidth,cap:2,animationSpeed:o.flowSpeed,trailLength:o.trailLength,animation:3}}function f([t,o],e){const{extent:r,size:[n,i]}=e;return[t/n*r.width+r.xmin,(i-o)/i*r.height+r.ymin]}function m(t,o){if(0===t.length||o<0||o>=t.length)return;const e=t[o];for(let r=0;r<t.length;r++)t[r]-=e}export{a as createFlowGeometry,s as materialParametersFromRenderer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{
|
|
5
|
+
import{width as t,height as n,containsXY as l,intersects as u,create as o}from"../../../../geometry/support/aaBoundingRect.js";import{createFlowFieldFromData as r}from"../../../2d/engine/flow/dataUtils.js";class e{constructor(t,n,l,u,o,r){this.data=t,this.mask=n,this.width=l,this.height=u,this.lij=o,this.extent=r}}function i(t,n){let[l,r,e,i]=[null,null,null,null];for(const o of t){const t=o.extent;u(t,n)&&(l=c(t[0],l),r=c(t[1],r),e=s(t[2],e),i=s(t[3],i))}return null==l||null==r||null==e||null==i?null:o([l,r,e,i])}function s(t,n){return null==n?t:Math.max(t,n)}function c(t,n){return null==n?t:Math.min(t,n)}function a(u,o,e,i,s){const[c,a]=e;let f=null;const h=new Map;o.forEach(t=>{h.set(t.lij,r(u,t))});const d=(t,n,u)=>l(t.extent,n,u);return(l,u)=>{const r=Math.round(l),e=Math.round(u);if(r<0||r>=c||e<0||e>=a)return[0,0];const m=l/c*t(i)+i[0],p=(a-u)/a*n(i)+i[1];if(null==f||!d(f,m,p)){f=null;for(const[t,n]of o)if(d(n,m,p)){f=n;break}}if(null==f?.data)return[0,0];const x=h.get(f.lij);if(null==x)return[0,0];const g=f.extent;return x((m-g[0])/t(g)*s,s-(p-g[1])/n(g)*s)}}export{e as FlowDataTile,i as boundingRectOfTiles,a as createFlowFieldFromDataTiled};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../Graphic.js";import{isIterable as n}from"../../../core/iteratorUtils.js";import{screenPointObjectToArray as i,createScreenPointArray as t}from"../../../core/screenUtils.js";import{create as r}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import s from"../../../geometry/Point.js";import
|
|
5
|
+
import e from"../../../Graphic.js";import{isIterable as n}from"../../../core/iteratorUtils.js";import{screenPointObjectToArray as i,createScreenPointArray as t}from"../../../core/screenUtils.js";import{create as r}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import s from"../../../geometry/Point.js";import l from"../../../geometry/SpatialReference.js";import{projectVectorToVector as o}from"../../../geometry/projection/projectVectorToVector.js";import{fallbackObjectIDAttribute as c}from"../../../layers/LayerConstants.js";import{isIntegratedMeshLayer as a}from"../../../layers/support/layerUtils.js";import{debugFlags as u}from"./debugFlags.js";import{getElevationAtPoint as d}from"./ElevationProvider.js";import{Intersector as p}from"../webgl-engine/lib/Intersector.js";import{isValidIntersectorResult as f}from"../webgl-engine/lib/IntersectorResult.js";import{toHit as m,toOwner as g}from"../webgl-engine/lib/intersectorUtilsConversions.js";import{terrainId as y}from"../webgl-engine/lib/verticalOffsetUtils.js";async function h(e,n,i,r){const s=i?x(e,i):r,l=t(n.x,n.y);s.requiresGroundFeedback=!0,s.enableDraped=!0;const o=new p(e.state.viewingMode);o.options.selectionMode=!0,o.options.store=2,e.sceneIntersectionHelper.intersectIntersectorScreen(l,o,s);const c=await b(e,o.results.all,s.graphics),d=o.results.ground,m=g(d,e),y=null!=m&&"type"in m&&a(m.type)?m:null,h={screenPoint:n,results:c,ground:{mapPoint:j(e,d),distance:f(d)?d.distanceInRenderSpace:0,layer:y}};return u.SCENEVIEW_HITTEST_RETURN_INTERSECTOR&&(h.intersector=o),h}function w(e,n,t,r){const s=t?x(e,t):r,l=!(!s.graphics?.include&&!s.graphics?.exclude),o=!(!s.mediaElements?.include&&!s.mediaElements?.exclude),c=i(n);s.enableDraped=s.include&&!s.include.has(y)||s.exclude?.has(y);const a=e.sceneIntersectionHelper,u=new p(e.state.viewingMode);if(u.options.selectionMode=!0,u.options.store=l||o?2:0,u.options.excludeLabels=t?.excludeLabels??!1,a.intersectIntersectorScreen(c,u,s),l||o){for(const n of u.results.all){const i=m(n,e);if(null==i)return j(e,n);if(l&&("graphic"!==i.type||E(s.graphics,i.graphic)))return j(e,n);if(o&&("media"!==i.type||S(s.mediaElements,i.element)))return j(e,n)}return null}return j(e,u.results.min)}async function b(e,n,i){const t=new Array;let r,s=null;const l={defer(e){r=e()}};for(let o=0;o<n.length;o++){const c=n[o],u=g(c,e);if(null!=u&&(u===e.map.ground||"type"in u&&a(u.type)))break;const d=m(c,e,l)??await r;if(r=null,null==d)continue;if("graphic"===d.type){if(null==s&&o!==n.length-1&&(s=new Set),null!=s){const e=U(d.graphic);if(s.has(e))continue;s.add(e)}if(!E(i,d.graphic))continue}const p=j(e,c),f=c.distanceInRenderSpace;if("media"===d.type){const e=d.element.toSource(p);t.push({...d,mapPoint:p,distance:f,sourcePoint:e})}else t.push({...d,mapPoint:p,distance:f})}return t}function j(e,n,i){return n.getIntersectionPoint(F)?(i=V(e,F,i),2===n.intersector&&e.basemapTerrain&&(i.z=d(e.basemapTerrain,i)??0),i):null}function U(e){const n=e.sourceLayer,i=e.layer,t=n&&"objectIdField"in n?n:i&&"objectIdField"in i?i:n;if(t){const n=t.objectIdField??c,i=e.attributes?.[n];if(i)return`o-${t.id}-${i}`}return`u-${e.uid}`}function E(e,n){return S(e,U(n))}function S(e,n){return null==e||(null==e.include||e.include.has(n))&&(null==e.exclude||!e.exclude.has(n))}function V(e,n,i){let t=e.spatialReference||l.WGS84;return o(n,e.renderSpatialReference,F,t)?n=F:(t=l.WGS84,o(n,e.renderSpatialReference,F,t)&&(n=F)),i?(i.x=n[0],i.y=n[1],i.z=n[2],i.spatialReference=t):i=new s(n,t),i}function x(e,n){const i=I(e,n.include,0),t=I(e,n.exclude,1);return{include:i.layerViewUids,exclude:t.layerViewUids,graphics:{include:i.graphicUids,exclude:t.graphicUids},mediaElements:{include:i.mediaElements,exclude:t.mediaElements}}}function I(i,t,r,s=new R){if(!t)return s;if(t instanceof e)L(s,U(t)),0===r&&(null!=i.graphicsView&&t.layer===i?P(s,i.graphicsView.uid):t.layer&&T(s,i,t.layer.uid));else if("layer"in t&&"element"in t)M(s,t.element),0===r&&T(s,i,t.layer.uid);else if(n(t))for(const e of t)e===i.graphics&&null!=i.graphicsView?P(s,i.graphicsView.uid):e===i.map.ground?P(s,y):I(i,e,r,s);else"layer"in t&&v(s,i,t),"uid"in t&&T(s,i,t.uid);return s}class R{constructor(){this.layerViewUids=null,this.graphicUids=null,this.mediaElements=null}}function T(e,n,i){const t=n.allLayerViews.find(e=>e.layer.uid===i);t&&P(e,t.uid)}function P(e,n){e.layerViewUids??=new Map,e.layerViewUids.set(n,!0)}function v(e,n,i){const t=n.allLayerViews.find(e=>e.layer.uid===i.layer.uid);if(!t)return;e.layerViewUids??=new Map;const r=e.layerViewUids.get(t.uid);!0!==r&&(r?r.add(i.id):e.layerViewUids.set(t.uid,new Set([i.id])))}function L(e,n){e.graphicUids??=new Set,e.graphicUids.add(n)}function M(e,n){e.mediaElements??=new Set,e.mediaElements.add(n)}const F=r();export{V as computeMapPointFromVec3d,x as externalToInternalIntersectOptions,U as getGraphicFilterUid,h as hitTest,j as intersectResultToMapPoint,w as toMap};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../../../../../geometry/support/Ellipsoid.js";import"./ComponentData.glsl.js";import"../../../../core/shaderLibrary/
|
|
5
|
+
import"../../../../../../../geometry/support/Ellipsoid.js";import"./ComponentData.glsl.js";import"../../../../core/shaderLibrary/ForwardLinearDepthToWriteShadowMap.glsl.js";import"../../../../core/shaderLibrary/ShaderOutput.js";import"../../../../core/shaderLibrary/Slice.glsl.js";import"../../../../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import"../../../../core/shaderLibrary/attributes/VertexColor.glsl.js";import"../../../../core/shaderLibrary/attributes/VertexNormal.glsl.js";import"../../../../core/shaderLibrary/attributes/VertexPosition.glsl.js";import"../../../../core/shaderLibrary/output/OutputDepth.glsl.js";import"../../../../core/shaderLibrary/output/OutputHighlight.glsl.js";import"../../../../core/shaderLibrary/output/OutputHighlightOverlay.js";import"../../../../core/shaderLibrary/shading/ComputeFragmentNormals.glsl.js";import"../../../../core/shaderLibrary/shading/ComputeMaterialColor.glsl.js";import"../../../../core/shaderLibrary/shading/ComputeNormalTexture.glsl.js";import"../../../../core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js";import"../../../../core/shaderLibrary/shading/MainLighting.glsl.js";import"../../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import"../../../../core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js";import"../../../../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import"../../../../core/shaderLibrary/shading/TerrainDepthTest.glsl.js";import"../../../../core/shaderLibrary/terrain/Overlay.glsl.js";import"../../../../core/shaderLibrary/util/DiscardOrAdjustAlpha.glsl.js";import"../../../../core/shaderModules/glsl.js";import"../../../../core/shaderModules/Texture2DBindUniform.js";import"../../../../effects/weather/SnowCover.glsl.js";import"../../../../shaders/OutputColorHighlightOID.glsl.js";import"../../../../../../webgl/ShaderBuilder.js";import"../../../../../../../webscene/support/AlphaCutoff.js";export{b as build}from"../../../../../../../chunks/ComponentShader.glsl.js";
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{releaseMaybe as e}from"../../../../../core/maybe.js";import{isPromiseLike as t}from"../../../../../core/promiseUtils.js";class s{constructor(s,r){this._textures=s,this.loadPromise=null,this._disposed=!1;const i=this._textures.acquire(r);t(i)?(i.then(t=>{this._disposed?e(t):this._textureRef=t}),this.loadPromise=i):this._textureRef=i}dispose(){this._textureRef=e(this._textureRef),this._disposed=!0}get glTexture(){return
|
|
5
|
+
import{releaseMaybe as e}from"../../../../../core/maybe.js";import{isPromiseLike as t}from"../../../../../core/promiseUtils.js";class s{constructor(s,r){this._textures=s,this.loadPromise=null,this._disposed=!1;const i=this._textures.acquire(r);t(i)?(i.then(t=>{this._disposed?e(t):this._textureRef=t}),this.loadPromise=i):this._textureRef=i}dispose(){this._textureRef=e(this._textureRef),this._disposed=!0}get glTexture(){return this._textureRef?.glTexture}}export{s as RenderTexture};
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
linearDepth = calculateLinearDepth(nearFar, vPosition_view.z);
|
|
9
|
-
}`)}d.code.add(r`void forwardLinearDepth() {}`)}export{n as ForwardLinearDepth,i as addCalculateLinearDepth,o as addLinearDepth,t as addNearFar};
|
|
5
|
+
import{If as e,glsl as a}from"../shaderModules/glsl.js";function r(e){e.varyings.add("linearDepth","float",{invariant:!0})}function t(t,i){i&&r(t),t.vertex.code.add(a`
|
|
6
|
+
void forwardLinearDepth(float _linearDepth) { ${e(i,"linearDepth = _linearDepth;")} }
|
|
7
|
+
`)}export{t as ForwardLinearDepth,r as addLinearDepth};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{ForwardLinearDepth as o}from"./ForwardLinearDepth.glsl.js";import{isColorOrColorEmission as r}from"./ShaderOutput.js";import{If as e,glsl as t}from"../shaderModules/glsl.js";function a(a,d){const i=r(d.output)&&d.receiveShadows;i&&o(a,!0),a.vertex.code.add(t`
|
|
6
|
+
void forwardLinearDepthToReadShadowMap() { ${e(i,"forwardLinearDepth(gl_Position.w);")} }
|
|
7
|
+
`)}export{a as ForwardLinearDepthToReadShadowMap};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{ForwardLinearDepth as r}from"./ForwardLinearDepth.glsl.js";import{isShadowRelatedOutput as e}from"./ShaderOutput.js";import{VertexPosition as a}from"./attributes/VertexPosition.glsl.js";import{Float2BindUniform as o}from"../shaderModules/Float2BindUniform.js";import{glsl as t,If as n}from"../shaderModules/glsl.js";function i(r){r.vertex.uniforms.add(new o("nearFar",r=>r.camera.nearFar))}function d(r){r.vertex.code.add(t`float calculateLinearDepth(vec2 nearFar,float z) {
|
|
6
|
+
return (-z - nearFar[0]) / (nearFar[1] - nearFar[0]);
|
|
7
|
+
}`)}function s(o,s){const{vertex:l}=o,u=e(s.output);u&&(o.include(a,s),r(o,!0),i(o),d(o)),l.code.add(t`
|
|
8
|
+
void forwardLinearDepthToWriteShadowMap() {
|
|
9
|
+
${n(u,"forwardLinearDepth(calculateLinearDepth(nearFar, vPosition_view.z));")}
|
|
10
|
+
}
|
|
11
|
+
`)}export{s as ForwardLinearDepthToWriteShadowMap,d as addCalculateLinearDepth,i as addNearFar};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{addCalculateLinearDepth as e}from"./
|
|
5
|
+
import{addCalculateLinearDepth as e}from"./ForwardLinearDepthToWriteShadowMap.glsl.js";import{glsl as r}from"../shaderModules/glsl.js";function o(o){e(o),o.vertex.code.add(r`vec4 transformPositionWithDepth(mat4 proj, mat4 view, vec3 pos, vec2 nearFar, out float depth) {
|
|
6
6
|
vec4 eye = view * vec4(pos, 1.0);
|
|
7
7
|
depth = calculateLinearDepth(nearFar,eye.z);
|
|
8
8
|
return proj * eye;
|
package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{addNearFar as o}from"../
|
|
5
|
+
import{addNearFar as o}from"../ForwardLinearDepthToWriteShadowMap.glsl.js";import{SliceDraw as r}from"../Slice.glsl.js";import{Transform as e}from"../Transform.glsl.js";import{NormalAttribute as t}from"../attributes/NormalAttribute.glsl.js";import{ObjectAndLayerIdColor as i}from"../attributes/ObjectAndLayerIdColor.glsl.js";import{TextureCoordinateAttribute as a}from"../attributes/TextureCoordinateAttribute.glsl.js";import{VertexNormal as s}from"../attributes/VertexNormal.glsl.js";import{OutputDepth as l}from"../output/OutputDepth.glsl.js";import{OutputHighlight as d}from"../output/OutputHighlight.glsl.js";import{VisualVariables as n}from"../shading/VisualVariables.glsl.js";import{DiscardOrAdjustAlphaPass as c}from"../util/DiscardOrAdjustAlpha.glsl.js";import{addProjViewLocalOrigin as u}from"../util/View.glsl.js";import{glsl as p,If as v}from"../../shaderModules/glsl.js";import{Texture2DPassUniform as m}from"../../shaderModules/Texture2DPassUniform.js";function f(f,g){const{vertex:x,fragment:O,varyings:j}=f,{hasColorTexture:h,alphaDiscardMode:w}=g,V=h&&1!==w,{output:C,normalType:b,hasColorTextureTransform:A}=g;switch(C){case 2:u(x,g),f.include(e,g),O.include(r,g),f.include(a,g),V&&O.uniforms.add(new m("tex",o=>o.texture)),x.main.add(p`vpos = getVertexInLocalOriginSpace();
|
|
6
6
|
vpos = subtractOrigin(vpos);
|
|
7
7
|
vpos = addVerticalOffset(vpos, localOrigin);
|
|
8
8
|
gl_Position = transformPosition(proj, view, vpos);
|
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{create as
|
|
5
|
+
import{create as a}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ForwardLinearDepthToReadShadowMap as o}from"../ForwardLinearDepthToReadShadowMap.glsl.js";import{calculateUVZShadowPass as e,calculateUVZShadowDraw as r,ReadShadowMapOrigin as t}from"./calculateUVZShadow.glsl.js";import{ShadowmapFiltering as d}from"./ShadowmapFiltering.glsl.js";import{FloatBindUniform as i}from"../../shaderModules/FloatBindUniform.js";import{If as l,glsl as n}from"../../shaderModules/glsl.js";import{Texture2DShadowBindUniform as s}from"../../shaderModules/Texture2DShadowBindUniform.js";import{NoParameters as c}from"../../../../../webgl/NoParameters.js";class h extends t{}class m extends c{constructor(){super(...arguments),this.origin=a()}}function p(a,o){o.receiveShadows&&a.include(e),u(a,o)}function f(a,o){o.receiveShadows&&a.include(r),u(a,o)}function u(a,e){a.fragment.uniforms.add(new i("lightingGlobalFactor",a=>a.lighting.globalFactor));const{receiveShadows:r,spherical:t}=e;a.include(o,e),r&&w(a),a.fragment.code.add(n`
|
|
6
|
+
float readShadow(float additionalAmbientScale, vec3 vpos) {
|
|
7
|
+
return ${r?"max(lightingGlobalFactor * (1.0 - additionalAmbientScale), readShadowMap(vpos, linearDepth))":l(t,"lightingGlobalFactor * (1.0 - additionalAmbientScale)","0.0")};
|
|
8
|
+
}
|
|
9
|
+
`)}function w(a){a.include(d);const{fragment:o}=a;o.uniforms.add(new s("shadowMap",a=>a.shadowMap.depthTexture)),o.code.add(n`float readShadowMap(const in vec3 _worldPos, float _linearDepth) {
|
|
6
10
|
vec3 uvzShadow = calculateUVZShadow(_worldPos, _linearDepth, textureSize(shadowMap,0));
|
|
7
11
|
if (uvzShadow.z < 0.0) {
|
|
8
12
|
return 0.0;
|
|
9
13
|
}
|
|
10
14
|
return readShadowMapUVZ(uvzShadow, shadowMap);
|
|
11
|
-
}`)}export{
|
|
15
|
+
}`)}export{f as ReadShadowMapDraw,h as ReadShadowMapDrawParameters,p as ReadShadowMapPass,m as ReadShadowMapPassParameters};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import r from"../../../../core/Evented.js";import s from"../../../../core/Logger.js";import{isPromiseLike as o,isAbortError as i}from"../../../../core/promiseUtils.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as u}from"../../../../core/accessorSupport/decorators/subclass.js";import{isUpdatableTexture as a}from"./ITexture.js";import{TextureUpdater as d}from"./TextureUpdater.js";import{TaskPriority as l}from"../../../support/Scheduler.js";let h=class extends t{constructor(e){super({}),this._stage=e,this._textures=new Map,this._loadingCount=0,this.events=new r.EventEmitter,this.updater=new d,this._frameTask=e.view.resourceController.scheduler.registerTask(l.TEXTURE_UNLOAD)}normalizeCtorArgs(){return{}}destroy(){this._frameTask.remove(),this.
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import r from"../../../../core/Evented.js";import s from"../../../../core/Logger.js";import{isPromiseLike as o,isAbortError as i}from"../../../../core/promiseUtils.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as u}from"../../../../core/accessorSupport/decorators/subclass.js";import{isUpdatableTexture as a}from"./ITexture.js";import{TextureUpdater as d}from"./TextureUpdater.js";import{TaskPriority as l}from"../../../support/Scheduler.js";let h=class extends t{constructor(e){super({}),this._stage=e,this._textures=new Map,this._loadingCount=0,this.events=new r.EventEmitter,this.updater=new d,this._frameTask=e.view.resourceController.scheduler.registerTask(l.TEXTURE_UNLOAD)}normalizeCtorArgs(){return{}}destroy(){this._frameTask.remove(),this.updater.destroy(),this._textures.forEach(e=>e.unload())}get updating(){return this._loadingCount>0||this._frameTask.updating}acquire(e){const t=this._textures.get(e);return t?(t.ref(),t.loadingPromise??t):this._createNewRef(e)}update(){this.updater.run()&&this.events.emit("changed",0)}_createNewRef(e){const t=this._stage.getTexture(e);if(null==t)return null;const r=t.events.on("unloaded",()=>{r.remove(),this._onTextureUnloaded(t)}),n=new p(t,()=>{this._frameTask.schedule(()=>{n.isUnreferenced&&t.unload()})});return this._textures.set(e,n),n.ref(),t.loaded?(this._updateGLTexture(n,t.glTexture),a(t)&&this.updater.add(t),n):(this._loadingCount++,n.loadingPromise=this._stage.schedule(()=>{const e=t.load(this._stage.renderView.renderingContext),r=e=>(this._loadingCount--,n.loadingPromise=null,this._updateGLTexture(n,e),a(t)&&this.updater.add(t),n),u=e=>(t.unload(),this._loadingCount--,n.loadingPromise=null,i(e)||s.getLogger(this).error(e),null);return o(e)?e.then(r,u):r(e)}),n.loadingPromise)}_updateGLTexture(e,t){e.glTexture=t,this.events.emit("changed",1)}_onTextureUnloaded(e){this._textures.delete(e.id),this.updater.remove(e)}};e([n()],h.prototype,"_loadingCount",void 0),e([n()],h.prototype,"_frameTask",void 0),e([n()],h.prototype,"updating",null),h=e([u("esri.views.3d.webgl-engine.lib.TextureRepository")],h);class p{constructor(e,t){this._texture=e,this._release=t,this._refCount=0}get id(){return this._texture.id}get isUnreferenced(){return 0===this._refCount}ref(){++this._refCount}release(){--this._refCount,this._refCount>0||(0!==this._refCount?(s.getLogger("esri.views.3d.webgl-engine.lib.TextureRepository.RefCountedTextureImpl").error("Cannot dereference texture that has no references!"),this._refCount=0):this._release())}unload(){this._texture.unload()}}export{h as TextureRepository};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
class t{constructor(){this._updating=new Map}add(t){this._updating.set(t.id,new e(t))}remove(t){this._updating.delete(t.id)}run(){let t=!1;return this._updating.forEach(e=>{const s=e.texture.update(e.previousToken);s>=0&&s!==e.previousToken&&(e.previousToken=s,t=!0)}),t}}class e{constructor(t){this.texture=t,this.previousToken=-1}}export{t as TextureUpdater};
|
|
5
|
+
class t{constructor(){this._updating=new Map}destroy(){this._updating.clear()}add(t){this._updating.set(t.id,new e(t))}remove(t){this._updating.delete(t.id)}run(){let t=!1;return this._updating.forEach(e=>{const s=e.texture.update(e.previousToken);s>=0&&s!==e.previousToken&&(e.previousToken=s,t=!0)}),t}}class e{constructor(t){this.texture=t,this.previousToken=-1}}export{t as TextureUpdater};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{isSome as t}from"../../../../../core/arrayUtils.js";import n from"../../../../../core/Error.js";import{someMap as r,getOrCreateMapValue as s}from"../../../../../core/MapUtils.js";import{destroyMaybe as a}from"../../../../../core/maybe.js";import{isAborted as i,throwIfAborted as o}from"../../../../../core/promiseUtils.js";import{property as l}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import{subclass as c}from"../../../../../core/accessorSupport/decorators/subclass.js";import{create as h}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{d,e as u,t as m}from"../../../../../chunks/vec32.js";import{create as f}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as p,fromValues as _}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{debugFlags as g}from"../../../support/debugFlags.js";import{glLayout as y}from"../../../support/buffer/glUtil.js";import{newLayout as v}from"../../../support/buffer/InterleavedLayout.js";import b from"../../../webgl/RenderCamera.js";import{AsyncRenderPlugin as I}from"../../effects/RenderPlugin.js";import{Default3D as C}from"../DefaultVertexAttributeLocations.js";import{DepthRange as D}from"../DepthRange.js";import{assert as R}from"../Util.js";import{InstanceData as E}from"./InstanceData.js";import{InstanceOctree as L}from"./InstanceOctree.js";import{LevelSelector as x}from"./LevelSelector.js";import{LodLevel as j}from"./LodLevel.js";import{RenderInstanceData as S}from"./RenderInstanceData.js";import{colorMixModes as w}from"../../materials/internal/MaterialUtil.js";import{encodeDoubleVec3 as M}from"../../materials/renderers/utils.js";import{DefaultMaterialDrawParameters as A}from"../../shaders/DefaultMaterialTechnique.js";import{defaultHighlightName as O}from"../../../../support/HighlightDefaults.js";import{TaskPriority as U,noBudget as T}from"../../../../support/Scheduler.js";import{bindVertexBufferLayout as F,unbindVertexBufferLayout as q}from"../../../../webgl/Util.js";const H=e=>{const t=e.baseBoundingSphere.radius,n=e.levels.map(e=>e.minScreenSpaceRadius);return new x(t,n)};let B=class extends I{constructor(e,t){super(e),this.type=6,this.isGround=!1,this._levels=[],this._defaultRenderInstanceData=new Array,this._highlightRenderInstanceDataMap=new Map,this._instanceIndex=0,this._cycleStartIndex=0,this._slicePlane=!1,this._camera=new b,this._updateCyclesWithStaticCamera=-1,this._needFullCycle=!1,this.produces=new Map([[2,e=>this._produces(e)],[4,e=>!!this._hasTransparentLevels()&&this._produces(e)]]),this._instanceData=new E({shaderTransformation:e.shaderTransformation},e.optionalFields),this.addHandles(t.registerTask(U.LOD_RENDERER,this))}initialize(){this._instanceBufferLayout=P(this.optionalFields),this._glInstanceBufferLayout=y(this._instanceBufferLayout,1),this.addHandles([this._instanceData.events.on("instances-changed",()=>this._requestUpdateCycle()),this._instanceData.events.on("instance-transform-changed",({index:e})=>{this._requestUpdateCycle(),this.metadata.notifyGraphicGeometryChanged(e)}),this._instanceData.events.on("instance-visibility-changed",({index:e})=>{this._requestUpdateCycle(!0),this.metadata.notifyGraphicVisibilityChanged(e)}),this._instanceData.events.on("instance-highlight-changed",()=>this._requestUpdateCycle(!0))])}get _allRenderInstanceData(){return[this._defaultRenderInstanceData,...this._highlightRenderInstanceDataMap.values()]}get _allRenderInstanceDataExceptHighlightShadow(){const e=[this._defaultRenderInstanceData];for(const t of this._highlightRenderInstanceDataMap)t[0]!==O&&e.push(t[1]);return e}hasHighlight(e){return this._highlightRenderInstanceDataMap.has(e)}get _enableLevelSelection(){return this.symbol.levels.length>1}get levels(){return this._levels}get baseBoundingBox(){return this._levels[this._levels.length-1].boundingBox}get baseBoundingSphere(){return this._levels[this._levels.length-1].boundingSphere}get baseMaterial(){return this._levels[this._levels.length-1].components[0].material}get slicePlaneEnabled(){return this._slicePlane}set slicePlaneEnabled(e){this._slicePlane=e}get layerViewUid(){return this.metadata.layerViewUid}get instanceData(){return this._instanceData}get hasEmissions(){return this._levels.some(e=>e.components.some(e=>e.material.hasEmissions))}get usedMemory(){return this._allRenderInstanceData.reduce((e,t)=>t.reduce((e,t)=>e+t.usedMemory,e),this._levels.reduce((e,t)=>e+t.components.reduce((e,t)=>e+t.usedMemory,0),0))}get renderStats(){const e=this._instanceData.size,t=[];return this._levels.forEach((e,n)=>{const r=this._allRenderInstanceData[0][n].size+this._allRenderInstanceData[1][n].size,s=e.triangleCount;t.push({renderedInstances:r,renderedTriangles:r*s,trianglesPerInstance:s})}),{totalInstances:e,renderedInstances:t.reduce((e,t)=>e+t.renderedInstances,0),renderedTriangles:t.reduce((e,t)=>e+t.renderedTriangles,0),levels:t}}_createRenderInstanceDataArray(e=[]){const{rctx:t}=this._context.renderContext;return this.symbol.levels.map(n=>{e.push(new S(t,this._instanceBufferLayout))}),e}async initializeRenderContext(e,n){this._context=e,this._createRenderInstanceDataArray(this._defaultRenderInstanceData);const r=await Promise.allSettled(this.symbol.levels.map(t=>j.create(e,t,n))),s=r.map(e=>"fulfilled"===e.status?e.value:null).filter(t);if(i(n)||s.length!==r.length){s.forEach(e=>e.destroy()),o(n);for(const e of r)if("rejected"===e.status)throw e.reason}this._levels=s,this._levelSelector=H(this)}uninitializeRenderContext(){this._invalidateOctree(),this._levels.forEach(e=>e.destroy()),this._defaultRenderInstanceData.forEach(e=>e.destroy()),this._highlightRenderInstanceDataMap.forEach(e=>e.forEach(e=>e.destroy()))}_hasTransparentLevels(){return this._levels.some(e=>e.components.some(e=>{const t=e.material.produces.get(4);return t?.(0)}))}hasHighlights(){return r(this._highlightRenderInstanceDataMap,e=>e.some(e=>e.size>0))}_produces(e){return(8!==e||this.hasHighlights())&&(5!==e||this.hasHighlight(O))}prepareRender(e){if(!g.LOD_INSTANCE_RENDERER_DISABLE_UPDATES){if(this._enableLevelSelection){const t=e.bind.contentCamera.equals(this._camera);this._camera.copyFrom(e.bind.contentCamera),t||this._requestUpdateCycle()}this._needFullCycle&&(this.runTask(T),this._needFullCycle=!1)}}acquireTechniques(e){if(!this.baseMaterial.visible||!this.baseMaterial.isVisibleForOutput(e.output))return null;const t=this._getInstanceDatas(e);if(!t)return null;const n=new Array,r=this.levels;return t.forEach(t=>r.forEach(({components:r},s)=>r.forEach(r=>n.push(this._beginComponent(e,t[s],r))))),n}render(e,t){const n=this._getInstanceDatas(e);if(!n||null==t)return;let r=0;e.rctx.bindVAO();const s=this.levels;n.forEach(n=>s.forEach(({components:s},a)=>s.forEach(s=>this._renderComponent(e,t[r++],n[a],s,a))))}_getInstanceDatas(e){const{output:t,bind:n}=e,r=8===t,s=5===t,a=6!==t;if(!r&&!s)return a?this._allRenderInstanceData:this._allRenderInstanceDataExceptHighlightShadow;const{_highlightRenderInstanceDataMap:i}=this;if(a){if(r){const e=n.highlight?.name;if(!e)return null;const t=i.get(e);return t?[t]:null}const e=i.get(O);return s?e?[e]:null:Array.from(i.values())}return null}intersect(e,t,n,r){if(!this.baseMaterial.visible||null==this._octree)return;const s=f();d(s,r,n);const a=s=>{this._instanceData.getCombinedModelTransform(s,k),e.transform.set(k),m(G,n,e.transform.inverse),m(Y,r,e.transform.inverse);const a=this._instanceData.getState(s),i=this._instanceData.getLodLevel(s),o=this._levels.length;R(!!(18&a),"invalid instance state"),R(i>=0&&i<o,"invaid lod level"),this._levels[i].intersect(e,t,G,Y,s,this.metadata,o)};this.baseMaterial.parameters.verticalOffset?this._octree.forEach(a):this._octree.forEachAlongRay(n,s,a)}notifyShaderTransformationChanged(){this._invalidateOctree(),this._requestUpdateCycle()}get _octree(){if(null==this._octreeCached){const e=this._instanceData,t=e.view?.state;if(!t)return null;this._octreeCached=new L(e,this.baseBoundingSphere);for(let n=0;n<e.capacity;++n)18&t.get(n)&&this._octreeCached.addInstance(n)}return this._octreeCached}_invalidateOctree(){this._octreeCached=a(this._octreeCached)}queryDepthRange(e){if(null==this._octree)return new D;const t=e.viewForward,n=this._octree.findClosest(t,1,e.frustum),r=this._octree.findClosest(t,-1,e.frustum);if(null==n||null==r)return new D;const s=e.eye,a=this._instanceData.view;a.boundingSphere.getVec(n,W),d(W,W,s);const i=u(W,t)-W[3];a.boundingSphere.getVec(r,W),d(W,W,s);const o=u(W,t)+W[3];return new D(i,o)}_requestUpdateCycle(e=!1){this._updateCyclesWithStaticCamera=-1,this._cycleStartIndex=this._instanceIndex,e&&(this._needFullCycle=!0,this._context.requestRender())}_startUpdateCycle(){this._updateCyclesWithStaticCamera++,this._allRenderInstanceData.forEach(e=>e.forEach(e=>e.startUpdateCycle()))}get running(){return this._instanceData.size>0&&this._updateCyclesWithStaticCamera<1}runTask(e){const{_enableLevelSelection:t,_camera:r,_levelSelector:a}=this;this._allRenderInstanceData.forEach(e=>e.forEach(e=>e.beginUpdate()));const i=this._instanceData,o=i.view;let l=i.size;const c=i.capacity;let h=this._instanceIndex;const d=Math.ceil(c/500),{_highlightRenderInstanceDataMap:u}=this;for(let m=0;m<l&&!e.done;++m){h===this._cycleStartIndex&&this._startUpdateCycle();const m=o.state.get(h);let f=0;if(!(1&m)){h=h+1===c?0:h+1,l++;continue}const p=o.lodLevel.get(h);if(2&m&&this._defaultRenderInstanceData[p].freeTail(),16&m){const e=i.geHighlightOptionsPrev(h);if(e){const t=u.get(e);if(!t)throw new n("internal:lod-renderer","Internal error in lodRenderer");t[p].freeTail(),t.every(e=>e.isEmpty)&&(t.forEach(e=>e.destroy()),u.delete(e))}}if(32&m)i.freeInstance(h);else if(4&m){let e=0;if(t&&(o.modelOrigin.getVec(h,z),e=a.selectLevel(z,i.getCombinedMedianScaleFactor(h),r)),f=-83&m,e>=0)if(8&m){const t=i.getHighlightName(h);if(t){const r=()=>{const e=this._createRenderInstanceDataArray();return e.forEach(e=>e.beginUpdate()),e},a=s(u,t,r);if(e>=a.length)throw new n("internal:lod-renderer",`LodRenderer internal error - missing lodLevel ${e}`);V(a[e],o,h)}f|=16}else V(this._defaultRenderInstanceData[e],o,h),f|=2;o.state.set(h,f),o.lodLevel.set(h,e)}else f=-83&m,o.state.set(h,f);if(null!=this._octreeCached){const e=!!(18&m),t=!!(18&f);!e&&t?this._octreeCached.addInstance(h):e&&!t?this._octreeCached.removeInstance(h):e&&t&&64&m&&(this._octreeCached.removeInstance(h),this._octreeCached.addInstance(h))}h=h+1===c?0:h+1,h%d===0&&e.madeProgress()}this._instanceIndex=h,this._allRenderInstanceData.forEach(e=>e.forEach(e=>e.endUpdate())),this._context.requestRender()}_beginComponent(e,t,n){if(0===t.size)return null;const r=n.glMaterials.load(e.rctx,e.bind.slot,e.output);return r?.beginSlot(e.bind)}_renderComponent(e,t,n,r,s){if(!t)return;const{bind:a,rctx:i}=e;i.runAppleAmdDriverHelper();const o=i.bindTechnique(t,a,r.material.parameters,$);i.bindVAO(r.vao),t.ensureAttributeLocations(r.vao),g.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL&&0===e.output&&(o.setUniform4fv("externalColor",Z[Math.min(s,Z.length-1)]),o.setUniform1i("symbolColorMixMode",w.replace));const l=n.capacity,c=n.headIndex,h=n.tailIndex,d=n.firstIndex,u=this._glInstanceBufferLayout,m=(e,s)=>{F(i,C,n.buffer,u,e),i.drawArraysInstanced(t.primitiveType,0,r.vertexCount,s-e),q(i,C,n.buffer,u)};r.material.transparent&&null!=d?c>h?(R(d>=h&&d<=c,"invalid firstIndex"),m(d,c),m(h,d)):c<h&&(d<=c?(R(d>=0&&d<=c,"invalid firstIndex"),m(d,c),m(h,l),m(0,d)):(R(d>=h&&d<=l,"invalid firstIndex"),m(d,l),m(0,c),m(h,d))):c>h?m(h,c):c<h&&(m(0,c),m(h,l)),i.bindVAO(null)}};function V(e,t,n){const r=e.allocateHead();N(t,n,e.view,r)}function N(e,t,n,r){M(e.modelOrigin,t,n.modelOriginHi,n.modelOriginLo,r),n.model.copyFrom(r,e.model,t),n.modelNormal.copyFrom(r,e.modelNormal,t),e.color&&n.color&&n.color.copyFrom(r,e.color,t),e.objectAndLayerIdColor&&n.objectAndLayerIdColor&&n.objectAndLayerIdColor.copyFrom(r,e.objectAndLayerIdColor,t),e.featureAttribute&&n.featureAttribute&&n.featureAttribute.copyFrom(r,e.featureAttribute,t)}function P(e){let t=v().vec3f("instanceModelOriginHi").vec3f("instanceModelOriginLo").mat3f("instanceModel").mat3f("instanceModelNormal");return null!=e&&e.includes("featureAttribute")&&(t=t.vec4f("instanceFeatureAttribute")),null!=e&&e.includes("color")&&(t=t.vec4u8("instanceColor")),null!=e&&e.includes("objectAndLayerIdColor")&&(t=t.vec4u8("instanceObjectAndLayerIdColor")),t}e([l({constructOnly:!0})],B.prototype,"symbol",void 0),e([l({constructOnly:!0})],B.prototype,"optionalFields",void 0),e([l({constructOnly:!0})],B.prototype,"metadata",void 0),e([l({constructOnly:!0})],B.prototype,"shaderTransformation",void 0),e([l()],B.prototype,"_instanceData",void 0),e([l()],B.prototype,"_cycleStartIndex",void 0),e([l({readOnly:!0})],B.prototype,"_enableLevelSelection",null),e([l()],B.prototype,"_updateCyclesWithStaticCamera",void 0),e([l({readOnly:!0})],B.prototype,"running",null),B=e([c("esri.views.3d.webgl-engine.lib.lodRendering.LodRenderer")],B);const z=f(),W=p(),k=h(),G=f(),Y=f(),Z=[_(1,0,1,1),_(0,0,1,1),_(0,1,0,1),_(1,1,0,1),_(1,0,0,1)],$=new A;export{B as LodRenderer};
|
|
5
|
+
import{__decorate as e}from"tslib";import{isSome as t}from"../../../../../core/arrayUtils.js";import n from"../../../../../core/Error.js";import{someMap as r,getOrCreateMapValue as s}from"../../../../../core/MapUtils.js";import{destroyMaybe as a}from"../../../../../core/maybe.js";import{isAborted as i,throwIfAborted as o}from"../../../../../core/promiseUtils.js";import{property as l}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import{subclass as c}from"../../../../../core/accessorSupport/decorators/subclass.js";import{create as h}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{d,e as u,t as m}from"../../../../../chunks/vec32.js";import{create as f}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as p,fromValues as _}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{debugFlags as g}from"../../../support/debugFlags.js";import{glLayout as y}from"../../../support/buffer/glUtil.js";import{newLayout as v}from"../../../support/buffer/InterleavedLayout.js";import b from"../../../webgl/RenderCamera.js";import{AsyncRenderPlugin as I}from"../../effects/RenderPlugin.js";import{Default3D as C}from"../DefaultVertexAttributeLocations.js";import{DepthRange as D}from"../DepthRange.js";import{assert as R}from"../Util.js";import{InstanceData as E}from"./InstanceData.js";import{InstanceOctree as L}from"./InstanceOctree.js";import{LevelSelector as x}from"./LevelSelector.js";import{LodLevel as j}from"./LodLevel.js";import{RenderInstanceData as S}from"./RenderInstanceData.js";import{colorMixModes as w}from"../../materials/internal/MaterialUtil.js";import{encodeDoubleVec3 as M}from"../../materials/renderers/utils.js";import{DefaultMaterialDrawParameters as A}from"../../shaders/DefaultMaterialTechnique.js";import{defaultHighlightName as O}from"../../../../support/HighlightDefaults.js";import{TaskPriority as U,noBudget as T}from"../../../../support/Scheduler.js";import{bindVertexBufferLayout as F}from"../../../../webgl/Util.js";const q=e=>{const t=e.baseBoundingSphere.radius,n=e.levels.map(e=>e.minScreenSpaceRadius);return new x(t,n)};let H=class extends I{constructor(e,t){super(e),this.type=6,this.isGround=!1,this._levels=[],this._defaultRenderInstanceData=new Array,this._highlightRenderInstanceDataMap=new Map,this._instanceIndex=0,this._cycleStartIndex=0,this._slicePlane=!1,this._camera=new b,this._updateCyclesWithStaticCamera=-1,this._needFullCycle=!1,this.produces=new Map([[2,e=>this._produces(e)],[4,e=>!!this._hasTransparentLevels()&&this._produces(e)]]),this._instanceData=new E({shaderTransformation:e.shaderTransformation},e.optionalFields),this.addHandles(t.registerTask(U.LOD_RENDERER,this))}initialize(){this._instanceBufferLayout=N(this.optionalFields),this._glInstanceBufferLayout=y(this._instanceBufferLayout,1),this.addHandles([this._instanceData.events.on("instances-changed",()=>this._requestUpdateCycle()),this._instanceData.events.on("instance-transform-changed",({index:e})=>{this._requestUpdateCycle(),this.metadata.notifyGraphicGeometryChanged(e)}),this._instanceData.events.on("instance-visibility-changed",({index:e})=>{this._requestUpdateCycle(!0),this.metadata.notifyGraphicVisibilityChanged(e)}),this._instanceData.events.on("instance-highlight-changed",()=>this._requestUpdateCycle(!0))])}get _allRenderInstanceData(){return[this._defaultRenderInstanceData,...this._highlightRenderInstanceDataMap.values()]}get _allRenderInstanceDataExceptHighlightShadow(){const e=[this._defaultRenderInstanceData];for(const t of this._highlightRenderInstanceDataMap)t[0]!==O&&e.push(t[1]);return e}hasHighlight(e){return this._highlightRenderInstanceDataMap.has(e)}get _enableLevelSelection(){return this.symbol.levels.length>1}get levels(){return this._levels}get baseBoundingBox(){return this._levels[this._levels.length-1].boundingBox}get baseBoundingSphere(){return this._levels[this._levels.length-1].boundingSphere}get baseMaterial(){return this._levels[this._levels.length-1].components[0].material}get slicePlaneEnabled(){return this._slicePlane}set slicePlaneEnabled(e){this._slicePlane=e}get layerViewUid(){return this.metadata.layerViewUid}get instanceData(){return this._instanceData}get hasEmissions(){return this._levels.some(e=>e.components.some(e=>e.material.hasEmissions))}get usedMemory(){return this._allRenderInstanceData.reduce((e,t)=>t.reduce((e,t)=>e+t.usedMemory,e),this._levels.reduce((e,t)=>e+t.components.reduce((e,t)=>e+t.usedMemory,0),0))}get renderStats(){const e=this._instanceData.size,t=[];return this._levels.forEach((e,n)=>{const r=this._allRenderInstanceData[0][n].size+this._allRenderInstanceData[1][n].size,s=e.triangleCount;t.push({renderedInstances:r,renderedTriangles:r*s,trianglesPerInstance:s})}),{totalInstances:e,renderedInstances:t.reduce((e,t)=>e+t.renderedInstances,0),renderedTriangles:t.reduce((e,t)=>e+t.renderedTriangles,0),levels:t}}_createRenderInstanceDataArray(e=[]){const{rctx:t}=this._context.renderContext;return this.symbol.levels.map(n=>{e.push(new S(t,this._instanceBufferLayout))}),e}async initializeRenderContext(e,n){this._context=e,this._createRenderInstanceDataArray(this._defaultRenderInstanceData);const r=await Promise.allSettled(this.symbol.levels.map(t=>j.create(e,t,n))),s=r.map(e=>"fulfilled"===e.status?e.value:null).filter(t);if(i(n)||s.length!==r.length){s.forEach(e=>e.destroy()),o(n);for(const e of r)if("rejected"===e.status)throw e.reason}this._levels=s,this._levelSelector=q(this)}uninitializeRenderContext(){this._invalidateOctree(),this._levels.forEach(e=>e.destroy()),this._defaultRenderInstanceData.forEach(e=>e.destroy()),this._highlightRenderInstanceDataMap.forEach(e=>e.forEach(e=>e.destroy()))}_hasTransparentLevels(){return this._levels.some(e=>e.components.some(e=>{const t=e.material.produces.get(4);return t?.(0)}))}hasHighlights(){return r(this._highlightRenderInstanceDataMap,e=>e.some(e=>e.size>0))}_produces(e){return(8!==e||this.hasHighlights())&&(5!==e||this.hasHighlight(O))}prepareRender(e){if(!g.LOD_INSTANCE_RENDERER_DISABLE_UPDATES){if(this._enableLevelSelection){const t=e.bind.contentCamera.equals(this._camera);this._camera.copyFrom(e.bind.contentCamera),t||this._requestUpdateCycle()}this._needFullCycle&&(this.runTask(T),this._needFullCycle=!1)}}acquireTechniques(e){if(!this.baseMaterial.visible||!this.baseMaterial.isVisibleForOutput(e.output))return null;const t=this._getInstanceDatas(e);if(!t)return null;const n=new Array,r=this.levels;return t.forEach(t=>r.forEach(({components:r},s)=>r.forEach(r=>n.push(this._beginComponent(e,t[s],r))))),n}render(e,t){const n=this._getInstanceDatas(e);if(!n||null==t)return;let r=0;e.rctx.bindVAO();const s=this.levels;n.forEach(n=>s.forEach(({components:s},a)=>s.forEach(s=>this._renderComponent(e,t[r++],n[a],s,a))))}_getInstanceDatas(e){const{output:t,bind:n}=e,r=8===t,s=5===t,a=6!==t;if(!r&&!s)return a?this._allRenderInstanceData:this._allRenderInstanceDataExceptHighlightShadow;const{_highlightRenderInstanceDataMap:i}=this;if(a){if(r){const e=n.highlight?.name;if(!e)return null;const t=i.get(e);return t?[t]:null}const e=i.get(O);return s?e?[e]:null:Array.from(i.values())}return null}intersect(e,t,n,r){if(!this.baseMaterial.visible||null==this._octree)return;const s=f();d(s,r,n);const a=s=>{this._instanceData.getCombinedModelTransform(s,W),e.transform.set(W),m(k,n,e.transform.inverse),m(G,r,e.transform.inverse);const a=this._instanceData.getState(s),i=this._instanceData.getLodLevel(s),o=this._levels.length;R(!!(18&a),"invalid instance state"),R(i>=0&&i<o,"invaid lod level"),this._levels[i].intersect(e,t,k,G,s,this.metadata,o)};this.baseMaterial.parameters.verticalOffset?this._octree.forEach(a):this._octree.forEachAlongRay(n,s,a)}notifyShaderTransformationChanged(){this._invalidateOctree(),this._requestUpdateCycle()}get _octree(){if(null==this._octreeCached){const e=this._instanceData,t=e.view?.state;if(!t)return null;this._octreeCached=new L(e,this.baseBoundingSphere);for(let n=0;n<e.capacity;++n)18&t.get(n)&&this._octreeCached.addInstance(n)}return this._octreeCached}_invalidateOctree(){this._octreeCached=a(this._octreeCached)}queryDepthRange(e){if(null==this._octree)return new D;const t=e.viewForward,n=this._octree.findClosest(t,1,e.frustum),r=this._octree.findClosest(t,-1,e.frustum);if(null==n||null==r)return new D;const s=e.eye,a=this._instanceData.view;a.boundingSphere.getVec(n,z),d(z,z,s);const i=u(z,t)-z[3];a.boundingSphere.getVec(r,z),d(z,z,s);const o=u(z,t)+z[3];return new D(i,o)}_requestUpdateCycle(e=!1){this._updateCyclesWithStaticCamera=-1,this._cycleStartIndex=this._instanceIndex,e&&(this._needFullCycle=!0,this._context.requestRender())}_startUpdateCycle(){this._updateCyclesWithStaticCamera++,this._allRenderInstanceData.forEach(e=>e.forEach(e=>e.startUpdateCycle()))}get running(){return this._instanceData.size>0&&this._updateCyclesWithStaticCamera<1}runTask(e){const{_enableLevelSelection:t,_camera:r,_levelSelector:a}=this;this._allRenderInstanceData.forEach(e=>e.forEach(e=>e.beginUpdate()));const i=this._instanceData,o=i.view;let l=i.size;const c=i.capacity;let h=this._instanceIndex;const d=Math.ceil(c/500),{_highlightRenderInstanceDataMap:u}=this;for(let m=0;m<l&&!e.done;++m){h===this._cycleStartIndex&&this._startUpdateCycle();const m=o.state.get(h);let f=0;if(!(1&m)){h=h+1===c?0:h+1,l++;continue}const p=o.lodLevel.get(h);if(2&m&&this._defaultRenderInstanceData[p].freeTail(),16&m){const e=i.geHighlightOptionsPrev(h);if(e){const t=u.get(e);if(!t)throw new n("internal:lod-renderer","Internal error in lodRenderer");t[p].freeTail(),t.every(e=>e.isEmpty)&&(t.forEach(e=>e.destroy()),u.delete(e))}}if(32&m)i.freeInstance(h);else if(4&m){let e=0;if(t&&(o.modelOrigin.getVec(h,P),e=a.selectLevel(P,i.getCombinedMedianScaleFactor(h),r)),f=-83&m,e>=0)if(8&m){const t=i.getHighlightName(h);if(t){const r=()=>{const e=this._createRenderInstanceDataArray();return e.forEach(e=>e.beginUpdate()),e},a=s(u,t,r);if(e>=a.length)throw new n("internal:lod-renderer",`LodRenderer internal error - missing lodLevel ${e}`);B(a[e],o,h)}f|=16}else B(this._defaultRenderInstanceData[e],o,h),f|=2;o.state.set(h,f),o.lodLevel.set(h,e)}else f=-83&m,o.state.set(h,f);if(null!=this._octreeCached){const e=!!(18&m),t=!!(18&f);!e&&t?this._octreeCached.addInstance(h):e&&!t?this._octreeCached.removeInstance(h):e&&t&&64&m&&(this._octreeCached.removeInstance(h),this._octreeCached.addInstance(h))}h=h+1===c?0:h+1,h%d===0&&e.madeProgress()}this._instanceIndex=h,this._allRenderInstanceData.forEach(e=>e.forEach(e=>e.endUpdate())),this._context.requestRender()}_beginComponent(e,t,n){if(0===t.size)return null;const r=n.glMaterials.load(e.rctx,e.bind.slot,e.output);return r?.beginSlot(e.bind)}_renderComponent(e,t,n,r,s){if(!t)return;const{bind:a,rctx:i}=e;i.runAppleAmdDriverHelper();const o=i.bindTechnique(t,a,r.material.parameters,Z);i.bindVAO(r.vao),t.ensureAttributeLocations(r.vao),g.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL&&0===e.output&&(o.setUniform4fv("externalColor",Y[Math.min(s,Y.length-1)]),o.setUniform1i("symbolColorMixMode",w.replace));const l=n.capacity,c=n.headIndex,h=n.tailIndex,d=n.firstIndex,u=this._glInstanceBufferLayout,m=(e,s)=>{F(i,C,n.buffer,u,e),i.drawArraysInstanced(t.primitiveType,0,r.vertexCount,s-e)};r.material.transparent&&null!=d?c>h?(R(d>=h&&d<=c,"invalid firstIndex"),m(d,c),m(h,d)):c<h&&(d<=c?(R(d>=0&&d<=c,"invalid firstIndex"),m(d,c),m(h,l),m(0,d)):(R(d>=h&&d<=l,"invalid firstIndex"),m(d,l),m(0,c),m(h,d))):c>h?m(h,c):c<h&&(m(0,c),m(h,l)),i.unbindBuffer(34962),i.bindVAO(null)}};function B(e,t,n){const r=e.allocateHead();V(t,n,e.view,r)}function V(e,t,n,r){M(e.modelOrigin,t,n.modelOriginHi,n.modelOriginLo,r),n.model.copyFrom(r,e.model,t),n.modelNormal.copyFrom(r,e.modelNormal,t),e.color&&n.color&&n.color.copyFrom(r,e.color,t),e.objectAndLayerIdColor&&n.objectAndLayerIdColor&&n.objectAndLayerIdColor.copyFrom(r,e.objectAndLayerIdColor,t),e.featureAttribute&&n.featureAttribute&&n.featureAttribute.copyFrom(r,e.featureAttribute,t)}function N(e){let t=v().vec3f("instanceModelOriginHi").vec3f("instanceModelOriginLo").mat3f("instanceModel").mat3f("instanceModelNormal");return null!=e&&e.includes("featureAttribute")&&(t=t.vec4f("instanceFeatureAttribute")),null!=e&&e.includes("color")&&(t=t.vec4u8("instanceColor")),null!=e&&e.includes("objectAndLayerIdColor")&&(t=t.vec4u8("instanceObjectAndLayerIdColor")),t}e([l({constructOnly:!0})],H.prototype,"symbol",void 0),e([l({constructOnly:!0})],H.prototype,"optionalFields",void 0),e([l({constructOnly:!0})],H.prototype,"metadata",void 0),e([l({constructOnly:!0})],H.prototype,"shaderTransformation",void 0),e([l()],H.prototype,"_instanceData",void 0),e([l()],H.prototype,"_cycleStartIndex",void 0),e([l({readOnly:!0})],H.prototype,"_enableLevelSelection",null),e([l()],H.prototype,"_updateCyclesWithStaticCamera",void 0),e([l({readOnly:!0})],H.prototype,"running",null),H=e([c("esri.views.3d.webgl-engine.lib.lodRendering.LodRenderer")],H);const P=f(),z=p(),W=h(),k=f(),G=f(),Y=[_(1,0,1,1),_(0,0,1,1),_(0,1,0,1),_(1,1,0,1),_(1,0,0,1)],Z=new A;export{H as LodRenderer};
|