@arcgis/core 4.27.0-rc.0 → 4.27.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/arcade/featureSetUtils.js +1 -1
- package/arcade/featureset/actions/GroupBy.js +1 -1
- package/arcade/featureset/actions/OrderBy.js +1 -1
- package/arcade/functions/featuresetbase.js +1 -1
- package/arcade/functions/featuresetstring.js +1 -1
- package/arcade/languageUtils.js +1 -1
- package/arcade/treeAnalysis.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0407bf97ad621c89a734.js +1 -0
- package/assets/esri/core/workers/chunks/0610691a0c0d9fbbd6d2.js +1 -0
- package/assets/esri/core/workers/chunks/{7ec6be2bc0f354011e46.js → 07651ef8348f702d59ac.js} +1 -1
- package/assets/esri/core/workers/chunks/0a02ac5628d1739372c6.js +1 -0
- package/assets/esri/core/workers/chunks/0a86c458916e83d6c523.js +1 -0
- package/assets/esri/core/workers/chunks/14145959a3dab1437818.js +1 -0
- package/assets/esri/core/workers/chunks/16db0bc87d87a7313dc4.js +1 -0
- package/assets/esri/core/workers/chunks/183e2e0cb86c1c640d94.js +1 -0
- package/assets/esri/core/workers/chunks/19d329b9d4ec2eff1d13.js +1 -0
- package/assets/esri/core/workers/chunks/1b8074269800b384ecf6.js +1 -0
- package/assets/esri/core/workers/chunks/2154d395f405be3cd3ba.js +1 -0
- package/assets/esri/core/workers/chunks/{33dbba3b7fc648437e50.js → 21e1f3b11e7d363b727a.js} +1 -1
- package/assets/esri/core/workers/chunks/{31a158c73994603c169d.js → 2446e336b1f7256d4fde.js} +1 -1
- package/assets/esri/core/workers/chunks/29290a44fd3b183c24e3.js +1 -0
- package/assets/esri/core/workers/chunks/{f498c4d4831141125781.js → 2f5639886f577baedbca.js} +1 -1
- package/assets/esri/core/workers/chunks/33901eb1574e46abd9af.js +1 -0
- package/assets/esri/core/workers/chunks/{9c78ad5ab57e0d47ac43.js → 3ba2fcb9110230f8790c.js} +1 -1
- package/assets/esri/core/workers/chunks/3e239bfad611985e50fb.js +1 -0
- package/assets/esri/core/workers/chunks/42f3421740a5479559dc.js +1 -0
- package/assets/esri/core/workers/chunks/474d9b334812533bab36.js +1 -0
- package/assets/esri/core/workers/chunks/53ad34bf32f5f3d4fe18.js +1 -0
- package/assets/esri/core/workers/chunks/{97cdbec7532cfcdf9ad2.js → 595a2baa04d92de59558.js} +1 -1
- package/assets/esri/core/workers/chunks/624521961fe1f2c4f2c5.js +1 -0
- package/assets/esri/core/workers/chunks/{212d59764c275c763941.js → 659b7bad7281c0e2aed3.js} +1 -1
- package/assets/esri/core/workers/chunks/6a3d611e8842afbb50ab.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/6e562fa57c0347091154.js +1 -0
- package/assets/esri/core/workers/chunks/7479dc0c790337af7597.js +1 -0
- package/assets/esri/core/workers/chunks/{e88cff2537be52da6531.js → 74fd2059ddda9083cbcc.js} +1 -1
- package/assets/esri/core/workers/chunks/7dc6774c77c822b68c99.js +1 -0
- package/assets/esri/core/workers/chunks/82a103a8b5382300889d.js +1 -0
- package/assets/esri/core/workers/chunks/{3fe357df92afa1bee70a.js → 90da1ed112b82712d0ef.js} +1 -1
- package/assets/esri/core/workers/chunks/{9849f64793f2ad39366b.js → 9290b0d330f02233d803.js} +1 -1
- package/assets/esri/core/workers/chunks/92e7f224a80195e606d6.js +1 -0
- package/assets/esri/core/workers/chunks/{36df72362b38759b895b.js → 9648a8f2b24f1ca3d637.js} +1 -1
- package/assets/esri/core/workers/chunks/{ad18fb7bb54a0c4bdb38.js → a20361b4d3bdd7d196ca.js} +1 -1
- package/assets/esri/core/workers/chunks/a7fd2a95fde197c06828.js +1 -0
- package/assets/esri/core/workers/chunks/b0cda39b53ecd6c44cd0.js +1 -0
- package/assets/esri/core/workers/chunks/b2a423d9ce8bb784267c.js +1 -0
- package/assets/esri/core/workers/chunks/b5fc6f2044ed047c5afd.js +1 -0
- package/assets/esri/core/workers/chunks/{df0453cdfe685d6436cc.js → b6dc41fce601b9d3480e.js} +1 -1
- package/assets/esri/core/workers/chunks/b8e6c64792a512df4c4d.js +1 -0
- package/assets/esri/core/workers/chunks/c6617a937440701c0180.js +1 -0
- package/assets/esri/core/workers/chunks/c6efe2e04ea6a55bb6e3.js +1 -0
- package/assets/esri/core/workers/chunks/d8607326a199dd994844.js +1 -0
- package/assets/esri/core/workers/chunks/d8bd3f498b3fa8153404.js +1 -0
- package/assets/esri/core/workers/chunks/{39e473586579d11d6732.js → e2432871f1329f47465d.js} +1 -1
- package/assets/esri/core/workers/chunks/ee5ee03dd2c7dc940272.js +1 -0
- package/assets/esri/core/workers/chunks/{c83669cf08391a62fb72.js → f1da7b29eecad0e9efae.js} +1 -1
- package/assets/esri/core/workers/chunks/{2e627c94e57c924e5917.js → f339db2b599fa9585283.js} +1 -1
- package/assets/esri/core/workers/chunks/f505ebd4bd3bfb6c790d.js +1 -0
- package/assets/esri/core/workers/chunks/{3c6c082157c916f8ddba.js → ffe61d5a6a9b34bee9d4.js} +1 -1
- package/assets/esri/themes/base/widgets/_Bookmarks.scss +5 -0
- package/assets/esri/themes/base/widgets/_Features.scss +5 -7
- package/assets/esri/themes/base/widgets/_Popup.scss +3 -3
- package/assets/esri/themes/base/widgets/_Swipe.scss +11 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/SSAO.glsl.js +1 -1
- package/chunks/languageUtils.js +1 -1
- package/geometry/Mesh.js +1 -1
- package/geometry/support/DoubleArray.js +1 -1
- package/geometry/support/meshUtils/bounds.js +5 -0
- package/geometry/support/meshUtils/georeference.js +1 -1
- package/interfaces.d.ts +2 -2
- package/kernel.js +1 -1
- package/layers/FeatureLayer.js +1 -1
- package/layers/StreamLayer.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/data/QueryEngine.js +1 -1
- package/layers/graphics/data/attributeSupport.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
- package/layers/support/FeatureReductionBinning.js +1 -1
- package/layers/support/FeatureReductionCluster.js +1 -1
- package/layers/support/featureLayerUtils.js +1 -1
- package/layers/support/rasterFunctions/colormaps.js +1 -1
- package/package.json +2 -2
- package/renderers/support/utils.js +1 -1
- package/support/arcadeUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/CIMSymbolHelper.js +1 -1
- package/symbols/cim/effects/EffectBuffer.js +1 -1
- package/symbols/cim/effects/EffectDonut.js +1 -1
- package/symbols/cim/effects/EffectOffset.js +1 -1
- package/views/2d/layers/features/Store2D.js +1 -1
- package/views/2d/layers/features/sources/StreamSource.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/webStyleUtils.js +1 -1
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/webgl-engine/lib/Camera.js +1 -1
- package/views/3d/webgl-engine/materials/pbrUtils.js +5 -0
- package/webdoc/support/writeUtils.js +1 -1
- package/widgets/Bookmarks/css.js +1 -1
- package/widgets/Bookmarks.js +1 -1
- package/widgets/Features.js +1 -1
- package/assets/esri/core/workers/chunks/0b03165dbf289797cefa.js +0 -1
- package/assets/esri/core/workers/chunks/0c1c0024879f944f44c4.js +0 -1
- package/assets/esri/core/workers/chunks/13a48796905613bc1679.js +0 -1
- package/assets/esri/core/workers/chunks/1ea1104651ab15f9a13c.js +0 -1
- package/assets/esri/core/workers/chunks/2108cfc7921430f0b805.js +0 -1
- package/assets/esri/core/workers/chunks/2eacca322737aafd8f0c.js +0 -1
- package/assets/esri/core/workers/chunks/39577683e334eb4d904c.js +0 -1
- package/assets/esri/core/workers/chunks/4d3deeb0ebd0ce8c1215.js +0 -1
- package/assets/esri/core/workers/chunks/576bddc3fa7d91a7e5bd.js +0 -1
- package/assets/esri/core/workers/chunks/623d6710a4f800c622ce.js +0 -1
- package/assets/esri/core/workers/chunks/6782cc3feb713676d544.js +0 -1
- package/assets/esri/core/workers/chunks/6e7178de0b2c3d2f7e6b.js +0 -1
- package/assets/esri/core/workers/chunks/78ce0b1af62435d8ebf4.js +0 -1
- package/assets/esri/core/workers/chunks/79d2baf392589588ef9b.js +0 -1
- package/assets/esri/core/workers/chunks/7bbdba52157da13a01fc.js +0 -1
- package/assets/esri/core/workers/chunks/84860b535a70ec448cfe.js +0 -1
- package/assets/esri/core/workers/chunks/9035d9e09a4e7cb94d37.js +0 -1
- package/assets/esri/core/workers/chunks/956b0fef7bc849415354.js +0 -1
- package/assets/esri/core/workers/chunks/9ab98321a4a7eaeeb018.js +0 -1
- package/assets/esri/core/workers/chunks/9cb7a68ff46e5c43e1d2.js +0 -1
- package/assets/esri/core/workers/chunks/a0f7f7f578521970c714.js +0 -1
- package/assets/esri/core/workers/chunks/a60eac45d3c65bd0216f.js +0 -1
- package/assets/esri/core/workers/chunks/aca5260f6984952a6e3d.js +0 -1
- package/assets/esri/core/workers/chunks/b05be356743fa5d24573.js +0 -1
- package/assets/esri/core/workers/chunks/ba6024465308c248170b.js +0 -1
- package/assets/esri/core/workers/chunks/d0983f808008920514f2.js +0 -1
- package/assets/esri/core/workers/chunks/dab832799bc06b0fec34.js +0 -1
- package/assets/esri/core/workers/chunks/e45d36aef2bc69ee9132.js +0 -1
- package/assets/esri/core/workers/chunks/e5bbd4cc5edbf7ab3624.js +0 -1
- package/assets/esri/core/workers/chunks/e700cf4d1f99291a4396.js +0 -1
- package/assets/esri/core/workers/chunks/f398a5cf33c3fd2522a5.js +0 -1
- package/assets/esri/core/workers/chunks/f4ee94a6cde4ea8837f1.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.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../Color.js";import"../../symbols.js";import{bidiText as t}from"../../core/BidiText.js";import{getFontFamily as r}from"../../core/fontUtils.js";import{clone as o}from"../../core/lang.js";import a from"../../core/Logger.js";import i from"../../core/RandomLCG.js";import{pt2px as s,px2pt as n}from"../../core/screenUtils.js";import{create as l,expandPointInPlace as c}from"../../geometry/support/aaBoundingRect.js";import{getBoundsXY as m}from"../../geometry/support/boundsUtils.js";import{createRendererExpression as f}from"../../support/arcadeOnDemand.js";import{Placement as y}from"./CIMPlacements.js";import{DEFAULT_TEXT_HEIGHT as u,horizontalAlignment2HAlign as h,verticalAlignment2VAlign as p,EnvDrawHelper as M,Transformation as d,CanvasDrawHelper as S,DEFAULT_HATCH_FILL_SEPARATION as b,lineGapType2LineHeight as g}from"./CIMSymbolDrawHelper.js";import{LineCapStyle as C,LineJoinStyle as I,BlockProgression as k,FontEffects as x,FontEncoding as w,FontType as P,GlyphHinting as L,TextReadingDirection as v,VerticalGlyphOrientation as F,BillBoardMode as D,TextureFilter as T,ExtremityPlacement as G}from"./enums.js";import{getValue as z,fromCIMFontStyle as E,fromCIMFontDecoration as O,isCIMMarkerStrokePlacement as A,attributesToFields as N,analyzeTextParts as R,assignTextValuesFromFeature as j,isGeometryEngineRequired as V,importGeometryEngine as B}from"./utils.js";import X from"../../views/2d/arcade/callExpressionWithFeature.js";import{C_INFINITY as _}from"../../views/2d/engine/vectorTiles/GeometryUtils.js";import{GLYPH_SIZE as H,MAGIC_LABEL_LINE_HEIGHT as Y,RANDOM_INSIDE_POLYGON_TEXTURE_SIZE as U}from"../../views/2d/engine/webgl/definitions.js";import{shapeGlyphs as $}from"../../views/2d/engine/webgl/mesh/templates/shapingUtils.js";import q from"../Font.js";const W=Math.PI,J=W/2,K=Math.PI/180,Q=96/72,Z=4,ee=a.getLogger("esri.symbols.cim.CIMSymbolHelper");function te(e){if(!e||!e.type)return null;let t;switch(e.type){case"cim":return e.data;case"web-style":return e;case"simple-marker":{const r=ne.fromSimpleMarker(e);if(!r)return null;t=r;break}case"picture-marker":t=ne.fromPictureMarker(e);break;case"simple-line":t=ne.fromSimpleLineSymbol(e);break;case"simple-fill":t=ne.fromSimpleFillSymbol(e);break;case"picture-fill":t=ne.fromPictureFillSymbol(e);break;case"text":t=ne.fromTextSymbol(e)}return{type:"CIMSymbolReference",symbol:t}}function re(e,t,r){switch(t.type){case"CIMSymbolReference":return re(e,t.symbol,r);case"CIMPointSymbol":null==r&&(r={x:0,y:0}),e.drawSymbol(t,r);break;case"CIMLineSymbol":null==r&&(r={paths:[[[0,0],[10,0]]]}),e.drawSymbol(t,r);break;case"CIMPolygonSymbol":null==r&&(r={rings:[[[0,0],[0,10],[10,10],[10,0],[0,0]]]}),e.drawSymbol(t,r);break;case"CIMTextSymbol":{const r={x:0,y:0};e.drawSymbol(t,r);break}case"CIMVectorMarker":{const r=new y;e.drawMarker(t,r);break}}return e.envelope()}function oe(e){if(!e)return 0;switch(e.type){case"CIMMarkerPlacementAlongLineSameSize":case"CIMMarkerPlacementAlongLineRandomSize":case"CIMMarkerPlacementAtExtremities":case"CIMMarkerPlacementAtMeasuredUnits":case"CIMMarkerPlacementAtRatioPositions":case"CIMMarkerPlacementOnLine":case"CIMMarkerPlacementOnVertices":return Math.abs(e.offset);default:return 0}}function ae(e){if(!e)return 0;switch(e.type){case"CIMGeometricEffectArrow":return Math.abs(.5*e.width);case"CIMGeometricEffectBuffer":return Math.abs(e.size);case"CIMGeometricEffectExtension":case"CIMGeometricEffectRadial":return Math.abs(e.length);case"CIMGeometricEffectJog":return Math.abs(.5*e.length);case"CIMGeometricEffectMove":return Math.max(Math.abs(z(e.offsetX)),Math.abs(z(e.offsetY)));case"CIMGeometricEffectOffset":case"CIMGeometricEffectOffsetTangent":return Math.abs(e.offset);case"CIMGeometricEffectRegularPolygon":return Math.abs(e.radius);case"CIMGeometricEffectRotate":case"CIMGeometricEffectScale":default:return 0;case"CIMGeometricEffectTaperedPolygon":return.5*Math.max(Math.abs(e.fromWidth),Math.abs(e.toWidth));case"CIMGeometricEffectWave":return Math.abs(e.amplitude);case"CIMGeometricEffectDonut":return e.width}}function ie(e){if(!e)return 0;let t=0;for(const r of e)t+=ae(r);return t}class se{getSymbolInflateSize(e,t,r,o,a){return e||(e=[0,0,0,0]),t?this._getInflateSize(e,t,r,o,a):e}static safeSize(e){const t=Math.max(Math.abs(e[0]),Math.abs(e[2])),r=Math.max(Math.abs(e[1]),Math.abs(e[3]));return Math.sqrt(t*t+r*r)}_vectorMarkerBounds(e,t,r,o){let a=!0;const i=l();if(t&&t.markerGraphics)for(const s of t.markerGraphics){const t=[0,0,0,0];s.geometry&&(m(i,s.geometry),t[0]=0,t[1]=0,t[2]=0,t[3]=0,this.getSymbolInflateSize(t,s.symbol,r,0,o),i[0]+=t[0],i[1]+=t[1],i[2]+=t[2],i[3]+=t[3],a?(e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],a=!1):(e[0]=Math.min(e[0],i[0]),e[1]=Math.min(e[1],i[1]),e[2]=Math.max(e[2],i[2]),e[3]=Math.max(e[3],i[3])))}return e}_getInflateSize(e,t,r,o,a){if(Se(t)){const i=this._getLayersInflateSize(e,t.symbolLayers,r,o,a),s=ie(t.effects);return s>0&&(i[0]-=s,i[1]-=s,i[2]+=s,i[3]+=s),i}return this._getTextInflatedSize(e,t,a)}_getLayersInflateSize(e,t,r,o,a){let i=!0;if(!t)return e;for(const s of t){if(!s)continue;let t=[0,0,0,0];switch(s.type){case"CIMSolidFill":case"CIMPictureFill":case"CIMHatchFill":case"CIMGradientFill":break;case"CIMSolidStroke":case"CIMPictureStroke":case"CIMGradientStroke":{const e=s;let r=e.width;null!=r&&(e.capStyle===C.Square||e.joinStyle===I.Miter?r/=1.4142135623730951:r/=2,t[0]=-r,t[1]=-r,t[2]=r,t[3]=r);break}case"CIMCharacterMarker":case"CIMVectorMarker":case"CIMPictureMarker":{const e=s;if("CIMVectorMarker"===s.type){const e=s;if(t=this._vectorMarkerBounds(t,e,r,a),e.frame){const r=(e.frame.xmin+e.frame.xmax)/2,o=(e.frame.ymin+e.frame.ymax)/2;if(t[0]-=r,t[1]-=o,t[2]-=r,t[3]-=o,null!=e.size){const r=e.size/(e.frame.ymax-e.frame.ymin);t[0]*=r,t[1]*=r,t[2]*=r,t[3]*=r}}}else if("CIMPictureMarker"===s.type){const o=s,a=r.getResource(o.url);let i=1;if(null!=a&&a.height&&(i=a.width/a.height),null!=e.size){const r=e.size/2,a=e.size*i*o.scaleX/2;t=[-a,-r,a,r]}}else if(null!=e.size){const r=e.size/2;t=[-r,-r,r,r]}if(e.anchorPoint){let r,o;"Absolute"===e.anchorPointUnits?(r=e.anchorPoint.x,o=e.anchorPoint.y):(r=e.anchorPoint.x*(t[2]-t[0]),o=e.anchorPoint.y*(t[3]-t[1])),t[0]-=r,t[1]-=o,t[2]-=r,t[3]-=o}let i=z(e.rotation);if(e.rotateClockwise&&(i=-i),o&&(i-=o),i){const e=K*i,r=Math.cos(e),o=Math.sin(e),a=l([_,_,-_,-_]);c(a,[t[0]*r-t[1]*o,t[0]*o+t[1]*r]),c(a,[t[0]*r-t[3]*o,t[0]*o+t[3]*r]),c(a,[t[2]*r-t[1]*o,t[2]*o+t[1]*r]),c(a,[t[2]*r-t[3]*o,t[2]*o+t[3]*r]),t=a}let n=z(e.offsetX),m=z(e.offsetY);if(o){const e=K*o,t=Math.cos(e),r=Math.sin(e),a=n*r+m*t;n=n*t-m*r,m=a}t[0]+=n,t[1]+=m,t[2]+=n,t[3]+=m;const f=oe(e.markerPlacement);f>0&&(t[0]-=f,t[1]-=f,t[2]+=f,t[3]+=f);break}}const n=ie(s.effects);n>0&&(t[0]-=n,t[1]-=n,t[2]+=n,t[3]+=n),i?(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],i=!1):(e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[2]),e[3]=Math.max(e[3],t[3]))}return e}_getTextInflatedSize(e,r,o){const a=r.height??u;if(e[0]=-a/2,e[1]=-a/2,e[2]=a/2,e[3]=a/2,!o)return e;const i=o.get(r);if(!i)return e;const{text:s,mosaicItem:n}=i;if(!n?.glyphMosaicItems?.length)return e;const{lineGapType:l,lineGap:c}=r,m=l?g(l,c??0,a):0,f=t(s)[1],y=n.glyphMosaicItems,M="CIMBackgroundCallout"===r.callout?.type,d=$(y,f,{scale:a/H,angle:z(r.angle),xOffset:z(r.offsetX),yOffset:z(r.offsetY),hAlign:h(r.horizontalAlignment),vAlign:p(r.verticalAlignment),maxLineWidth:512,lineHeight:Y*Math.max(.25,Math.min(m||1,4)),decoration:r.font.decoration||"none",isCIM:!0,hasBackground:M}).boundsT;return e[0]=d.x-d.halfWidth,e[1]=-d.y-d.halfHeight,e[2]=d.x+d.halfWidth,e[3]=-d.y+d.halfHeight,e}}class ne{static getEnvelope(e,t,r){if(!e)return null;const o=new M(r);if(Array.isArray(e)){let r;for(const a of e)r?r.union(re(o,a,t)):r=re(o,a,t);return r}return re(o,e,t)}static getTextureAnchor(e,t){const r=this.getEnvelope(e,null,t);if(!r)return[0,0,0];const o=(r.x+.5*r.width)*Q,a=(r.y+.5*r.height)*Q,i=r.width*Q+2,s=r.height*Q+2;return[-o/i,-a/s,s]}static rasterize(e,t,r,o,a=!0){const i=r||this.getEnvelope(t,null,o);if(!i)return[null,0,0,0,0];const s=(i.x+.5*i.width)*Q,n=(i.y+.5*i.height)*Q;e.width=i.width*Q,e.height=i.height*Q,r||(e.width+=2,e.height+=2);const l=e.getContext("2d"),c=d.createScale(Q,-Q);c.translate(.5*e.width-s,.5*e.height+n);const m=new S(l,o,c);switch(t.type){case"CIMPointSymbol":{const e={type:"point",x:0,y:0};m.drawSymbol(t,e);break}case"CIMVectorMarker":{const e=new y;m.drawMarker(t,e);break}}const f=l.getImageData(0,0,e.width,e.height),u=new Uint8Array(f.data);if(a){let e;for(let t=0;t<u.length;t+=4)e=u[t+3]/255,u[t]=u[t]*e,u[t+1]=u[t+1]*e,u[t+2]=u[t+2]*e}return[u,e.width,e.height,-s/e.width,-n/e.height]}static fromTextSymbol(e){const{angle:r,color:o,font:a,haloColor:i,haloSize:s,horizontalAlignment:n,kerning:l,text:c,verticalAlignment:m,xoffset:f,yoffset:y,backgroundColor:u,borderLineColor:h,borderLineSize:p}=e;let M,d,S,b,g,C;a&&(M=a.family,d=a.style,S=a.weight,b=a.size,g=a.decoration);let I=!1;if(c){I=t(c)[1]}return(u||p)&&(C={type:"CIMBackgroundCallout",margin:null,backgroundSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",color:ue(u)},{type:"CIMSolidStroke",color:ue(h),width:p}]},accentBarSymbol:null,gap:null,leaderLineSymbol:null,lineStyle:null}),{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:!0,anchorPointUnits:"Relative",dominantSizeAxis3D:"Y",size:10,billboardMode3D:"FaceNearPlane",frame:{xmin:-5,ymin:-5,xmax:5,ymax:5},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",angle:r,blockProgression:k.BTT,depth3D:1,extrapolateBaselines:!0,fontEffects:x.Normal,fontEncoding:w.Unicode,fontFamilyName:M||"Arial",fontStyleName:he(d,S),fontType:P.Unspecified,haloSize:s,height:b,hinting:L.Default,horizontalAlignment:fe(n??"center"),kerning:l,letterWidth:100,ligatures:!0,lineGapType:"Multiple",offsetX:z(f),offsetY:z(y),strikethrough:"line-through"===g,underline:"underline"===g,symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:ue(o)}]},haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:ue(i)}]},shadowColor:[0,0,0,255],shadowOffsetX:1,shadowOffsetY:1,textCase:"Normal",textDirection:I?v.RTL:v.LTR,verticalAlignment:ye(m??"baseline"),verticalGlyphOrientation:F.Right,wordSpacing:100,billboardMode3D:D.FaceNearPlane,callout:C},textString:c}],scaleSymbolsProportionally:!0,respectFrame:!0}],scaleX:1,angleAlignment:"Display"}}static fromPictureFillSymbol(e){const{height:t,outline:r,width:o,xoffset:a,xscale:i,yoffset:s,yscale:n}=e,l=[],c={type:"CIMPolygonSymbol",symbolLayers:l};if(r){const{cap:e,join:t,miterLimit:o,width:a}=r;l.push({type:"CIMSolidStroke",color:ue(r.color),capStyle:ce(e),joinStyle:me(t),miterLimit:o,width:a})}let m=e.url;"esriPFS"===e.type&&e.imageData&&(m=e.imageData);const f="angle"in e?e.angle??0:0,y=(o??0)*(i||1),u=(t??0)*(n||1);return l.push({type:"CIMPictureFill",invertBackfaceTexture:!1,scaleX:1,textureFilter:T.Picture,tintColor:null,url:m,height:u,width:y,offsetX:z(a),offsetY:z(s),rotation:z(-f),colorSubstitutions:null}),c}static fromSimpleFillSymbol(e){const{color:t,style:r,outline:a}=e,i=[],s={type:"CIMPolygonSymbol",symbolLayers:i};let l=null;if(a){const{cap:e,join:t,style:r}=a;"solid"!==r&&"none"!==r&&"esriSLSSolid"!==r&&"esriSLSNull"!==r&&(l=[{type:"CIMGeometricEffectDashes",dashTemplate:de(r,e),lineDashEnding:"NoConstraint",scaleDash:!0,offsetAlongLine:null}]),i.push({type:"CIMSolidStroke",color:"esriSLSNull"!==r&&"none"!==r?ue(a.color):[0,0,0,0],capStyle:ce(e),joinStyle:me(t),miterLimit:a.miterLimit,width:a.width,effects:l})}if(r&&"solid"!==r&&"none"!==r&&"esriSFSSolid"!==r&&"esriSFSNull"!==r){const e={type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",color:ue(t),capStyle:C.Butt,joinStyle:I.Miter,width:.75}]};let a=0;const s=n(ge(r)?8:10);switch(r){case"vertical":case"esriSFSVertical":a=90;break;case"forward-diagonal":case"esriSFSForwardDiagonal":case"diagonal-cross":case"esriSFSDiagonalCross":a=-45;break;case"backward-diagonal":case"esriSFSBackwardDiagonal":a=45;break;case"cross":case"esriSFSCross":a=0}i.push({type:"CIMHatchFill",lineSymbol:e,offsetX:0,offsetY:0,rotation:a,separation:s}),"cross"===r||"esriSFSCross"===r?i.push({type:"CIMHatchFill",lineSymbol:o(e),offsetX:0,offsetY:0,rotation:90,separation:s}):"diagonal-cross"!==r&&"esriSFSDiagonalCross"!==r||i.push({type:"CIMHatchFill",lineSymbol:o(e),offsetX:0,offsetY:0,rotation:45,separation:s})}else!r||"solid"!==r&&"esriSFSSolid"!==r||i.push({type:"CIMSolidFill",enable:!0,color:ue(t)});return s}static fromSimpleLineSymbol(e){const{cap:t,color:r,join:o,marker:a,miterLimit:i,style:s,width:n}=e;let l=null;"solid"!==s&&"none"!==s&&"esriSLSSolid"!==s&&"esriSLSNull"!==s&&(l=[{type:"CIMGeometricEffectDashes",dashTemplate:de(s,t),lineDashEnding:"NoConstraint",scaleDash:!0,offsetAlongLine:null}]);const c=[];if(a){let e;switch(a.placement){case"begin-end":e=G.Both;break;case"begin":e=G.JustBegin;break;case"end":e=G.JustEnd;break;default:e=G.None}const t=ne.fromSimpleMarker(a,n,r).symbolLayers[0];t.markerPlacement={type:"CIMMarkerPlacementAtExtremities",angleToLine:!0,offset:0,extremityPlacement:e,offsetAlongLine:0},c.push(t)}return c.push({type:"CIMSolidStroke",color:"none"!==s&&"esriSLSNull"!==s?ue(r):[0,0,0,0],capStyle:ce(t),joinStyle:me(o),miterLimit:i,width:n,effects:l}),{type:"CIMLineSymbol",symbolLayers:c}}static fromPictureMarker(e){const{angle:t,height:r,width:o,xoffset:a,yoffset:i}=e;let s=e.url;return"esriPMS"===e.type&&e.imageData&&(s=e.imageData),{type:"CIMPointSymbol",symbolLayers:[{type:"CIMPictureMarker",invertBackfaceTexture:!1,scaleX:1,textureFilter:T.Picture,tintColor:null,url:s,size:r,width:o,offsetX:z(a),offsetY:z(i),rotation:z(-t)}]}}static fromSimpleMarker(e,t,r){const{style:o}=e,a=e.color??r;if("path"===o){const t=[];if("outline"in e&&e.outline){const r=e.outline;t.push({type:"CIMSolidStroke",enable:!0,width:s(Math.round(n(r.width))),color:ue(r.color)})}t.push({type:"CIMSolidFill",enable:!0,color:ue(a),path:e.path});const[r,o]=be("square");return{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:!0,rotation:z(-e.angle),size:z(e.size||6),offsetX:z(e.xoffset),offsetY:z(e.yoffset),frame:r,markerGraphics:[{type:"CIMMarkerGraphic",geometry:o,symbol:{type:"CIMPolygonSymbol",symbolLayers:t}}]}]}}const[i,l]=be(o);let c;if(l&&i){const r=[];if("outline"in e&&e.outline){const t=e.outline;r.push({type:"CIMSolidStroke",enable:!0,width:null!=t.width&&t.width>.667?s(Math.round(n(t.width))):t.width,color:ue(t.color)})}else!t||"line-marker"!==e.type||"cross"!==e.style&&"x"!==e.style||r.push({type:"CIMSolidStroke",enable:!0,width:t,color:ue(a)});r.push({type:"CIMSolidFill",enable:!0,color:ue(a)});const o={type:"CIMPolygonSymbol",symbolLayers:r};c={type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:!0,rotation:z(-e.angle),size:z(e.size||6*t),offsetX:z(e.xoffset),offsetY:z(e.yoffset),frame:i,markerGraphics:[{type:"CIMMarkerGraphic",geometry:l,symbol:o}]}]}}return c}static fromCIMHatchFill(e,t){const r=t*(e.separation??b),a=r/2,i=o(e.lineSymbol);i.symbolLayers?.forEach((e=>{switch(e.type){case"CIMSolidStroke":null!=e.width&&(e.width*=t),e.effects?.forEach((e=>{"CIMGeometricEffectDashes"===e.type&&(e.dashTemplate=e.dashTemplate.map((e=>e*t)))}));break;case"CIMVectorMarker":{null!=e.size&&(e.size*=t);const r=e.markerPlacement;null!=r&&"placementTemplate"in r&&(r.placementTemplate=r.placementTemplate.map((e=>e*t)));break}}}));let s=this._getLineSymbolPeriod(i)||Z;for(;s<Z;)s*=2;const n=s/2;return{type:"CIMVectorMarker",frame:{xmin:-n,xmax:n,ymin:-a,ymax:a},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{paths:[[[-n,0],[n,0]]]},symbol:i}],size:r}}static fetchResources(e,t,o){if(e&&t)switch(e.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":{const r=e.symbolLayers;if(!r)return;for(const e of r)switch(Ie(e,t,o),e.type){case"CIMPictureFill":case"CIMHatchFill":case"CIMGradientFill":case"CIMPictureStroke":case"CIMGradientStroke":case"CIMCharacterMarker":case"CIMPictureMarker":"url"in e&&e.url&&o.push(t.fetchResource(e.url,null));break;case"CIMVectorMarker":{const r=e.markerGraphics;if(!r)continue;for(const e of r)if(e){const r=e.symbol;r&&ne.fetchResources(r,t,o)}}}break}case"CIMTextSymbol":{const a=e,i=r(a.fontFamilyName),{style:s,weight:n}=E(a.fontStyleName),l=O(a);o.push(t.loadFont(new q({family:i,style:s,weight:n,decoration:l})).catch((()=>{ee.error("unsupported font in preview")})));break}}}static _getLineSymbolPeriod(e){if(e){const t=this._getEffectsRepeat(e.effects);if(t)return t;if(e.symbolLayers)for(const r of e.symbolLayers)if(r){const e=this._getEffectsRepeat(r.effects);if(e)return e;switch(r.type){case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":case"CIMObjectMarker3D":case"CIMglTFMarker3D":{const e=this._getPlacementRepeat(r.markerPlacement);if(e)return e}}}}return 0}static _getEffectsRepeat(e){if(e)for(const t of e)if(t)switch(t.type){case"CIMGeometricEffectDashes":{const e=t.dashTemplate;if(e&&e.length){let t=0;for(const r of e)t+=r;return 1&e.length&&(t*=2),t}break}case"CIMGeometricEffectWave":return t.period;default:ee.error(`unsupported geometric effect type ${t.type}`)}return 0}static _getPlacementRepeat(e){if(e)switch(e.type){case"CIMMarkerPlacementAlongLineSameSize":case"CIMMarkerPlacementAlongLineRandomSize":case"CIMMarkerPlacementAlongLineVariableSize":{const t=e.placementTemplate;if(t&&t.length){let e=0;for(const r of t)e+=+r;return 1&t.length&&(e*=2),e}break}}return 0}static fromCIMInsidePolygon(e){const t=e.markerPlacement,r={...e};r.markerPlacement=null,r.anchorPoint=null;const o=Math.abs(t.stepX),a=Math.abs(t.stepY),s=(t.randomness??100)/100;let l,c,m,f;if("Random"===t.gridType){const e=n(U),r=Math.max(Math.floor(e/o),1),y=Math.max(Math.floor(e/a),1);l=r*o/2,c=y*a/2,m=2*c;const u=new i(t.seed),h=s*o/1.5,p=s*a/1.5;f=[];for(let t=0;t<r;t++)for(let e=0;e<y;e++){const r=t*o-l+h*(.5-u.getFloat()),i=e*a-c+p*(.5-u.getFloat());f.push({x:r,y:i}),0===t&&f.push({x:r+2*l,y:i}),0===e&&f.push({x:r,y:i+2*c})}}else!0===t.shiftOddRows?(l=o/2,c=a,m=2*a,f=[{x:-l,y:0},{x:l,y:0},{x:0,y:c},{x:0,y:-c}]):(l=o/2,c=a/2,m=a,f=[{x:-o,y:0},{x:0,y:-a},{x:-o,y:-a},{x:0,y:0},{x:o,y:0},{x:0,y:a},{x:o,y:a},{x:-o,y:a},{x:o,y:-a}]);return{type:"CIMVectorMarker",frame:{xmin:-l,xmax:l,ymin:-c,ymax:c},markerGraphics:f.map((e=>({type:"CIMMarkerGraphic",geometry:e,symbol:{type:"CIMPointSymbol",symbolLayers:[r]}}))),size:m}}static getSize(e){if(e)switch(e.type){case"CIMTextSymbol":return e.height;case"CIMPointSymbol":{let t=0;if(e.symbolLayers)for(const r of e.symbolLayers)if(r)switch(r.type){case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":case"CIMObjectMarker3D":case"CIMglTFMarker3D":{const e=r.size;null!=e&&e>t&&(t=e);break}}return t}case"CIMLineSymbol":case"CIMPolygonSymbol":{let t=0;if(e.symbolLayers)for(const r of e.symbolLayers)if(r)switch(r.type){case"CIMSolidStroke":case"CIMPictureStroke":case"CIMGradientStroke":{const e=r.width;null!=e&&e>t&&(t=e);break}case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":case"CIMObjectMarker3D":case"CIMglTFMarker3D":if(r.markerPlacement&&A(r.markerPlacement)){const e=r.size;null!=e&&e>t&&(t=e)}}return t}}}static getMarkerScaleRatio(e){if(e&&"CIMVectorMarker"===e.type)if(!1!==e.scaleSymbolsProportionally&&e.frame&&null!=e.size){const t=e.frame.ymax-e.frame.ymin;return e.size/t}return 1}}class le{static findApplicableOverrides(e,t,r){if(e&&t){if(e.primitiveName){let o=!1;for(const t of r)if(t.primitiveName===e.primitiveName){o=!0;break}if(!o)for(const a of t)a.primitiveName===e.primitiveName&&r.push(a)}switch(e.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":if(e.effects)for(const o of e.effects)le.findApplicableOverrides(o,t,r);if(e.symbolLayers)for(const o of e.symbolLayers)le.findApplicableOverrides(o,t,r);break;case"CIMTextSymbol":break;case"CIMSolidStroke":case"CIMPictureStroke":case"CIMGradientStroke":case"CIMSolidFill":case"CIMPictureFill":case"CIMHatchFill":case"CIMGradientFill":case"CIMVectorMarker":case"CIMCharacterMarker":case"CIMPictureMarker":if(e.effects)for(const o of e.effects)le.findApplicableOverrides(o,t,r);if(e.markerPlacement&&le.findApplicableOverrides(e.markerPlacement,t,r),"CIMVectorMarker"===e.type){if(e.markerGraphics)for(const o of e.markerGraphics)le.findApplicableOverrides(o,t,r),le.findApplicableOverrides(o.symbol,t,r)}else"CIMCharacterMarker"===e.type?le.findApplicableOverrides(e.symbol,t,r):"CIMHatchFill"===e.type?le.findApplicableOverrides(e.lineSymbol,t,r):"CIMPictureMarker"===e.type&&le.findApplicableOverrides(e.animatedSymbolProperties,t,r)}}}static findEffectOverrides(e,t,r){if(!t||!e)return;const o=e.length;for(let a=0;a<o;a++){const o=e[a],i=o?.primitiveName;if(i){let e=!1;for(const t of r)if(t.primitiveName===i){e=!0;break}if(!e)for(const o of t)o.primitiveName===i&&r.push(o)}}}static async resolveSymbolOverrides(e,t,r,a,i,s,n){if(!e||!e.symbol)return null;let{symbol:l,primitiveOverrides:c}=e;const m=!!c;if(!m&&!a)return l;l=o(l);let f=!0;if(t||(t={attributes:{}},f=!1),m){if(f||(c=c.filter((e=>!e.valueExpressionInfo?.expression.includes("$feature")))),n||(c=c.filter((e=>!e.valueExpressionInfo?.expression.includes("$view")))),c.length>0){const e=N(t.attributes);await le.evaluateOverrides(c,t,{spatialReference:r,fields:e,geometryType:i},s,n)}le.applyOverrides(l,c)}return a&&le.applyDictionaryTextOverrides(l,t,a),l}static async evaluateOverrides(e,t,r,o,a){if(!t)return;let i;for(const s of e){const e=s.valueExpressionInfo;if(e&&r&&r.geometryType){i||(i=[]),s.value=void 0;const n=f(e.expression,r.spatialReference,r.fields).then((e=>{s.value=X(e,t,{$view:a},r.geometryType,o)}));i.push(n)}}void 0!==i&&i.length>0&&await Promise.all(i)}static applyDictionaryTextOverrides(e,t,r,o="Normal"){if(e&&e.type)switch(e.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":case"CIMTextSymbol":{const a=e.symbolLayers;if(!a)return;for(const i of a)i&&"CIMVectorMarker"===i.type&&le.applyDictionaryTextOverrides(i,t,r,"CIMTextSymbol"===e.type?e.textCase:o)}break;case"CIMVectorMarker":{const o=e.markerGraphics;if(!o)return;for(const e of o)e&&le.applyDictionaryTextOverrides(e,t,r)}break;case"CIMMarkerGraphic":{const a=e.textString;if(a&&a.includes("[")){const i=R(a,r);e.textString=j(t,i,o)}}}}static applyOverrides(e,t,r,o){if(e.primitiveName)for(const a of t)if(a.primitiveName===e.primitiveName){const t=Ce(a.propertyName);if(o&&o.push({cim:e,nocapPropertyName:t,value:e[t]}),a.expression&&(a.value=le.toValue(a.propertyName,a.expression)),r){let t=!1;for(const o of r)o.primitiveName===e.primitiveName&&(t=!0);t||r.push(a)}null!=a.value&&(e[t]=a.value)}switch(e.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":if(e.effects)for(const a of e.effects)le.applyOverrides(a,t,r,o);if(e.symbolLayers)for(const a of e.symbolLayers)le.applyOverrides(a,t,r,o);break;case"CIMTextSymbol":break;case"CIMSolidStroke":case"CIMSolidFill":case"CIMVectorMarker":if(e.effects)for(const a of e.effects)le.applyOverrides(a,t,r,o);if("CIMVectorMarker"===e.type&&e.markerGraphics)for(const a of e.markerGraphics)le.applyOverrides(a,t,r,o),le.applyOverrides(a.symbol,t,r,o)}}static restoreOverrides(e){for(const t of e)t.cim[t.nocapPropertyName]=t.value}static buildOverrideKey(e){let t="";for(const r of e)void 0!==r.value&&(t+=`${r.primitiveName}${r.propertyName}${JSON.stringify(r.value)}`);return t}static toValue(t,r){if("DashTemplate"===t)return r.split(" ").map((e=>Number(e)));if("Color"===t){const t=new e(r).toRgba();return t[3]*=255,t}return r}}const ce=e=>{if(!e)return C.Butt;switch(e){case"butt":return C.Butt;case"square":return C.Square;case"round":return C.Round}},me=e=>{if(!e)return I.Miter;switch(e){case"miter":return I.Miter;case"round":return I.Round;case"bevel":return I.Bevel}},fe=e=>{if(null==e)return"Center";switch(e){case"left":return"Left";case"right":return"Right";case"center":return"Center"}},ye=e=>{if(null==e)return"Center";switch(e){case"baseline":return"Baseline";case"top":return"Top";case"middle":return"Center";case"bottom":return"Bottom"}},ue=e=>{if(!e)return[0,0,0,0];const{r:t,g:r,b:o,a}=e;return[t,r,o,255*a]},he=(e,t)=>{const r=pe(t),o=Me(e);return r&&o?`${r}-${o}`:`${r}${o}`},pe=e=>{if(!e)return"";switch(e.toLowerCase()){case"bold":case"bolder":return"bold"}return""},Me=e=>{if(!e)return"";switch(e.toLowerCase()){case"italic":case"oblique":return"italic"}return""},de=(e,t)=>{const r="butt"===t;switch(e){case"dash":case"esriSLSDash":return r?[4,3]:[3,4];case"dash-dot":case"esriSLSDashDot":return r?[4,3,1,3]:[3,4,0,4];case"dot":case"esriSLSDot":return r?[1,3]:[0,4];case"long-dash":case"esriSLSLongDash":return r?[8,3]:[7,4];case"long-dash-dot":case"esriSLSLongDashDot":return r?[8,3,1,3]:[7,4,0,4];case"long-dash-dot-dot":case"esriSLSDashDotDot":return r?[8,3,1,3,1,3]:[7,4,0,4,0,4];case"short-dash":case"esriSLSShortDash":return r?[4,1]:[3,2];case"short-dash-dot":case"esriSLSShortDashDot":return r?[4,1,1,1]:[3,2,0,2];case"short-dash-dot-dot":case"esriSLSShortDashDotDot":return r?[4,1,1,1,1,1]:[3,2,0,2,0,2];case"short-dot":case"esriSLSShortDot":return r?[1,1]:[0,2];case"solid":case"esriSLSSolid":case"none":return ee.error("Unexpected: style does not require rasterization"),[0,0];default:return ee.error(`Tried to rasterize SLS, but found an unexpected style: ${e}!`),[0,0]}};function Se(e){return void 0!==e.symbolLayers}const be=e=>{const t=100,r=50;let o,a;const i=e;if("circle"===i||"esriSMSCircle"===i){const e=.25;let t=Math.acos(1-e/r),i=Math.ceil(W/t/4);0===i&&(i=1),t=J/i,i*=4;const s=[];s.push([r,0]);for(let o=1;o<i;o++)s.push([r*Math.cos(o*t),-r*Math.sin(o*t)]);s.push([r,0]),o={rings:[s]},a={xmin:-r,ymin:-r,xmax:r,ymax:r}}else if("cross"===i||"esriSMSCross"===i){const e=0;o={rings:[[[e,r],[e,e],[r,e],[r,-e],[e,-e],[e,-r],[-e,-r],[-e,-e],[-r,-e],[-r,e],[-e,e],[-e,r],[e,r]]]},a={xmin:-r,ymin:-r,xmax:r,ymax:r}}else if("diamond"===i||"esriSMSDiamond"===i)o={rings:[[[-r,0],[0,r],[r,0],[0,-r],[-r,0]]]},a={xmin:-r,ymin:-r,xmax:r,ymax:r};else if("square"===i||"esriSMSSquare"===i)o={rings:[[[-r,-r],[-r,r],[r,r],[r,-r],[-r,-r]]]},a={xmin:-r,ymin:-r,xmax:r,ymax:r};else if("x"===i||"esriSMSX"===i){const e=0;o={rings:[[[0,e],[r-e,r],[r,r-e],[e,0],[r,e-r],[r-e,-r],[0,-e],[e-r,-r],[-r,e-r],[-e,0],[-r,r-e],[e-r,r],[0,e]]]},a={xmin:-r,ymin:-r,xmax:r,ymax:r}}else if("triangle"===i||"esriSMSTriangle"===i){const e=t*.5773502691896257,r=-e,i=2/3*t,s=i-t;o={rings:[[[r,s],[0,i],[e,s],[r,s]]]},a={xmin:r,ymin:s,xmax:e,ymax:i}}else"arrow"===i&&(o={rings:[[[-50,50],[50,0],[-50,-50],[-33,-20],[-33,20],[-50,50]]]},a={xmin:-r,ymin:-r,xmax:r,ymax:r});return[a,o]},ge=e=>"vertical"===e||"horizontal"===e||"cross"===e||"esriSFSCross"===e||"esriSFSVertical"===e||"esriSFSHorizontal"===e,Ce=e=>e?e.charAt(0).toLowerCase()+e.substr(1):e;function Ie(e,t,r){if(!e.effects||null!=t.geometryEngine)return;if(t.geometryEnginePromise)return void r.push(t.geometryEnginePromise);V(e.effects)&&(t.geometryEnginePromise=B(),r.push(t.geometryEnginePromise),t.geometryEnginePromise.then((e=>t.geometryEngine=e)))}export{ne as CIMSymbolHelper,se as CIMSymbolInflatedSizeHelper,le as OverrideHelper,ie as getEffectsInflateSize,de as slsDashToTemplateArray,te as symbolToCIM};
|
|
5
|
+
import e from"../../Color.js";import"../../symbols.js";import{bidiText as t}from"../../core/BidiText.js";import{getFontFamily as r}from"../../core/fontUtils.js";import{clone as a}from"../../core/lang.js";import o from"../../core/Logger.js";import i from"../../core/RandomLCG.js";import{pt2px as s,px2pt as n}from"../../core/screenUtils.js";import{create as l,expandPointInPlace as c}from"../../geometry/support/aaBoundingRect.js";import{getBoundsXY as m}from"../../geometry/support/boundsUtils.js";import{createRendererExpression as f}from"../../support/arcadeOnDemand.js";import{Placement as y}from"./CIMPlacements.js";import{DEFAULT_TEXT_HEIGHT as u,horizontalAlignment2HAlign as h,verticalAlignment2VAlign as p,EnvDrawHelper as M,Transformation as d,CanvasDrawHelper as S,DEFAULT_HATCH_FILL_SEPARATION as b,lineGapType2LineHeight as g}from"./CIMSymbolDrawHelper.js";import{LineCapStyle as C,LineJoinStyle as I,BlockProgression as k,FontEffects as x,FontEncoding as w,FontType as P,GlyphHinting as L,TextReadingDirection as v,VerticalGlyphOrientation as F,BillBoardMode as D,TextureFilter as T,ExtremityPlacement as G}from"./enums.js";import{getValue as z,fromCIMFontStyle as E,fromCIMFontDecoration as O,isCIMMarkerStrokePlacement as A,attributesToFields as N,analyzeTextParts as R,assignTextValuesFromFeature as j,isGeometryEngineRequired as V,importGeometryEngine as B}from"./utils.js";import X from"../../views/2d/arcade/callExpressionWithFeature.js";import{C_INFINITY as _}from"../../views/2d/engine/vectorTiles/GeometryUtils.js";import{GLYPH_SIZE as H,MAGIC_LABEL_LINE_HEIGHT as Y,RANDOM_INSIDE_POLYGON_TEXTURE_SIZE as U}from"../../views/2d/engine/webgl/definitions.js";import{shapeGlyphs as $}from"../../views/2d/engine/webgl/mesh/templates/shapingUtils.js";import q from"../Font.js";const W=Math.PI,J=W/2,K=Math.PI/180,Q=96/72,Z=4,ee=o.getLogger("esri.symbols.cim.CIMSymbolHelper");function te(e){if(!e||!e.type)return null;let t;switch(e.type){case"cim":return e.data;case"web-style":return e;case"simple-marker":{const r=ne.fromSimpleMarker(e);if(!r)return null;t=r;break}case"picture-marker":t=ne.fromPictureMarker(e);break;case"simple-line":t=ne.fromSimpleLineSymbol(e);break;case"simple-fill":t=ne.fromSimpleFillSymbol(e);break;case"picture-fill":t=ne.fromPictureFillSymbol(e);break;case"text":t=ne.fromTextSymbol(e)}return{type:"CIMSymbolReference",symbol:t}}function re(e,t,r){switch(t.type){case"CIMSymbolReference":return re(e,t.symbol,r);case"CIMPointSymbol":null==r&&(r={x:0,y:0}),e.drawSymbol(t,r);break;case"CIMLineSymbol":null==r&&(r={paths:[[[0,0],[10,0]]]}),e.drawSymbol(t,r);break;case"CIMPolygonSymbol":null==r&&(r={rings:[[[0,0],[0,10],[10,10],[10,0],[0,0]]]}),e.drawSymbol(t,r);break;case"CIMTextSymbol":{const r={x:0,y:0};e.drawSymbol(t,r);break}case"CIMVectorMarker":{const r=new y;e.drawMarker(t,r);break}}return e.envelope()}function ae(e){if(!e)return 0;switch(e.type){case"CIMMarkerPlacementAlongLineSameSize":case"CIMMarkerPlacementAlongLineRandomSize":case"CIMMarkerPlacementAtExtremities":case"CIMMarkerPlacementAtMeasuredUnits":case"CIMMarkerPlacementAtRatioPositions":case"CIMMarkerPlacementOnLine":case"CIMMarkerPlacementOnVertices":return Math.abs(e.offset);default:return 0}}function oe(e){if(!e)return 0;switch(e.type){case"CIMGeometricEffectArrow":return Math.abs(.5*e.width);case"CIMGeometricEffectBuffer":return Math.abs(e.size);case"CIMGeometricEffectExtension":case"CIMGeometricEffectRadial":return Math.abs(e.length);case"CIMGeometricEffectJog":return Math.abs(.5*e.length);case"CIMGeometricEffectMove":return Math.max(Math.abs(z(e.offsetX)),Math.abs(z(e.offsetY)));case"CIMGeometricEffectOffset":case"CIMGeometricEffectOffsetTangent":return Math.abs(e.offset);case"CIMGeometricEffectRegularPolygon":return Math.abs(e.radius);case"CIMGeometricEffectRotate":case"CIMGeometricEffectScale":default:return 0;case"CIMGeometricEffectTaperedPolygon":return.5*Math.max(Math.abs(e.fromWidth),Math.abs(e.toWidth));case"CIMGeometricEffectWave":return Math.abs(e.amplitude);case"CIMGeometricEffectDonut":return Math.abs(e.width)}}function ie(e){if(!e)return 0;let t=0;for(const r of e)t+=oe(r);return t}class se{getSymbolInflateSize(e,t,r,a,o){return e||(e=[0,0,0,0]),t?this._getInflateSize(e,t,r,a,o):e}static safeSize(e){const t=Math.max(Math.abs(e[0]),Math.abs(e[2])),r=Math.max(Math.abs(e[1]),Math.abs(e[3]));return Math.sqrt(t*t+r*r)}_vectorMarkerBounds(e,t,r,a){let o=!0;const i=l();if(t&&t.markerGraphics)for(const s of t.markerGraphics){const t=[0,0,0,0];s.geometry&&(m(i,s.geometry),t[0]=0,t[1]=0,t[2]=0,t[3]=0,this.getSymbolInflateSize(t,s.symbol,r,0,a),i[0]+=t[0],i[1]+=t[1],i[2]+=t[2],i[3]+=t[3],o?(e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],o=!1):(e[0]=Math.min(e[0],i[0]),e[1]=Math.min(e[1],i[1]),e[2]=Math.max(e[2],i[2]),e[3]=Math.max(e[3],i[3])))}return e}_getInflateSize(e,t,r,a,o){if(Se(t)){const i=this._getLayersInflateSize(e,t.symbolLayers,r,a,o),s=ie(t.effects);return s>0&&(i[0]-=s,i[1]-=s,i[2]+=s,i[3]+=s),i}return this._getTextInflatedSize(e,t,o)}_getLayersInflateSize(e,t,r,a,o){let i=!0;if(!t)return e;for(const s of t){if(!s)continue;let t=[0,0,0,0];switch(s.type){case"CIMSolidFill":case"CIMPictureFill":case"CIMHatchFill":case"CIMGradientFill":break;case"CIMSolidStroke":case"CIMPictureStroke":case"CIMGradientStroke":{const e=s;let r=e.width;null!=r&&(e.capStyle===C.Square||e.joinStyle===I.Miter?r/=1.4142135623730951:r/=2,t[0]=-r,t[1]=-r,t[2]=r,t[3]=r);break}case"CIMCharacterMarker":case"CIMVectorMarker":case"CIMPictureMarker":{const e=s;if("CIMVectorMarker"===s.type){const e=s;if(t=this._vectorMarkerBounds(t,e,r,o),e.frame){const r=(e.frame.xmin+e.frame.xmax)/2,a=(e.frame.ymin+e.frame.ymax)/2;if(t[0]-=r,t[1]-=a,t[2]-=r,t[3]-=a,null!=e.size){const r=e.size/(e.frame.ymax-e.frame.ymin);t[0]*=r,t[1]*=r,t[2]*=r,t[3]*=r}}}else if("CIMPictureMarker"===s.type){const a=s,o=r.getResource(a.url);let i=1;if(null!=o&&o.height&&(i=o.width/o.height),null!=e.size){const r=e.size/2,o=e.size*i*a.scaleX/2;t=[-o,-r,o,r]}}else if(null!=e.size){const r=e.size/2;t=[-r,-r,r,r]}if(e.anchorPoint){let r,a;"Absolute"===e.anchorPointUnits?(r=e.anchorPoint.x,a=e.anchorPoint.y):(r=e.anchorPoint.x*(t[2]-t[0]),a=e.anchorPoint.y*(t[3]-t[1])),t[0]-=r,t[1]-=a,t[2]-=r,t[3]-=a}let i=z(e.rotation);if(e.rotateClockwise&&(i=-i),a&&(i-=a),i){const e=K*i,r=Math.cos(e),a=Math.sin(e),o=l([_,_,-_,-_]);c(o,[t[0]*r-t[1]*a,t[0]*a+t[1]*r]),c(o,[t[0]*r-t[3]*a,t[0]*a+t[3]*r]),c(o,[t[2]*r-t[1]*a,t[2]*a+t[1]*r]),c(o,[t[2]*r-t[3]*a,t[2]*a+t[3]*r]),t=o}let n=z(e.offsetX),m=z(e.offsetY);if(a){const e=K*a,t=Math.cos(e),r=Math.sin(e),o=n*r+m*t;n=n*t-m*r,m=o}t[0]+=n,t[1]+=m,t[2]+=n,t[3]+=m;const f=ae(e.markerPlacement);f>0&&(t[0]-=f,t[1]-=f,t[2]+=f,t[3]+=f);break}}const n=ie(s.effects);n>0&&(t[0]-=n,t[1]-=n,t[2]+=n,t[3]+=n),i?(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],i=!1):(e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[2]),e[3]=Math.max(e[3],t[3]))}return e}_getTextInflatedSize(e,r,a){const o=r.height??u;if(e[0]=-o/2,e[1]=-o/2,e[2]=o/2,e[3]=o/2,!a)return e;const i=a.get(r);if(!i)return e;const{text:s,mosaicItem:n}=i;if(!n?.glyphMosaicItems?.length)return e;const{lineGapType:l,lineGap:c}=r,m=l?g(l,c??0,o):0,f=t(s)[1],y=n.glyphMosaicItems,M="CIMBackgroundCallout"===r.callout?.type,d=$(y,f,{scale:o/H,angle:z(r.angle),xOffset:z(r.offsetX),yOffset:z(r.offsetY),hAlign:h(r.horizontalAlignment),vAlign:p(r.verticalAlignment),maxLineWidth:512,lineHeight:Y*Math.max(.25,Math.min(m||1,4)),decoration:r.font.decoration||"none",isCIM:!0,hasBackground:M}).boundsT;return e[0]=d.x-d.halfWidth,e[1]=-d.y-d.halfHeight,e[2]=d.x+d.halfWidth,e[3]=-d.y+d.halfHeight,e}}class ne{static getEnvelope(e,t,r){if(!e)return null;const a=new M(r);if(Array.isArray(e)){let r;for(const o of e)r?r.union(re(a,o,t)):r=re(a,o,t);return r}return re(a,e,t)}static getTextureAnchor(e,t){const r=this.getEnvelope(e,null,t);if(!r)return[0,0,0];const a=(r.x+.5*r.width)*Q,o=(r.y+.5*r.height)*Q,i=r.width*Q+2,s=r.height*Q+2;return[-a/i,-o/s,s]}static rasterize(e,t,r,a,o=!0){const i=r||this.getEnvelope(t,null,a);if(!i)return[null,0,0,0,0];const s=(i.x+.5*i.width)*Q,n=(i.y+.5*i.height)*Q;e.width=i.width*Q,e.height=i.height*Q,r||(e.width+=2,e.height+=2);const l=e.getContext("2d"),c=d.createScale(Q,-Q);c.translate(.5*e.width-s,.5*e.height+n);const m=new S(l,a,c);switch(t.type){case"CIMPointSymbol":{const e={type:"point",x:0,y:0};m.drawSymbol(t,e);break}case"CIMVectorMarker":{const e=new y;m.drawMarker(t,e);break}}const f=l.getImageData(0,0,e.width,e.height),u=new Uint8Array(f.data);if(o){let e;for(let t=0;t<u.length;t+=4)e=u[t+3]/255,u[t]=u[t]*e,u[t+1]=u[t+1]*e,u[t+2]=u[t+2]*e}return[u,e.width,e.height,-s/e.width,-n/e.height]}static fromTextSymbol(e){const{angle:r,color:a,font:o,haloColor:i,haloSize:s,horizontalAlignment:n,kerning:l,text:c,verticalAlignment:m,xoffset:f,yoffset:y,backgroundColor:u,borderLineColor:h,borderLineSize:p}=e;let M,d,S,b,g,C;o&&(M=o.family,d=o.style,S=o.weight,b=o.size,g=o.decoration);let I=!1;if(c){I=t(c)[1]}return(u||p)&&(C={type:"CIMBackgroundCallout",margin:null,backgroundSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",color:ue(u)},{type:"CIMSolidStroke",color:ue(h),width:p}]},accentBarSymbol:null,gap:null,leaderLineSymbol:null,lineStyle:null}),{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:!0,anchorPointUnits:"Relative",dominantSizeAxis3D:"Y",size:10,billboardMode3D:"FaceNearPlane",frame:{xmin:-5,ymin:-5,xmax:5,ymax:5},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",angle:r,blockProgression:k.BTT,depth3D:1,extrapolateBaselines:!0,fontEffects:x.Normal,fontEncoding:w.Unicode,fontFamilyName:M||"Arial",fontStyleName:he(d,S),fontType:P.Unspecified,haloSize:s,height:b,hinting:L.Default,horizontalAlignment:fe(n??"center"),kerning:l,letterWidth:100,ligatures:!0,lineGapType:"Multiple",offsetX:z(f),offsetY:z(y),strikethrough:"line-through"===g,underline:"underline"===g,symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:ue(a)}]},haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:ue(i)}]},shadowColor:[0,0,0,255],shadowOffsetX:1,shadowOffsetY:1,textCase:"Normal",textDirection:I?v.RTL:v.LTR,verticalAlignment:ye(m??"baseline"),verticalGlyphOrientation:F.Right,wordSpacing:100,billboardMode3D:D.FaceNearPlane,callout:C},textString:c}],scaleSymbolsProportionally:!0,respectFrame:!0}],scaleX:1,angleAlignment:"Display"}}static fromPictureFillSymbol(e){const{height:t,outline:r,width:a,xoffset:o,xscale:i,yoffset:s,yscale:n}=e,l=[],c={type:"CIMPolygonSymbol",symbolLayers:l};if(r){const{cap:e,join:t,miterLimit:a,width:o}=r;l.push({type:"CIMSolidStroke",color:ue(r.color),capStyle:ce(e),joinStyle:me(t),miterLimit:a,width:o})}let m=e.url;"esriPFS"===e.type&&e.imageData&&(m=e.imageData);const f="angle"in e?e.angle??0:0,y=(a??0)*(i||1),u=(t??0)*(n||1);return l.push({type:"CIMPictureFill",invertBackfaceTexture:!1,scaleX:1,textureFilter:T.Picture,tintColor:null,url:m,height:u,width:y,offsetX:z(o),offsetY:z(s),rotation:z(-f),colorSubstitutions:null}),c}static fromSimpleFillSymbol(e){const{color:t,style:r,outline:o}=e,i=[],s={type:"CIMPolygonSymbol",symbolLayers:i};let l=null;if(o){const{cap:e,join:t,style:r}=o;"solid"!==r&&"none"!==r&&"esriSLSSolid"!==r&&"esriSLSNull"!==r&&(l=[{type:"CIMGeometricEffectDashes",dashTemplate:de(r,e),lineDashEnding:"NoConstraint",scaleDash:!0,offsetAlongLine:null}]),i.push({type:"CIMSolidStroke",color:"esriSLSNull"!==r&&"none"!==r?ue(o.color):[0,0,0,0],capStyle:ce(e),joinStyle:me(t),miterLimit:o.miterLimit,width:o.width,effects:l})}if(r&&"solid"!==r&&"none"!==r&&"esriSFSSolid"!==r&&"esriSFSNull"!==r){const e={type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",color:ue(t),capStyle:C.Butt,joinStyle:I.Miter,width:.75}]};let o=0;const s=n(ge(r)?8:10);switch(r){case"vertical":case"esriSFSVertical":o=90;break;case"forward-diagonal":case"esriSFSForwardDiagonal":case"diagonal-cross":case"esriSFSDiagonalCross":o=-45;break;case"backward-diagonal":case"esriSFSBackwardDiagonal":o=45;break;case"cross":case"esriSFSCross":o=0}i.push({type:"CIMHatchFill",lineSymbol:e,offsetX:0,offsetY:0,rotation:o,separation:s}),"cross"===r||"esriSFSCross"===r?i.push({type:"CIMHatchFill",lineSymbol:a(e),offsetX:0,offsetY:0,rotation:90,separation:s}):"diagonal-cross"!==r&&"esriSFSDiagonalCross"!==r||i.push({type:"CIMHatchFill",lineSymbol:a(e),offsetX:0,offsetY:0,rotation:45,separation:s})}else!r||"solid"!==r&&"esriSFSSolid"!==r||i.push({type:"CIMSolidFill",enable:!0,color:ue(t)});return s}static fromSimpleLineSymbol(e){const{cap:t,color:r,join:a,marker:o,miterLimit:i,style:s,width:n}=e;let l=null;"solid"!==s&&"none"!==s&&"esriSLSSolid"!==s&&"esriSLSNull"!==s&&(l=[{type:"CIMGeometricEffectDashes",dashTemplate:de(s,t),lineDashEnding:"NoConstraint",scaleDash:!0,offsetAlongLine:null}]);const c=[];if(o){let e;switch(o.placement){case"begin-end":e=G.Both;break;case"begin":e=G.JustBegin;break;case"end":e=G.JustEnd;break;default:e=G.None}const t=ne.fromSimpleMarker(o,n,r).symbolLayers[0];t.markerPlacement={type:"CIMMarkerPlacementAtExtremities",angleToLine:!0,offset:0,extremityPlacement:e,offsetAlongLine:0},c.push(t)}return c.push({type:"CIMSolidStroke",color:"none"!==s&&"esriSLSNull"!==s?ue(r):[0,0,0,0],capStyle:ce(t),joinStyle:me(a),miterLimit:i,width:n,effects:l}),{type:"CIMLineSymbol",symbolLayers:c}}static fromPictureMarker(e){const{angle:t,height:r,width:a,xoffset:o,yoffset:i}=e;let s=e.url;return"esriPMS"===e.type&&e.imageData&&(s=e.imageData),{type:"CIMPointSymbol",symbolLayers:[{type:"CIMPictureMarker",invertBackfaceTexture:!1,scaleX:1,textureFilter:T.Picture,tintColor:null,url:s,size:r,width:a,offsetX:z(o),offsetY:z(i),rotation:z(-t)}]}}static fromSimpleMarker(e,t,r){const{style:a}=e,o=e.color??r;if("path"===a){const t=[];if("outline"in e&&e.outline){const r=e.outline;t.push({type:"CIMSolidStroke",enable:!0,width:s(Math.round(n(r.width))),color:ue(r.color)})}t.push({type:"CIMSolidFill",enable:!0,color:ue(o),path:e.path});const[r,a]=be("square");return{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:!0,rotation:z(-e.angle),size:z(e.size||6),offsetX:z(e.xoffset),offsetY:z(e.yoffset),frame:r,markerGraphics:[{type:"CIMMarkerGraphic",geometry:a,symbol:{type:"CIMPolygonSymbol",symbolLayers:t}}]}]}}const[i,l]=be(a);let c;if(l&&i){const r=[];if("outline"in e&&e.outline){const t=e.outline;r.push({type:"CIMSolidStroke",enable:!0,width:null!=t.width&&t.width>.667?s(Math.round(n(t.width))):t.width,color:ue(t.color)})}else!t||"line-marker"!==e.type||"cross"!==e.style&&"x"!==e.style||r.push({type:"CIMSolidStroke",enable:!0,width:t,color:ue(o)});r.push({type:"CIMSolidFill",enable:!0,color:ue(o)});const a={type:"CIMPolygonSymbol",symbolLayers:r};c={type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",enable:!0,rotation:z(-e.angle),size:z(e.size||6*t),offsetX:z(e.xoffset),offsetY:z(e.yoffset),frame:i,markerGraphics:[{type:"CIMMarkerGraphic",geometry:l,symbol:a}]}]}}return c}static fromCIMHatchFill(e,t){const r=t*(e.separation??b),o=r/2,i=a(e.lineSymbol);i.symbolLayers?.forEach((e=>{switch(e.type){case"CIMSolidStroke":null!=e.width&&(e.width*=t),e.effects?.forEach((e=>{"CIMGeometricEffectDashes"===e.type&&(e.dashTemplate=e.dashTemplate.map((e=>e*t)))}));break;case"CIMVectorMarker":{null!=e.size&&(e.size*=t);const r=e.markerPlacement;null!=r&&"placementTemplate"in r&&(r.placementTemplate=r.placementTemplate.map((e=>e*t)));break}}}));let s=this._getLineSymbolPeriod(i)||Z;for(;s<Z;)s*=2;const n=s/2;return{type:"CIMVectorMarker",frame:{xmin:-n,xmax:n,ymin:-o,ymax:o},markerGraphics:[{type:"CIMMarkerGraphic",geometry:{paths:[[[-n,0],[n,0]]]},symbol:i}],size:r}}static fetchResources(e,t,a){if(e&&t)switch(e.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":{const r=e.symbolLayers;if(!r)return;for(const e of r)switch(Ie(e,t,a),e.type){case"CIMPictureFill":case"CIMHatchFill":case"CIMGradientFill":case"CIMPictureStroke":case"CIMGradientStroke":case"CIMCharacterMarker":case"CIMPictureMarker":"url"in e&&e.url&&a.push(t.fetchResource(e.url,null));break;case"CIMVectorMarker":{const r=e.markerGraphics;if(!r)continue;for(const e of r)if(e){const r=e.symbol;r&&ne.fetchResources(r,t,a)}}}break}case"CIMTextSymbol":{const o=e,i=r(o.fontFamilyName),{style:s,weight:n}=E(o.fontStyleName),l=O(o);a.push(t.loadFont(new q({family:i,style:s,weight:n,decoration:l})).catch((()=>{ee.error("unsupported font in preview")})));break}}}static _getLineSymbolPeriod(e){if(e){const t=this._getEffectsRepeat(e.effects);if(t)return t;if(e.symbolLayers)for(const r of e.symbolLayers)if(r){const e=this._getEffectsRepeat(r.effects);if(e)return e;switch(r.type){case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":case"CIMObjectMarker3D":case"CIMglTFMarker3D":{const e=this._getPlacementRepeat(r.markerPlacement);if(e)return e}}}}return 0}static _getEffectsRepeat(e){if(e)for(const t of e)if(t)switch(t.type){case"CIMGeometricEffectDashes":{const e=t.dashTemplate;if(e&&e.length){let t=0;for(const r of e)t+=r;return 1&e.length&&(t*=2),t}break}case"CIMGeometricEffectWave":return t.period;default:ee.error(`unsupported geometric effect type ${t.type}`)}return 0}static _getPlacementRepeat(e){if(e)switch(e.type){case"CIMMarkerPlacementAlongLineSameSize":case"CIMMarkerPlacementAlongLineRandomSize":case"CIMMarkerPlacementAlongLineVariableSize":{const t=e.placementTemplate;if(t&&t.length){let e=0;for(const r of t)e+=+r;return 1&t.length&&(e*=2),e}break}}return 0}static fromCIMInsidePolygon(e){const t=e.markerPlacement,r={...e};r.markerPlacement=null,r.anchorPoint=null;const a=Math.abs(t.stepX),o=Math.abs(t.stepY),s=(t.randomness??100)/100;let l,c,m,f;if("Random"===t.gridType){const e=n(U),r=Math.max(Math.floor(e/a),1),y=Math.max(Math.floor(e/o),1);l=r*a/2,c=y*o/2,m=2*c;const u=new i(t.seed),h=s*a/1.5,p=s*o/1.5;f=[];for(let t=0;t<r;t++)for(let e=0;e<y;e++){const r=t*a-l+h*(.5-u.getFloat()),i=e*o-c+p*(.5-u.getFloat());f.push({x:r,y:i}),0===t&&f.push({x:r+2*l,y:i}),0===e&&f.push({x:r,y:i+2*c})}}else!0===t.shiftOddRows?(l=a/2,c=o,m=2*o,f=[{x:-l,y:0},{x:l,y:0},{x:0,y:c},{x:0,y:-c}]):(l=a/2,c=o/2,m=o,f=[{x:-a,y:0},{x:0,y:-o},{x:-a,y:-o},{x:0,y:0},{x:a,y:0},{x:0,y:o},{x:a,y:o},{x:-a,y:o},{x:a,y:-o}]);return{type:"CIMVectorMarker",frame:{xmin:-l,xmax:l,ymin:-c,ymax:c},markerGraphics:f.map((e=>({type:"CIMMarkerGraphic",geometry:e,symbol:{type:"CIMPointSymbol",symbolLayers:[r]}}))),size:m}}static getSize(e){if(e)switch(e.type){case"CIMTextSymbol":return e.height;case"CIMPointSymbol":{let t=0;if(e.symbolLayers)for(const r of e.symbolLayers)if(r)switch(r.type){case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":case"CIMObjectMarker3D":case"CIMglTFMarker3D":{const e=r.size;null!=e&&e>t&&(t=e);break}}return t}case"CIMLineSymbol":case"CIMPolygonSymbol":{let t=0;if(e.symbolLayers)for(const r of e.symbolLayers)if(r)switch(r.type){case"CIMSolidStroke":case"CIMPictureStroke":case"CIMGradientStroke":{const e=r.width;null!=e&&e>t&&(t=e);break}case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":case"CIMObjectMarker3D":case"CIMglTFMarker3D":if(r.markerPlacement&&A(r.markerPlacement)){const e=r.size;null!=e&&e>t&&(t=e)}}return t}}}static getMarkerScaleRatio(e){if(e&&"CIMVectorMarker"===e.type)if(!1!==e.scaleSymbolsProportionally&&e.frame&&null!=e.size){const t=e.frame.ymax-e.frame.ymin;return e.size/t}return 1}}class le{static findApplicableOverrides(e,t,r){if(e&&t){if(e.primitiveName){let a=!1;for(const t of r)if(t.primitiveName===e.primitiveName){a=!0;break}if(!a)for(const o of t)o.primitiveName===e.primitiveName&&r.push(o)}switch(e.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":if(e.effects)for(const a of e.effects)le.findApplicableOverrides(a,t,r);if(e.symbolLayers)for(const a of e.symbolLayers)le.findApplicableOverrides(a,t,r);break;case"CIMTextSymbol":break;case"CIMSolidStroke":case"CIMPictureStroke":case"CIMGradientStroke":case"CIMSolidFill":case"CIMPictureFill":case"CIMHatchFill":case"CIMGradientFill":case"CIMVectorMarker":case"CIMCharacterMarker":case"CIMPictureMarker":if(e.effects)for(const a of e.effects)le.findApplicableOverrides(a,t,r);if(e.markerPlacement&&le.findApplicableOverrides(e.markerPlacement,t,r),"CIMVectorMarker"===e.type){if(e.markerGraphics)for(const a of e.markerGraphics)le.findApplicableOverrides(a,t,r),le.findApplicableOverrides(a.symbol,t,r)}else"CIMCharacterMarker"===e.type?le.findApplicableOverrides(e.symbol,t,r):"CIMHatchFill"===e.type?le.findApplicableOverrides(e.lineSymbol,t,r):"CIMPictureMarker"===e.type&&le.findApplicableOverrides(e.animatedSymbolProperties,t,r)}}}static findEffectOverrides(e,t,r){if(!t||!e)return;const a=e.length;for(let o=0;o<a;o++){const a=e[o],i=a?.primitiveName;if(i){let e=!1;for(const t of r)if(t.primitiveName===i){e=!0;break}if(!e)for(const a of t)a.primitiveName===i&&r.push(a)}}}static async resolveSymbolOverrides(e,t,r,o,i,s,n){if(!e||!e.symbol)return null;let{symbol:l,primitiveOverrides:c}=e;const m=!!c;if(!m&&!o)return l;l=a(l);let f=!0;if(t||(t={attributes:{}},f=!1),m){if(f||(c=c.filter((e=>!e.valueExpressionInfo?.expression.includes("$feature")))),n||(c=c.filter((e=>!e.valueExpressionInfo?.expression.includes("$view")))),c.length>0){const e=N(t.attributes);await le.evaluateOverrides(c,t,{spatialReference:r,fields:e,geometryType:i},s,n)}le.applyOverrides(l,c)}return o&&le.applyDictionaryTextOverrides(l,t,o),l}static async evaluateOverrides(e,t,r,a,o){if(!t)return;let i;for(const s of e){const e=s.valueExpressionInfo;if(e&&r&&r.geometryType){i||(i=[]),s.value=void 0;const n=f(e.expression,r.spatialReference,r.fields).then((e=>{s.value=X(e,t,{$view:o},r.geometryType,a)}));i.push(n)}}void 0!==i&&i.length>0&&await Promise.all(i)}static applyDictionaryTextOverrides(e,t,r,a="Normal"){if(e&&e.type)switch(e.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":case"CIMTextSymbol":{const o=e.symbolLayers;if(!o)return;for(const i of o)i&&"CIMVectorMarker"===i.type&&le.applyDictionaryTextOverrides(i,t,r,"CIMTextSymbol"===e.type?e.textCase:a)}break;case"CIMVectorMarker":{const a=e.markerGraphics;if(!a)return;for(const e of a)e&&le.applyDictionaryTextOverrides(e,t,r)}break;case"CIMMarkerGraphic":{const o=e.textString;if(o&&o.includes("[")){const i=R(o,r);e.textString=j(t,i,a)}}}}static applyOverrides(e,t,r,a){if(e.primitiveName)for(const o of t)if(o.primitiveName===e.primitiveName){const t=Ce(o.propertyName);if(a&&a.push({cim:e,nocapPropertyName:t,value:e[t]}),o.expression&&(o.value=le.toValue(o.propertyName,o.expression)),r){let t=!1;for(const a of r)a.primitiveName===e.primitiveName&&(t=!0);t||r.push(o)}null!=o.value&&(e[t]=o.value)}switch(e.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":if(e.effects)for(const o of e.effects)le.applyOverrides(o,t,r,a);if(e.symbolLayers)for(const o of e.symbolLayers)le.applyOverrides(o,t,r,a);break;case"CIMTextSymbol":break;case"CIMSolidStroke":case"CIMSolidFill":case"CIMVectorMarker":if(e.effects)for(const o of e.effects)le.applyOverrides(o,t,r,a);if("CIMVectorMarker"===e.type&&e.markerGraphics)for(const o of e.markerGraphics)le.applyOverrides(o,t,r,a),le.applyOverrides(o.symbol,t,r,a)}}static restoreOverrides(e){for(const t of e)t.cim[t.nocapPropertyName]=t.value}static buildOverrideKey(e){let t="";for(const r of e)void 0!==r.value&&(t+=`${r.primitiveName}${r.propertyName}${JSON.stringify(r.value)}`);return t}static toValue(t,r){if("DashTemplate"===t)return r.split(" ").map((e=>Number(e)));if("Color"===t){const t=new e(r).toRgba();return t[3]*=255,t}return r}}const ce=e=>{if(!e)return C.Butt;switch(e){case"butt":return C.Butt;case"square":return C.Square;case"round":return C.Round}},me=e=>{if(!e)return I.Miter;switch(e){case"miter":return I.Miter;case"round":return I.Round;case"bevel":return I.Bevel}},fe=e=>{if(null==e)return"Center";switch(e){case"left":return"Left";case"right":return"Right";case"center":return"Center"}},ye=e=>{if(null==e)return"Center";switch(e){case"baseline":return"Baseline";case"top":return"Top";case"middle":return"Center";case"bottom":return"Bottom"}},ue=e=>{if(!e)return[0,0,0,0];const{r:t,g:r,b:a,a:o}=e;return[t,r,a,255*o]},he=(e,t)=>{const r=pe(t),a=Me(e);return r&&a?`${r}-${a}`:`${r}${a}`},pe=e=>{if(!e)return"";switch(e.toLowerCase()){case"bold":case"bolder":return"bold"}return""},Me=e=>{if(!e)return"";switch(e.toLowerCase()){case"italic":case"oblique":return"italic"}return""},de=(e,t)=>{const r="butt"===t;switch(e){case"dash":case"esriSLSDash":return r?[4,3]:[3,4];case"dash-dot":case"esriSLSDashDot":return r?[4,3,1,3]:[3,4,0,4];case"dot":case"esriSLSDot":return r?[1,3]:[0,4];case"long-dash":case"esriSLSLongDash":return r?[8,3]:[7,4];case"long-dash-dot":case"esriSLSLongDashDot":return r?[8,3,1,3]:[7,4,0,4];case"long-dash-dot-dot":case"esriSLSDashDotDot":return r?[8,3,1,3,1,3]:[7,4,0,4,0,4];case"short-dash":case"esriSLSShortDash":return r?[4,1]:[3,2];case"short-dash-dot":case"esriSLSShortDashDot":return r?[4,1,1,1]:[3,2,0,2];case"short-dash-dot-dot":case"esriSLSShortDashDotDot":return r?[4,1,1,1,1,1]:[3,2,0,2,0,2];case"short-dot":case"esriSLSShortDot":return r?[1,1]:[0,2];case"solid":case"esriSLSSolid":case"none":return ee.error("Unexpected: style does not require rasterization"),[0,0];default:return ee.error(`Tried to rasterize SLS, but found an unexpected style: ${e}!`),[0,0]}};function Se(e){return void 0!==e.symbolLayers}const be=e=>{const t=100,r=50;let a,o;const i=e;if("circle"===i||"esriSMSCircle"===i){const e=.25;let t=Math.acos(1-e/r),i=Math.ceil(W/t/4);0===i&&(i=1),t=J/i,i*=4;const s=[];s.push([r,0]);for(let a=1;a<i;a++)s.push([r*Math.cos(a*t),-r*Math.sin(a*t)]);s.push([r,0]),a={rings:[s]},o={xmin:-r,ymin:-r,xmax:r,ymax:r}}else if("cross"===i||"esriSMSCross"===i){const e=0;a={rings:[[[e,r],[e,e],[r,e],[r,-e],[e,-e],[e,-r],[-e,-r],[-e,-e],[-r,-e],[-r,e],[-e,e],[-e,r],[e,r]]]},o={xmin:-r,ymin:-r,xmax:r,ymax:r}}else if("diamond"===i||"esriSMSDiamond"===i)a={rings:[[[-r,0],[0,r],[r,0],[0,-r],[-r,0]]]},o={xmin:-r,ymin:-r,xmax:r,ymax:r};else if("square"===i||"esriSMSSquare"===i)a={rings:[[[-r,-r],[-r,r],[r,r],[r,-r],[-r,-r]]]},o={xmin:-r,ymin:-r,xmax:r,ymax:r};else if("x"===i||"esriSMSX"===i){const e=0;a={rings:[[[0,e],[r-e,r],[r,r-e],[e,0],[r,e-r],[r-e,-r],[0,-e],[e-r,-r],[-r,e-r],[-e,0],[-r,r-e],[e-r,r],[0,e]]]},o={xmin:-r,ymin:-r,xmax:r,ymax:r}}else if("triangle"===i||"esriSMSTriangle"===i){const e=t*.5773502691896257,r=-e,i=2/3*t,s=i-t;a={rings:[[[r,s],[0,i],[e,s],[r,s]]]},o={xmin:r,ymin:s,xmax:e,ymax:i}}else"arrow"===i&&(a={rings:[[[-50,50],[50,0],[-50,-50],[-33,-20],[-33,20],[-50,50]]]},o={xmin:-r,ymin:-r,xmax:r,ymax:r});return[o,a]},ge=e=>"vertical"===e||"horizontal"===e||"cross"===e||"esriSFSCross"===e||"esriSFSVertical"===e||"esriSFSHorizontal"===e,Ce=e=>e?e.charAt(0).toLowerCase()+e.substr(1):e;function Ie(e,t,r){if(!e.effects||null!=t.geometryEngine)return;if(t.geometryEnginePromise)return void r.push(t.geometryEnginePromise);V(e.effects)&&(t.geometryEnginePromise=B(),r.push(t.geometryEnginePromise),t.geometryEnginePromise.then((e=>t.geometryEngine=e)))}export{ne as CIMSymbolHelper,se as CIMSymbolInflatedSizeHelper,le as OverrideHelper,ie as getEffectsInflateSize,de as slsDashToTemplateArray,te as symbolToCIM};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../geometry.js";import{GeometryCursor as e}from"../../../geometry/GeometryCursor.js";import{collectMultipath as t}from"../../../geometry/geometryCursorCollectUtils.js";import{clipCursorToTileExtent as i}from"../CIMEffects.js";import{CurveHelper as s,PIXEL_TOLERANCE as r}from"../CurveHelper.js";import{GeometricEffectOffsetMethod as n}from"../enums.js";import o from"../../../geometry/SpatialReference.js";class m{static local(){return null===m.instance&&(m.instance=new m),m.instance}execute(e,t,i,s,r,n){return new l(e,t,i,s,r,n)}}m.instance=null;class l{constructor(e,t,i,n,o,m){this._inputGeometries=e,this._tileKey=n,this._geometryEngine=o,this._curveHelper=new s,this._size=(void 0!==t.size?t.size:1)*i,this._maxInflateSize=m
|
|
5
|
+
import"../../../geometry.js";import{GeometryCursor as e}from"../../../geometry/GeometryCursor.js";import{collectMultipath as t}from"../../../geometry/geometryCursorCollectUtils.js";import{clipCursorToTileExtent as i}from"../CIMEffects.js";import{CurveHelper as s,PIXEL_TOLERANCE as r}from"../CurveHelper.js";import{GeometricEffectOffsetMethod as n}from"../enums.js";import o from"../../../geometry/SpatialReference.js";class m{static local(){return null===m.instance&&(m.instance=new m),m.instance}execute(e,t,i,s,r,n){return new l(e,t,i,s,r,n)}}m.instance=null;class l{constructor(e,t,i,n,o,m){this._inputGeometries=e,this._tileKey=n,this._geometryEngine=o,this._curveHelper=new s,this._size=(void 0!==t.size?t.size:1)*i,this._maxInflateSize=m*i,this._offsetFlattenError=r*i}next(){let s;for(;s=this._inputGeometries.next();){if(0===this._size)return s;if("esriGeometryEnvelope"===s.geometryType)if(this._size>0){const i=e.createEmptyOptimizedCIM(s.geometryType),r=t(s)[0],o=this._curveHelper.offset(r,this._size,n.Rounded,4,this._offsetFlattenError);if(o)return i.pushPath(o),i}else if(this._size<0){const t=s.asJSON();if(Math.min(t.xmax-t.xmin,t.ymax-t.ymin)+2*this._size>0)return e.fromJSONCIM({xmin:t.xmin-this._size,xmax:t.xmax+this._size,ymin:t.ymin-this._size,ymax:t.ymax+this._size})}const r=this._geometryEngine;if(null==r)return null;const m=this._tileKey?i(s,this._maxInflateSize):s;if(!m)continue;const l=r.buffer(o.WebMercator,m.asJSON(),this._size,1);return l?e.fromJSONCIM(l):null}return null}}export{m as EffectBuffer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../geometry.js";import{GeometryCursor as t}from"../../../geometry/GeometryCursor.js";import{clipCursorToTileExtent as
|
|
5
|
+
import"../../../geometry.js";import{GeometryCursor as t}from"../../../geometry/GeometryCursor.js";import{clipCursorToTileExtent as e}from"../CIMEffects.js";import{GeometricEffectDonutMethod as i}from"../enums.js";import n from"../../../geometry/SpatialReference.js";class s{static local(){return null===s.instance&&(s.instance=new s),s.instance}execute(t,e,i,n,s,m){return new r(t,e,i,n,s,m)}}s.instance=null;class r{constructor(t,e,n,s,r,m){switch(this._inputGeometries=t,this._tileKey=s,this._geometryEngine=r,this._maxInflateSize=m*n,this._width=(void 0!==e.width?e.width:2)*n,e.method){case i.Mitered:case i.Bevelled:case i.Rounded:case i.TrueBuffer:case i.Square:}this._option=e.option}next(){let i;for(;i=this._inputGeometries.next();){if("esriGeometryEnvelope"===i.geometryType&&this._width>0){const e=i.asJSON();return Math.min(e.xmax-e.xmin,e.ymax-e.ymin)-2*this._width<0?i:t.fromJSONCIM({paths:[[[e.xmin+this._width,e.ymin+this._width],[e.xmax-this._width,e.ymin+this._width],[e.xmax-this._width,e.ymax-this._width],[e.xmin+this._width,e.ymax-this._width],[e.xmin+this._width,e.ymin+this._width]],[[e.xmin,e.ymin],[e.xmin,e.ymax],[e.xmax,e.ymax],[e.xmax,e.ymin],[e.xmin,e.ymin]]]})}if("esriGeometryPolygon"===i.geometryType){if(0===this._width)return i.clone();const t=this._geometryEngine;if(null==t)return null;const s=this._tileKey?e(i,this._maxInflateSize):i.clone();if(!s)continue;const r=t.buffer(n.WebMercator,s.asJSON(),-this._width,1);if(r)for(const e of r.rings)e&&s.pushPath(e.reverse());return s}}return null}}export{s as EffectDonut};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../geometry.js";import{GeometryCursor as t}from"../../../geometry/GeometryCursor.js";import{collectPath as e}from"../../../geometry/geometryCursorCollectUtils.js";import{isExtent as
|
|
5
|
+
import"../../../geometry.js";import{GeometryCursor as t}from"../../../geometry/GeometryCursor.js";import{collectPath as e}from"../../../geometry/geometryCursorCollectUtils.js";import{isExtent as o}from"../../../geometry/support/jsonUtils.js";import{clipCursorToTileExtent as s}from"../CIMEffects.js";import{CurveHelper as r,PIXEL_TOLERANCE as i}from"../CurveHelper.js";import{GeometricEffectOffsetMethod as n}from"../enums.js";import f from"../../../geometry/SpatialReference.js";class m{static local(){return null===m.instance&&(m.instance=new m),m.instance}execute(t,e,o,s,r,i){return new h(t,e,o,s,r,i)}}m.instance=null;class h{constructor(t,e,o,s,n,f){this._inputGeometries=t,this._tileKey=s,this._geometryEngine=n,this._curveHelper=new r,this._offset=(e.offset??1)*o,this._method=e.method,this._maxInflateSize=f*o,this._option=e.option,this._offsetFlattenError=i*o}next(){let r;for(;r=this._inputGeometries.next();){if(0===this._offset)return r.clone();if("esriGeometryEnvelope"===r.geometryType){if(this._method===n.Rounded&&this._offset>0){const o=e(r),s=this._curveHelper.offset(o,-this._offset,this._method,4,this._offsetFlattenError);if(s){const e=t.createEmptyOptimizedCIM(r.geometryType);return e.pushPath(s),e}return null}const s=r.asJSON();if(o(s)&&Math.min(s.xmax-s.xmin,s.ymax-s.ymin)+2*this._offset>0)return t.fromJSONCIM({xmin:s.xmin-this._offset,xmax:s.xmax+this._offset,ymin:s.ymin-this._offset,ymax:s.ymax+this._offset})}const i=this._geometryEngine;if(null==i)continue;const m=this._tileKey?s(r,this._maxInflateSize):r.clone();if(!m)continue;const h=i.offset(f.WebMercator,m.asJSON(),-this._offset,1,this._method,4,this._offsetFlattenError);return h?t.fromJSONCIM(h):null}return null}}export{m as EffectOffset};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"../../../../core/has.js";import{diff as e,hasDiff as s}from"../../../../core/accessorSupport/diffUtils.js";import{createRendererExpression as t}from"../../../../support/arcadeOnDemand.js";import i from"../../arcade/callExpressionWithCursor.js";
|
|
5
|
+
import has from"../../../../core/has.js";import{diff as e,hasDiff as s}from"../../../../core/accessorSupport/diffUtils.js";import{createRendererExpression as t}from"../../../../support/arcadeOnDemand.js";import i from"../../arcade/callExpressionWithCursor.js";class a{constructor(e,s){this._canCacheExpressionValue=!1,this._sourceInfo=e,this._storage=s,this._bitsets={computed:s.getBitset(s.createBitset())}}get storage(){return this._storage}invalidate(){this._bitsets.computed.clear()}async updateSchema(t,i){const a=e(this._schema,i);if(this._schema=i,!i||null==a||!s(a,"attributes"))return;has("esri-2d-update-debug")&&console.debug("Applying Update - Store:",a),this._bitsets.computed.clear(),t.targets[i.name]=!0;const r=i.attributes,o=[],c=[];for(const e in r){const s=r[e];switch(s.type){case"field":break;case"expression":o.push(this._createArcadeComputedField(s));break;case"label-expression":o.push(this._createLabelArcadeComputedField(s));break;case"statistic":c.push(s)}}this._computedFields=await Promise.all(o),this._canCacheExpressionValue=!this._computedFields.some((e=>"expression"===e.type&&null!=e.expression&&e.expression.referencesScale())),this._statisticFields=c}setComputedAttributes(e,s,t,i){const a=this._bitsets.computed;if(!this._canCacheExpressionValue||!a.has(t)){a.set(t);for(const a of this._computedFields){const r=this._evaluateField(s,a,i);switch(a.resultType){case"numeric":e.setComputedNumericAtIndex(t,a.fieldIndex,r);break;case"string":e.setComputedStringAtIndex(t,a.fieldIndex,r)}}}}async _createArcadeComputedField(e){const s=this._sourceInfo.spatialReference,i=this._sourceInfo.fieldsIndex;return{...e,expression:await t(e.valueExpression,s,i)}}async _createLabelArcadeComputedField(e){const s=this._sourceInfo.spatialReference,t=this._sourceInfo.fieldsIndex,{createLabelFunction:i}=await import("../../../../layers/support/labelFormatUtils.js"),a=await i(e.label,t,s);return{...e,builder:a}}_evaluateField(e,s,t){switch(s.type){case"label-expression":{const t=e.readArcadeFeature();return s.builder.evaluate(t)||""}case"expression":{const{expression:a}=s;return i(a,e,{$view:{scale:t}})}}}}export{a as Store2D};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{handlesGroup as e}from"../../../../../core/handleUtils.js";import"../../../../../core/has.js";import{r as t}from"../../../../../chunks/rbush.js";import{convertFromFeature as s,quantizeOptimizedGeometry as n,quantizeX as i,quantizeY as r}from"../../../../../layers/graphics/featureConversionUtils.js";import o from"../../../../../layers/graphics/OptimizedGeometry.js";import{StreamFeatureManager as a}from"../../../../../layers/graphics/data/StreamFeatureManager.js";import{createConnection as d}from"../../../../../layers/graphics/sources/connections/createConnection.js";import{DataTileSource as c}from"./DataTileSource.js";import{StreamConnectionState as h}from"./StreamConnectionState.js";import{FeatureSetReaderJSON as u}from"../support/FeatureSetReaderJSON.js";import{UpdateToken as l}from"../support/UpdateToken.js";const p=2500;function _(e,t){const s=e.weakClone();if(null!=e.geometry){const n=i(t,e.geometry.coords[0]),a=r(t,e.geometry.coords[1]);s.geometry=new o([],[n,a])}return s}function m(e){return"esriGeometryPoint"===e?_:(t,s)=>{const i=t.weakClone(),r=new o,a=!1,d=!1,c=n(r,t.geometry,a,d,e,s,!1,!1);return i.geometry=c,i}}function g(e){return"esriGeometryPoint"===e?e=>null!=e.geometry?{minX:e.geometry.coords[0],minY:e.geometry.coords[1],maxX:e.geometry.coords[0],maxY:e.geometry.coords[1]}:{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}:e=>{let t=1/0,s=1/0,n=-1/0,i=-1/0;return null!=e.geometry&&e.geometry.forEachVertex(((e,r)=>{t=Math.min(t,e),s=Math.min(s,r),n=Math.max(n,e),i=Math.max(i,r)})),{minX:t,minY:s,maxX:n,maxY:i}}}function y(e,s){const n=t(9,g(s));return n.load(e),n}function f(e,t){return e.search({minX:t.bounds[0],minY:t.bounds[1],maxX:t.bounds[2],maxY:t.bounds[3]})}class v{constructor(e,t){this.onUpdate=e,this._geometryType=t,this._objectIdToFeature=new Map,this._index=null}get _features(){const e=[];return this._objectIdToFeature.forEach((t=>e.push(t))),e}add(e){this._objectIdToFeature.set(e.objectId,e),this._index=null}get(e){return this._objectIdToFeature.has(e)?this._objectIdToFeature.get(e):null}forEach(e){this._objectIdToFeature.forEach(e)}search(e){return this._index||(this._index=y(this._features,this._geometryType)),f(this._index,e)}clear(){this._index=null,this._objectIdToFeature.clear()}removeById(e){const t=this._objectIdToFeature.get(e);return t?(this._objectIdToFeature.delete(e),this._index=null,t):null}update(e,t){this.onUpdate(e,t)}get size(){return this._objectIdToFeature.size}}class
|
|
5
|
+
import{handlesGroup as e}from"../../../../../core/handleUtils.js";import"../../../../../core/has.js";import{r as t}from"../../../../../chunks/rbush.js";import{convertFromFeature as s,quantizeOptimizedGeometry as n,quantizeX as i,quantizeY as r}from"../../../../../layers/graphics/featureConversionUtils.js";import o from"../../../../../layers/graphics/OptimizedGeometry.js";import{StreamFeatureManager as a}from"../../../../../layers/graphics/data/StreamFeatureManager.js";import{createConnection as d}from"../../../../../layers/graphics/sources/connections/createConnection.js";import{DataTileSource as c}from"./DataTileSource.js";import{StreamConnectionState as h}from"./StreamConnectionState.js";import{FeatureSetReaderJSON as u}from"../support/FeatureSetReaderJSON.js";import{UpdateToken as l}from"../support/UpdateToken.js";const p=2500;function _(e,t){const s=e.weakClone();if(null!=e.geometry){const n=i(t,e.geometry.coords[0]),a=r(t,e.geometry.coords[1]);s.geometry=new o([],[n,a])}return s}function m(e){return"esriGeometryPoint"===e?_:(t,s)=>{const i=t.weakClone(),r=new o,a=!1,d=!1,c=n(r,t.geometry,a,d,e,s,!1,!1);return i.geometry=c,i}}function g(e){return"esriGeometryPoint"===e?e=>null!=e.geometry?{minX:e.geometry.coords[0],minY:e.geometry.coords[1],maxX:e.geometry.coords[0],maxY:e.geometry.coords[1]}:{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}:e=>{let t=1/0,s=1/0,n=-1/0,i=-1/0;return null!=e.geometry&&e.geometry.forEachVertex(((e,r)=>{t=Math.min(t,e),s=Math.min(s,r),n=Math.max(n,e),i=Math.max(i,r)})),{minX:t,minY:s,maxX:n,maxY:i}}}function y(e,s){const n=t(9,g(s));return n.load(e),n}function f(e,t){return e.search({minX:t.bounds[0],minY:t.bounds[1],maxX:t.bounds[2],maxY:t.bounds[3]})}class v{constructor(e,t){this.onUpdate=e,this._geometryType=t,this._objectIdToFeature=new Map,this._index=null}get _features(){const e=[];return this._objectIdToFeature.forEach((t=>e.push(t))),e}add(e){this._objectIdToFeature.set(e.objectId,e),this._index=null}get(e){return this._objectIdToFeature.has(e)?this._objectIdToFeature.get(e):null}forEach(e){this._objectIdToFeature.forEach(e)}search(e){return this._index||(this._index=y(this._features,this._geometryType)),f(this._index,e)}clear(){this._index=null,this._objectIdToFeature.clear()}removeById(e){const t=this._objectIdToFeature.get(e);return t?(this._objectIdToFeature.delete(e),this._index=null,t):null}update(e,t){this.onUpdate(e,t)}get size(){return this._objectIdToFeature.size}}class b extends c{constructor(t){super(t),this.type="stream",this._updateIntervalId=0,this._level=0,this._isPaused=!1,this._updateInfo={websocket:0,client:0},this._inUpdate=!1;const{outSR:s}=t,{geometryType:n,objectIdField:i,timeInfo:r,purgeOptions:o,source:c,spatialReference:u,serviceFilter:l,maxReconnectionAttempts:_,maxReconnectionInterval:g,updateInterval:y,customParameters:f,enabledEventTypes:b}=t.serviceInfo,I=new v(this._onUpdate.bind(this),n),T=new a(I,i,r,o),j=d(c,u,s,n,l,_,g,f??{});this._connectionState=new h({connection:j}),this._store=I,this._manager=T,this._connection=j,this._quantize=m(n),this._enabledEventTypes=new Set(b),this._handlesGroup=e([this._connection.on("data-received",(e=>this._onFeature(e))),this._connection.on("message-received",(e=>this._onWebSocketMessage(e)))]),this._initUpdateInterval=()=>{let e=performance.now();this._updateIntervalId=setInterval((()=>{const s=performance.now(),n=s-e;if(n>p){e=s;const t=Math.round(this._updateInfo.client/(n/1e3)),i=Math.round(this._updateInfo.websocket/(n/1e3));this._updateInfo.client=0,this._updateInfo.websocket=0,this.events.emit("updateRate",{client:t,websocket:i})}t.canAcceptRequest()&&!this._inUpdate&&this._manager.checkForUpdates()}),y)},this._initUpdateInterval()}destroy(){super.destroy(),this._clearUpdateInterval(),this._connection.destroy(),this._handlesGroup?.remove()}_fetchDataTile(){}get connectionStatus(){return this._connectionState.connectionStatus}get errorString(){return this._connectionState.errorString}updateCustomParameters(e){this._connection.updateCustomParameters(e)}pauseStream(){this._isPaused||(this._isPaused=!0,this._clearUpdateInterval())}resumeStream(){this._isPaused&&(this._isPaused=!1,this._initUpdateInterval())}sendMessageToSocket(e){this._connection.sendMessageToSocket(e)}sendMessageToClient(e){this._isPaused&&"type"in e&&"clear"===e.type?(this._store.clear(),this._subscriptions.forEach(((e,t)=>{e.didSend&&e.tile.level===this._level&&this._onMessage({type:"append",id:t,addOrUpdate:null,clear:!0,end:!0})}))):this._connection.sendMessageToClient(e)}enableEvent(e,t){t?this._enabledEventTypes.add(e):this._enabledEventTypes.delete(e)}subscribe(e,t){super.subscribe(e,t);const s=this._subscriptions.get(e.id);s.resolve(),this._level=e.level;const n=this._getTileFeatures(e);this._onMessage({type:"append",id:e.key.id,addOrUpdate:n,end:!0}),s.didSend=!0}unsubscribe(e){super.unsubscribe(e)}*readers(e){const t=this._subscriptions.get(e),{tile:s}=t;yield this._getTileFeatures(s)}createTileQuery(e){throw new Error("Service does not support tile queries")}async resend(){this._subscriptions.forEach((e=>{const{tile:t}=e,s={type:"append",id:t.id,addOrUpdate:this._getTileFeatures(t),end:!0};this._onMessage(s)}))}_getTileFeatures(e){const t=this._store.search(e).map((t=>this._quantize(t,e.transform)));return u.fromOptimizedFeatures(t,this._serviceInfo,e.transform)}_onWebSocketMessage(e){if(this._enabledEventTypes.has("message-received")&&this.events.emit("message-received",e),"type"in e)switch(e.type){case"delete":if(e.objectIds)for(const t of e.objectIds)this._manager.removeById(t);if(e.trackIds)for(const t of e.trackIds)this._manager.removeByTrackId(t);break;case"clear":this._store.forEach((e=>this._manager.removeById(e.objectId)))}}_onFeature(e){this._updateInfo.websocket++;try{this._enabledEventTypes.has("data-received")&&this.events.emit("data-received",e);const t=s(e,this._serviceInfo.geometryType,!1,!1,this._serviceInfo.objectIdField);this._manager.add(t)}catch(t){}}_clearUpdateInterval(){clearInterval(this._updateIntervalId),this._updateIntervalId=0}async _onUpdate(e,t){this._inUpdate=!0;try{null!=e&&(this._updateInfo.client+=e.length),this._subscriptions.forEach(((e,t)=>{e.didSend&&e.tile.level===this._level&&this._onMessage({type:"append",id:t,addOrUpdate:null,clear:!0,end:!1})}));const t=[];this._subscriptions.forEach(((e,s)=>{if(!e.didSend||e.tile.level!==this._level)return;const n=e.tile,i={type:"append",id:s,addOrUpdate:this._getTileFeatures(n),remove:[],end:!1,status:l.empty()};e.requests.stream.enqueue(i),t.push(this._onMessage(i))})),await Promise.all(t),this._subscriptions.forEach(((e,t)=>{e.didSend&&e.tile.level===this._level&&this._onMessage({type:"append",id:t,addOrUpdate:null,end:!0})}))}catch{}this._inUpdate=!1}}export{b as StreamSource};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{f as r,t as o}from"../../../../chunks/mat3.js";import{c as a}from"../../../../chunks/mat3f64.js";import{f as n,m as s,a as i}from"../../../../chunks/mat4.js";import{c as l,I as u,b as c}from"../../../../chunks/mat4f64.js";import{s as m,a as h,g as f,e as p,n as d,b as g,f as x}from"../../../../chunks/vec3.js";import{Z as _,O as T,c as b}from"../../../../chunks/vec3f64.js";import{O as y}from"../../../../chunks/vec4f64.js";import{computeTranslationToOriginAndRotation as v,projectVectorToDehydratedPoint as C,projectBuffer as O,canProjectWithoutEngine as w}from"../../../../geometry/projection.js";import{create as M,empty as P,expandWithBuffer as j,intersectsClippingArea as A}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as I}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as R,getZeroIndexArray as E}from"../../../../geometry/support/Indices.js";import N from"../../../../geometry/support/MeshComponent.js";import B from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import F from"../../../../geometry/support/MeshTextureTransform.js";import{t as S,a as U}from"../../../../chunks/vec32.js";import{transformNormal as L,projectNormalToPCPF as $,transformTangent as G,projectTangentToPCPF as V}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as D}from"../../../../layers/graphics/dehydratedFeatures.js";import{MeshTransformUpdateAction as k}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as H}from"../../../ViewingMode.js";import{isEncodedMeshTexture as q}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as W}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as z}from"./ElevationAligners.js";import{needsElevationUpdates3D as Y,evaluateElevationInfoAtPoint as Z}from"./elevationAlignmentUtils.js";import{ElevationContext as J}from"./ElevationContext.js";import{Graphics3DMeshObject3DGraphicLayer as K}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as Q}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as X}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as ee,MeshFastUpdateProcessor as te}from"./MeshFastUpdateProcessor.js";import{createMaterial as re}from"../support/edgeUtils.js";import{parseColorMixMode as oe,encodeSymbolColor as ae}from"../support/symbolColorUtils.js";import ne from"../../support/debugFlags.js";import{Attribute as se}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as ie,CullFaceOptions as le}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as ue}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as ce}from"../../webgl-engine/lib/Geometry.js";import{Object3D as me}from"../../webgl-engine/lib/Object3D.js";import{Texture as he}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as fe}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as pe}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as de}from"../../webgl-engine/materials/NativeLineMaterial.js";import{TextureWrapMode as ge}from"../../../webgl/enums.js";const xe=["mesh"];class _e extends X{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new ee,this._fastUpdateProcessor=new te,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){ne.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new de({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new de({color:[0,1,1,1]}))}destroy(){super.destroy(),this._context.stage.removeMany(this._materialInfoCache.materials),this._context.stage.removeMany(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy(this._context.stage)}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,xe,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t,new J),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache,this._context)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>{const o=t(e);null!=o&&o.layerOpacityChanged(r,this._context.isAsync)}))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,Y)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters((({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>{const r=t(e);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters((({material:t})=>t.setParameters({usePBR:e}))),!0}updateTransform(e,t,r,o){const a=this._context.renderCoordsHelper.spatialReference,n=Pe,{origin:s,transform:i}=r;switch(v(t,m(ye,s.x,s.y,s.z??0),n,a),o){case k.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case k.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case k.UpdateFastLocalOrigin:e.updateFastLocalOrigin(n,i,this._context.localOriginFactory)}const{elevationContext:l}=e;l.centerPointInElevationSR=this._getCenterPointInElevationSR(n);const{elevationProvider:u,renderCoordsHelper:c}=this._context,h=(e,t)=>Z(e,u,l,c,t);return e.alignedSampledElevation=z(e,l,u.spatialReference,h,c,n),e.updateTransform(n,i,this._context.isAsync),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_textureTransformUid(e){const{offset:t,scale:r,rotation:o}=e??Ie;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:n,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:u,alphaCutoff:c,alphaMode:m}=t.material,h=this._colorOrTextureUid(a),f=this._colorOrTextureUid(n),p=this._textureTransformUid(s),d=this._colorOrTextureUid(i),g=this._textureTransformUid(l);if(o.color=a,o.colorTexture=n,o.normalTexture=i,o.uid=`${o.uid},cmuid:${h},ctmuid:${f},cttuid:${p},ntmuid:${d},nttuid:${g},ds:${u},ac:${c},am:${m}`,t.material instanceof B){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:n,emissiveColor:i,emissiveTexture:u,emissiveTextureTransform:c,occlusionTexture:m,occlusionTextureTransform:h}=t.material,f=this._colorOrTextureUid(a),p=this._textureTransformUid(n),d=this._colorOrTextureUid(i),g=this._colorOrTextureUid(u),x=this._textureTransformUid(c),_=this._colorOrTextureUid(m),T=this._textureTransformUid(h);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=i,o.emissiveTexture=u,o.occlusionTexture=m,o.colorTextureTransform=this._convertTextureTransform(s),o.normalTextureTransform=this._convertTextureTransform(l),o.emissiveTextureTransform=this._convertTextureTransform(c),o.occlusionTextureTransform=this._convertTextureTransform(h),o.metallicRoughnessTextureTransform=this._convertTextureTransform(n),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${f},mrtt:${p},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${T}`}return o}_convertTextureTransform(e){if(!e)return null;const{scale:r,offset:o,rotation:a}=e;return{scale:r,offset:o,rotation:t(a)}}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data?e.data:e.url}_getInternalTextureId(e){const t=this._getInternalTexture(e,ie.Opaque);return null!=t?t.id:null}_getInternalTexture(e,t){const r=this._getLoadableTextureResource(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let a=this._textures.get(o);return a||(a=new he(q(r)?r.data:r,{mipmap:!0,wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,preMultiplyAlpha:!q(r)&&t!==ie.Opaque,encoding:q(r)&&null!=r.encoding?r.encoding:void 0}),this._textures.set(o,a),this._context.stage.add(a),this._context.stage.loadImmediate(a)),a}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return ge.CLAMP_TO_EDGE;case"mirror":return ge.MIRRORED_REPEAT;default:return ge.REPEAT}}_setInternalMaterialParameters(t,r){if(null!=t.color&&this._setInternalColorValueParameters(t.color,r),null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);null!=e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}null!=t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),null!=t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),null!=t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),null!=t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),null!=t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture)),r.colorTextureTransformMatrix=W(t.colorTextureTransform),r.normalTextureTransformMatrix=W(t.normalTextureTransform),r.occlusionTextureTransformMatrix=W(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=W(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=W(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=null!=this.symbolLayer.material?this.symbolLayer.material.colorMixMode:null;if(r)t.externalColor=y;else{const r=null!=this.symbolLayer.material?this.symbolLayer.material.color:null;null!=r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=y)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(e,t){const r=t.material?.color,o=t.material?.colorTexture,a=t.material?.alphaMode,n="blend"===a,s=!("opaque"===a)&&(this._hasTransparentVertexColors(e)||null!=r&&r.a<1||null!=o&&o.transparent||n),i=this._materialProperties(e,t,s),l=this._materialInfoCache.byUid(i.uid);if(l)return l.material;const u={uid:i.uid,material:null,isComponentTransparent:s,alphaMode:t.material?t.material.alphaMode:"opaque"},c=null==i.metallicRoughnessTexture&&null==i.metallic&&null==i.roughness,m={usePBR:this._usePBR(),isSchematic:c,hasVertexColors:i.hasVertexColors,hasSymbolColors:i.hasSymbolVertexColors,hasVertexTangents:i.hasVertexTangents,ambient:_,diffuse:T,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:le.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};c||(m.mrrFactors=[null!=i.metallic?i.metallic:1,null!=i.roughness?i.roughness:1,.5]),t.material&&(m.doubleSided=t.material.doubleSided,m.cullFace=t.material.doubleSided?le.None:le.Back,m.textureAlphaCutoff=t.material.alphaCutoff),this._setExternalMaterialParameters(m),this._setMaterialTransparentParameter(m,u),this._setInternalMaterialParameters(i,m);const h=new pe(m);return u.material=h,this._materialInfoCache.set(i.uid,u),this._context.stage.add(h),h}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?ie.MaskBlend:ie.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?ie.Opaque:"mask"===t.alphaMode?ie.Mask:ie.Blend}_addDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,a=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),n=[],s=[],i=[],l=[];for(let p=0;p<r;p++){const e=t[p],r=e.vertexAttributes.get(fe.POSITION),o=e.vertexAttributes.get(fe.NORMAL),u=e.indices.get(fe.POSITION),c=e.indices.get(fe.NORMAL),m=r.data,d=o.data;for(let t=0;t<u.length;t++){const e=3*u[t],r=3*c[t];for(let t=0;t<3;t++)n.push(m[e+t]);for(let t=0;t<3;t++)n.push(m[e+t]+d[r+t]*a);if(s.push(s.length),s.push(s.length),t%3==0){this._calculateFaceNormal(m,u,t,Oe),this._getFaceVertices(m,u,t,ye,ve,Ce),h(ye,ye,ve),h(ye,ye,Ce),f(ye,ye,1/3);for(let e=0;e<3;e++)i.push(ye[e]);for(let e=0;e<3;e++)i.push(ye[e]+Oe[e]*a);l.push(l.length),l.push(l.length)}}}const u=t[0].transformation,c=new ce(this._debugVertexNormalMaterial,[[fe.POSITION,new se(n,3,!0)]],[[fe.POSITION,s]],null,ue.Line);t.push(c),c.transformation=u;const m=new ce(this._debugFaceNormalMaterial,[[fe.POSITION,new se(i,3,!0)]],[[fe.POSITION,l]],null,ue.Line);m.transformation=u,t.push(m)}_createAs3DShape(e,t,r,o){const a=e.geometry;if("mesh"!==a.type)return null;const n=this._createGeometryInfo(a,t,o);if(null==n)return null;const{geometries:s,objectTransformation:i}=n;ne.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(a,s);const l=new me({geometries:s,layerUid:this._context.layer.uid,graphicUid:o});l.transformation=i;const u=re(this.symbolLayer,{opacity:this._getLayerOpacity()}),c=null!=u?new Q(s[0].material,[u],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,m=new K(this,l,s,null,null,z,r,c);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=Y(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:h,renderCoordsHelper:f}=this._context,p=(e,t)=>Z(e,h,r,f,t);return m.alignedSampledElevation=z(m,r,h.spatialReference,p,f),m}_getCenterPointInElevationSR(e){const t=D(0,0,0,null!=this._context.elevationProvider.spatialReference?this._context.elevationProvider.spatialReference:null);return C([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){default:case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o)}}_createComponentNormalsSource(e,t,r,o){if(null==t)return this._createComponentNormalsFlat(e,o);let a=!1;if(!r.trustSourceNormals)for(let n=0;n<o.length;n+=3){this._calculateFaceNormal(e,o,n,Oe);for(let e=0;e<3;e++){const r=3*o[n+e];ye[0]=t[r],ye[1]=t[r+1],ye[2]=t[r+2],p(Oe,ye)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new Te(t,o,a)}_createComponentNormalsFlat(e,t){const r=I(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const n=this._calculateFaceNormal(e,t,a,Oe);for(let e=0;e<3;e++)r[a+e]=n[e],o[a+e]=a/3}return new Te(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let n=0;n<t.length;n+=3){const o=this._calculateFaceNormal(e,t,n,Oe);for(let e=0;e<3;e++){const a=t[n+e];let s=r[a];s||(s={normal:b(),count:0},r[a]=s),h(s.normal,s.normal,o),s.count++}}const o=I(3*t.length),a=new Array(3*t.length);for(let n=0;n<t.length;n++){const e=r[t[n]];1!==e.count&&(d(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*n+t]=e.normal[t];a[n]=n}return new Te(o,a,!1)}_getFaceVertices(e,t,r,o,a,n){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],n[0]=e[l],n[1]=e[l+1],n[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,ye,ve,Ce),g(ve,ve,ye),g(Ce,Ce,ye),x(ye,ve,Ce),d(o,ye),o}_getOrCreateComponents(e){return e.components??Ae}_createPositionBuffer(e,t){let r=e.vertexAttributes.position;const o=t.reprojection===Re.ECEF?t.transformBeforeProject:null;if(null!=o&&(r=S(new Float64Array(r.length),r,o)),t.reprojection===Re.NONE)return t.needsBufferCopy?new Float64Array(r):r;const a=null!=o?r:new Float64Array(r.length);return O(r,e.spatialReference,0,a,this._context.renderCoordsHelper.spatialReference,0,r.length/3),a}_createNormalBuffer(e,t,r){let o=e.vertexAttributes.normal;if(null==o)return null;const a=r.reprojection===Re.ECEF?r.transformBeforeProject:null;null!=a&&(o=L(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Re.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const n=e.vertexAttributes.position,s=null!=a?o:new Float32Array(o.length);return $(o,n,t,e.spatialReference,s)}_createTangentBuffer(e,t,r){let o=e.vertexAttributes.tangent;if(null==o)return null;const a=r.reprojection===Re.ECEF?r.transformBeforeProject:null;null!=a&&(o=G(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Re.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const n=e.vertexAttributes.position,s=null!=a?o:new Float32Array(o.length);return V(o,n,t,e.spatialReference,s)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=oe(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return ae(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,a=e.vertexAttributes.uv,n=e.vertexAttributes.tangent;if(null!=o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(null!=n&&n.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(null!=a&&a.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),i=this._createPositionBuffer(e,s),u=this._createColorBuffer(e),c=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,s),h=this._createTangentBuffer(e,i,s);return{positionBuffer:i,normalBuffer:m,tangentBuffer:h,uvBuffer:a,colorBuffer:u,symbolColorBuffer:c,objectTransformation:s.reprojection===Re.NONE&&null!=s.objectTransformation?s.objectTransformation:this._transformOriginLocal(e,i,m,h),geometryTransformation:s.reprojection===Re.NONE&&null!=s.geometryTransformation?s.geometryTransformation:l()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r=t.isRelative,o=t.isGeoreferenced?this._context.renderCoordsHelper.viewingMode===H.Local?Re.NONE:Re.ECEF:Re.NONE;if(r){const{origin:r}=t,a=l(),i=e.transform?.localMatrix??u;if(o===Re.NONE){v(e.spatialReference,r,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:o,objectTransformation:a,geometryTransformation:c(i),needsBufferCopy:!1}}const m=n(l(),r);return s(m,m,i),{reprojection:o,transformBeforeProject:m,needsBufferCopy:!0}}return{reprojection:o,needsBufferCopy:!0}}_transformOriginLocal(e,t,a,n){const s=this._context.renderCoordsHelper.spatialReference,u=e.anchor;be[0]=u.x,be[1]=u.y,be[2]=u.z??0;const c=l();return v(e.spatialReference,be,c,s),i(we,c),S(t,t,we),null==a&&null==n||(r(Me,c),o(Me,Me),null!=a&&U(a,a,Me),null!=n&&U(n,n,Me,4)),c}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_getOrCreateFaces(e,t){return t.faces??R(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes&&e.vertexAttributes.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference;let o;const a=t.length/3;return null==r||e.spatialReference.equals(r)?o=t:(o=new Float64Array(t.length),O(e.vertexAttributes.position,e.spatialReference,0,o,r,0,a)),P(je),j(je,o,0,a),!A(je,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!w(e.spatialReference,this._context.graphicsCoreOwner.view.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:a,uvBuffer:n,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:u,objectTransformation:c,geometryTransformation:m}=o,h=this._getOrCreateComponents(e),f=new Array;let p=!1;for(const d of h){if(!this._validateFaces(e,d))return null;const t=this._getOrCreateFaces(e,d);if(0===t.length)continue;const o=this._createComponentNormals(a,l,d,t);o.didFlipNormals&&(p=!0);const c=[[fe.POSITION,new se(a,3,!0)],[fe.NORMAL,new se(o.normals,3,!0)]],h=[[fe.POSITION,t],[fe.NORMAL,o.indices]];null!=s&&(c.push([fe.COLOR,new se(s,4,!0)]),h.push([fe.COLOR,t])),null!=i&&(c.push([fe.SYMBOLCOLOR,new se(i,4,!0)]),h.push([fe.SYMBOLCOLOR,E(t.length)])),null!=n&&(c.push([fe.UV0,new se(n,2,!0)]),h.push([fe.UV0,t])),null!=u&&(c.push([fe.TANGENT,new se(u,4,!0)]),h.push([fe.TANGENT,t]));const g=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),x=this._getOrCreateMaterial(e,d),_=new ce(x,c,h,null,ue.Mesh,g);_.transformation=m,f.push(_)}return p&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:f,objectTransformation:c}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}test(){return{...super.test(),materials:this._materialInfoCache.materials}}}class Te{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const be=b(),ye=b(),ve=b(),Ce=b(),Oe=b(),we=l(),Me=a(),Pe=l(),je=M(),Ae=[new N],Ie=new F;var Re;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(Re||(Re={}));export{_e as Graphics3DMeshFillSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{f as r,t as o}from"../../../../chunks/mat3.js";import{c as a}from"../../../../chunks/mat3f64.js";import{f as n,m as s,a as i}from"../../../../chunks/mat4.js";import{c as l,I as u,b as c}from"../../../../chunks/mat4f64.js";import{s as m,a as h,g as f,e as p,n as d,b as g,f as x}from"../../../../chunks/vec3.js";import{Z as _,O as T,c as b}from"../../../../chunks/vec3f64.js";import{O as y}from"../../../../chunks/vec4f64.js";import{computeTranslationToOriginAndRotation as v,projectVectorToDehydratedPoint as C,projectBuffer as O,canProjectWithoutEngine as w}from"../../../../geometry/projection.js";import{create as M,empty as j,expandWithBuffer as A,intersectsClippingArea as P}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as I}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as R,getZeroIndexArray as E}from"../../../../geometry/support/Indices.js";import N from"../../../../geometry/support/MeshComponent.js";import F from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import B from"../../../../geometry/support/MeshTextureTransform.js";import{t as S,a as U}from"../../../../chunks/vec32.js";import{transformNormal as L,projectNormalToPCPF as $,transformTangent as G,projectTangentToPCPF as V}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as D}from"../../../../layers/graphics/dehydratedFeatures.js";import{MeshTransformUpdateAction as k}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as H}from"../../../ViewingMode.js";import{isEncodedMeshTexture as q}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as W}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as z}from"./ElevationAligners.js";import{needsElevationUpdates3D as Y,evaluateElevationInfoAtPoint as Z}from"./elevationAlignmentUtils.js";import{ElevationContext as J}from"./ElevationContext.js";import{Graphics3DMeshObject3DGraphicLayer as K}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as Q}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as X}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as ee,MeshFastUpdateProcessor as te}from"./MeshFastUpdateProcessor.js";import{createMaterial as re}from"../support/edgeUtils.js";import{parseColorMixMode as oe,encodeSymbolColor as ae}from"../support/symbolColorUtils.js";import ne from"../../support/debugFlags.js";import{Attribute as se}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as ie,CullFaceOptions as le}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as ue}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as ce}from"../../webgl-engine/lib/Geometry.js";import{Object3D as me}from"../../webgl-engine/lib/Object3D.js";import{Texture as he}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as fe}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as pe}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as de}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as ge}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as xe}from"../../../webgl/enums.js";const _e=["mesh"];class Te extends X{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new ee,this._fastUpdateProcessor=new te,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){ne.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new de({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new de({color:[0,1,1,1]}))}destroy(){super.destroy(),this._context.stage.removeMany(this._materialInfoCache.materials),this._context.stage.removeMany(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy(this._context.stage)}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,_e,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t,new J),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache,this._context)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>{const o=t(e);null!=o&&o.layerOpacityChanged(r,this._context.isAsync)}))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,Y)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters((({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>{const r=t(e);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters((({material:t})=>t.setParameters({usePBR:e}))),!0}updateTransform(e,t,r,o){const a=this._context.renderCoordsHelper.spatialReference,n=Ae,{origin:s,transform:i}=r;switch(v(t,m(ve,s.x,s.y,s.z??0),n,a),o){case k.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case k.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case k.UpdateFastLocalOrigin:e.updateFastLocalOrigin(n,i,this._context.localOriginFactory)}const{elevationContext:l}=e;l.centerPointInElevationSR=this._getCenterPointInElevationSR(n);const{elevationProvider:u,renderCoordsHelper:c}=this._context,h=(e,t)=>Z(e,u,l,c,t);return e.alignedSampledElevation=z(e,l,u.spatialReference,h,c,n),e.updateTransform(n,i,this._context.isAsync),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_textureTransformUid(e){const{offset:t,scale:r,rotation:o}=e??Re;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:n,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:u,alphaCutoff:c,alphaMode:m}=t.material,h=this._colorOrTextureUid(a),f=this._colorOrTextureUid(n),p=this._textureTransformUid(s),d=this._colorOrTextureUid(i),g=this._textureTransformUid(l);if(o.color=a,o.colorTexture=n,o.normalTexture=i,o.uid=`${o.uid},cmuid:${h},ctmuid:${f},cttuid:${p},ntmuid:${d},nttuid:${g},ds:${u},ac:${c},am:${m}`,t.material instanceof F){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:n,emissiveColor:i,emissiveTexture:u,emissiveTextureTransform:c,occlusionTexture:m,occlusionTextureTransform:h}=t.material,f=this._colorOrTextureUid(a),p=this._textureTransformUid(n),d=this._colorOrTextureUid(i),g=this._colorOrTextureUid(u),x=this._textureTransformUid(c),_=this._colorOrTextureUid(m),T=this._textureTransformUid(h);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=i,o.emissiveTexture=u,o.occlusionTexture=m,o.colorTextureTransform=this._convertTextureTransform(s),o.normalTextureTransform=this._convertTextureTransform(l),o.emissiveTextureTransform=this._convertTextureTransform(c),o.occlusionTextureTransform=this._convertTextureTransform(h),o.metallicRoughnessTextureTransform=this._convertTextureTransform(n),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${f},mrtt:${p},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${T}`}return o}_convertTextureTransform(e){if(!e)return null;const{scale:r,offset:o,rotation:a}=e;return{scale:r,offset:o,rotation:t(a)}}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data?e.data:e.url}_getInternalTextureId(e){const t=this._getInternalTexture(e,ie.Opaque);return null!=t?t.id:null}_getInternalTexture(e,t){const r=this._getLoadableTextureResource(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let a=this._textures.get(o);return a||(a=new he(q(r)?r.data:r,{mipmap:!0,wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,preMultiplyAlpha:!q(r)&&t!==ie.Opaque,encoding:q(r)&&null!=r.encoding?r.encoding:void 0}),this._textures.set(o,a),this._context.stage.add(a),this._context.stage.loadImmediate(a)),a}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return xe.CLAMP_TO_EDGE;case"mirror":return xe.MIRRORED_REPEAT;default:return xe.REPEAT}}_setInternalMaterialParameters(t,r){if(null!=t.color&&this._setInternalColorValueParameters(t.color,r),null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);null!=e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}null!=t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),null!=t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),null!=t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),null!=t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),null!=t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture)),r.colorTextureTransformMatrix=W(t.colorTextureTransform),r.normalTextureTransformMatrix=W(t.normalTextureTransform),r.occlusionTextureTransformMatrix=W(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=W(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=W(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=null!=this.symbolLayer.material?this.symbolLayer.material.colorMixMode:null;if(r)t.externalColor=y;else{const r=null!=this.symbolLayer.material?this.symbolLayer.material.color:null;null!=r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=y)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(t,r){const o=r.material?.color,a=r.material?.colorTexture,n=r.material?.alphaMode,s="blend"===n,i=!("opaque"===n)&&(this._hasTransparentVertexColors(t)||null!=o&&o.a<1||null!=a&&a.transparent||s),l=this._materialProperties(t,r,i),u=this._materialInfoCache.byUid(l.uid);if(u)return u.material;const c={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=ge({normalTexture:l.normalTexture,metallicRoughnessTexture:l.metallicRoughnessTexture,metallicFactor:l.metallic,roughnessFactor:l.roughness,emissiveTexture:l.emissiveTexture,emissiveFactor:e.toUnitRGBA(l.emissiveColor),occlusionTexture:l.occlusionTexture}),h={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:_,diffuse:T,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:le.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};m||(h.mrrFactors=[l.metallic??1,l.roughness??1,.5]),r.material&&(h.doubleSided=r.material.doubleSided,h.cullFace=r.material.doubleSided?le.None:le.Back,h.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(h),this._setMaterialTransparentParameter(h,c),this._setInternalMaterialParameters(l,h);const f=new pe(h);return c.material=f,this._materialInfoCache.set(l.uid,c),this._context.stage.add(f),f}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?ie.MaskBlend:ie.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?ie.Opaque:"mask"===t.alphaMode?ie.Mask:ie.Blend}_addDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,a=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),n=[],s=[],i=[],l=[];for(let p=0;p<r;p++){const e=t[p],r=e.vertexAttributes.get(fe.POSITION),o=e.vertexAttributes.get(fe.NORMAL),u=e.indices.get(fe.POSITION),c=e.indices.get(fe.NORMAL),m=r.data,d=o.data;for(let t=0;t<u.length;t++){const e=3*u[t],r=3*c[t];for(let t=0;t<3;t++)n.push(m[e+t]);for(let t=0;t<3;t++)n.push(m[e+t]+d[r+t]*a);if(s.push(s.length),s.push(s.length),t%3==0){this._calculateFaceNormal(m,u,t,we),this._getFaceVertices(m,u,t,ve,Ce,Oe),h(ve,ve,Ce),h(ve,ve,Oe),f(ve,ve,1/3);for(let e=0;e<3;e++)i.push(ve[e]);for(let e=0;e<3;e++)i.push(ve[e]+we[e]*a);l.push(l.length),l.push(l.length)}}}const u=t[0].transformation,c=new ce(this._debugVertexNormalMaterial,[[fe.POSITION,new se(n,3,!0)]],[[fe.POSITION,s]],null,ue.Line);t.push(c),c.transformation=u;const m=new ce(this._debugFaceNormalMaterial,[[fe.POSITION,new se(i,3,!0)]],[[fe.POSITION,l]],null,ue.Line);m.transformation=u,t.push(m)}_createAs3DShape(e,t,r,o){const a=e.geometry;if("mesh"!==a.type)return null;const n=this._createGeometryInfo(a,t,o);if(null==n)return null;const{geometries:s,objectTransformation:i}=n;ne.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(a,s);const l=new me({geometries:s,layerUid:this._context.layer.uid,graphicUid:o});l.transformation=i;const u=re(this.symbolLayer,{opacity:this._getLayerOpacity()}),c=null!=u?new Q(s[0].material,[u],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,m=new K(this,l,s,null,null,z,r,c);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=Y(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:h,renderCoordsHelper:f}=this._context,p=(e,t)=>Z(e,h,r,f,t);return m.alignedSampledElevation=z(m,r,h.spatialReference,p,f),m}_getCenterPointInElevationSR(e){const t=D(0,0,0,null!=this._context.elevationProvider.spatialReference?this._context.elevationProvider.spatialReference:null);return C([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){default:case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o)}}_createComponentNormalsSource(e,t,r,o){if(null==t)return this._createComponentNormalsFlat(e,o);let a=!1;if(!r.trustSourceNormals)for(let n=0;n<o.length;n+=3){this._calculateFaceNormal(e,o,n,we);for(let e=0;e<3;e++){const r=3*o[n+e];ve[0]=t[r],ve[1]=t[r+1],ve[2]=t[r+2],p(we,ve)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new be(t,o,a)}_createComponentNormalsFlat(e,t){const r=I(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const n=this._calculateFaceNormal(e,t,a,we);for(let e=0;e<3;e++)r[a+e]=n[e],o[a+e]=a/3}return new be(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let n=0;n<t.length;n+=3){const o=this._calculateFaceNormal(e,t,n,we);for(let e=0;e<3;e++){const a=t[n+e];let s=r[a];s||(s={normal:b(),count:0},r[a]=s),h(s.normal,s.normal,o),s.count++}}const o=I(3*t.length),a=new Array(3*t.length);for(let n=0;n<t.length;n++){const e=r[t[n]];1!==e.count&&(d(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*n+t]=e.normal[t];a[n]=n}return new be(o,a,!1)}_getFaceVertices(e,t,r,o,a,n){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],n[0]=e[l],n[1]=e[l+1],n[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,ve,Ce,Oe),g(Ce,Ce,ve),g(Oe,Oe,ve),x(ve,Ce,Oe),d(o,ve),o}_getOrCreateComponents(e){return e.components??Ie}_createPositionBuffer(e,t){let r=e.vertexAttributes.position;const o=t.reprojection===Ee.ECEF?t.transformBeforeProject:null;if(null!=o&&(r=S(new Float64Array(r.length),r,o)),t.reprojection===Ee.NONE)return t.needsBufferCopy?new Float64Array(r):r;const a=null!=o?r:new Float64Array(r.length);return O(r,e.spatialReference,0,a,this._context.renderCoordsHelper.spatialReference,0,r.length/3),a}_createNormalBuffer(e,t,r){let o=e.vertexAttributes.normal;if(null==o)return null;const a=r.reprojection===Ee.ECEF?r.transformBeforeProject:null;null!=a&&(o=L(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Ee.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const n=e.vertexAttributes.position,s=null!=a?o:new Float32Array(o.length);return $(o,n,t,e.spatialReference,s)}_createTangentBuffer(e,t,r){let o=e.vertexAttributes.tangent;if(null==o)return null;const a=r.reprojection===Ee.ECEF?r.transformBeforeProject:null;null!=a&&(o=G(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Ee.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const n=e.vertexAttributes.position,s=null!=a?o:new Float32Array(o.length);return V(o,n,t,e.spatialReference,s)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=oe(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return ae(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,a=e.vertexAttributes.uv,n=e.vertexAttributes.tangent;if(null!=o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(null!=n&&n.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(null!=a&&a.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),i=this._createPositionBuffer(e,s),u=this._createColorBuffer(e),c=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,s),h=this._createTangentBuffer(e,i,s);return{positionBuffer:i,normalBuffer:m,tangentBuffer:h,uvBuffer:a,colorBuffer:u,symbolColorBuffer:c,objectTransformation:s.reprojection===Ee.NONE&&null!=s.objectTransformation?s.objectTransformation:this._transformOriginLocal(e,i,m,h),geometryTransformation:s.reprojection===Ee.NONE&&null!=s.geometryTransformation?s.geometryTransformation:l()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r=t.isRelative,o=t.isGeoreferenced?this._context.renderCoordsHelper.viewingMode===H.Local?Ee.NONE:Ee.ECEF:Ee.NONE;if(r){const{origin:r}=t,a=l(),i=e.transform?.localMatrix??u;if(o===Ee.NONE){v(e.spatialReference,r,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:o,objectTransformation:a,geometryTransformation:c(i),needsBufferCopy:!1}}const m=n(l(),r);return s(m,m,i),{reprojection:o,transformBeforeProject:m,needsBufferCopy:!0}}return{reprojection:o,needsBufferCopy:!0}}_transformOriginLocal(e,t,a,n){const s=this._context.renderCoordsHelper.spatialReference,u=e.anchor;ye[0]=u.x,ye[1]=u.y,ye[2]=u.z??0;const c=l();return v(e.spatialReference,ye,c,s),i(Me,c),S(t,t,Me),null==a&&null==n||(r(je,c),o(je,je),null!=a&&U(a,a,je),null!=n&&U(n,n,je,4)),c}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_getOrCreateFaces(e,t){return t.faces??R(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes&&e.vertexAttributes.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference;let o;const a=t.length/3;return null==r||e.spatialReference.equals(r)?o=t:(o=new Float64Array(t.length),O(e.vertexAttributes.position,e.spatialReference,0,o,r,0,a)),j(Pe),A(Pe,o,0,a),!P(Pe,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!w(e.spatialReference,this._context.graphicsCoreOwner.view.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:a,uvBuffer:n,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:u,objectTransformation:c,geometryTransformation:m}=o,h=this._getOrCreateComponents(e),f=new Array;let p=!1;for(const d of h){if(!this._validateFaces(e,d))return null;const t=this._getOrCreateFaces(e,d);if(0===t.length)continue;const o=this._createComponentNormals(a,l,d,t);o.didFlipNormals&&(p=!0);const c=[[fe.POSITION,new se(a,3,!0)],[fe.NORMAL,new se(o.normals,3,!0)]],h=[[fe.POSITION,t],[fe.NORMAL,o.indices]];null!=s&&(c.push([fe.COLOR,new se(s,4,!0)]),h.push([fe.COLOR,t])),null!=i&&(c.push([fe.SYMBOLCOLOR,new se(i,4,!0)]),h.push([fe.SYMBOLCOLOR,E(t.length)])),null!=n&&(c.push([fe.UV0,new se(n,2,!0)]),h.push([fe.UV0,t])),null!=u&&(c.push([fe.TANGENT,new se(u,4,!0)]),h.push([fe.TANGENT,t]));const g=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),x=this._getOrCreateMaterial(e,d),_=new ce(x,c,h,null,ue.Mesh,g);_.transformation=m,f.push(_)}return p&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:f,objectTransformation:c}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}test(){return{...super.test(),materials:this._materialInfoCache.materials}}}class be{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const ye=b(),ve=b(),Ce=b(),Oe=b(),we=b(),Me=l(),je=a(),Ae=l(),Pe=M(),Ie=[new N],Re=new B;var Ee;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(Ee||(Ee={}));export{Te as Graphics3DMeshFillSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import l from"../../../../core/Error.js";import{fetchStyle as t,symbolUrlFromStyleItem as s}from"../../../../symbols/support/styleUtils.js";import{getStyleItemFromStyle as e,fetchSymbolFromStyle as n}from"../../../../symbols/support/webStyleSymbolUtils.js";async function r(r){if(null===r||null==r.styleName&&null==r.styleUrl)return null;const o=r.name;if(null==o)throw new l("symbolstyleutils:style-symbol-reference-name-missing","Missing name in style symbol reference");const u={portal:r.portal},i=await t(r,u).catch((()=>null));if(null===i)return null;const m=e(o,i.data);if(m&&!m.formatInfos
|
|
5
|
+
import l from"../../../../core/Error.js";import{fetchStyle as t,symbolUrlFromStyleItem as s}from"../../../../symbols/support/styleUtils.js";import{getStyleItemFromStyle as e,fetchSymbolFromStyle as n}from"../../../../symbols/support/webStyleSymbolUtils.js";async function r(r){if(null===r||null==r.styleName&&null==r.styleUrl)return null;const o=r.name;if(null==o)throw new l("symbolstyleutils:style-symbol-reference-name-missing","Missing name in style symbol reference");const u={portal:r.portal},i=await t(r,u).catch((()=>null));if(null===i)return null;const m=e(o,i.data);if(m&&!m.formatInfos?.some((l=>"gltf_basisu"===l.type)))return null;const a=await n(i,o,u,"webRef",((l,t)=>s(l,t,["gltf_basisu","gltf"]))).catch((()=>null));if(null===a||"point-3d"!==a.type)return null;const y=a.symbolLayers.items[0];return"object"===y.type?y.resource:null}export{r as getResourceUrlFromSymbolStyle};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import t from"../../../../core/Error.js";import{MIN_PRIORITY as o}from"../../../../core/MemCache.js";import{generateUUID as n}from"../../../../core/uuid.js";import{projectBoundingSphere as r,projectBuffer as s,canProjectWithoutEngine as a,isLoaded as l,load as i}from"../../../../geometry/projection.js";import{newDoubleArray as u}from"../../../../geometry/support/DoubleArray.js";import{k as d}from"../../../../chunks/sphere.js";import{project as c}from"../../../../geometry/support/meshUtils/georeference.js";import{loadImageAsync as m}from"../../../../support/requestUtils.js";import{EncodedMeshTexture as h}from"../../glTF/internal/resourceUtils.js";import{TextureUsage as f,TextureEncoding as p}from"./enums.js";import{hasAdvancedMaterialParameters as g}from"./I3SMaterialUtil.js";import{CullFaceOptions as x}from"../../webgl-engine/lib/basicInterfaces.js";class y{constructor(e,t,o,n){this._id2Meta=new Map,this._oid2Meta=new Map,this._nextMeshNodeId=2,this._uid=e,this._indexSR=t,this._renderSR=o,this._memoryController=n,this._memCache=this._memoryController.newCache(`sl-client-mesh-data-${this._uid}`)}get indexSR(){return this._indexSR}get renderSR(){return this._renderSR}createMeshNodeInfo(e,t){const o="mesh"+this._nextMeshNodeId++,n=e.extent,s=n.spatialReference,a=this._indexSR,l=M(n,e.origin);r(l,s,l,a);return{type:"mesh",id:o,version:S(e),oid:t,mbs:l,componentNodeIds:[],unloadedMesh:e,nodeIndex:null,loadMeshPromise:null}}addMeshNode(e,t){t.nodeIndex=e,this._id2Meta.set(t.id,t),this._oid2Meta.set(t.oid,t)}getMeshNodeIndex(e){const t=this._oid2Meta.get(e);return null==t||"mesh"!==t.type?null:t.nodeIndex}removeNode(e){if(null==e)return;const t=this._id2Meta.get(e);null!=t&&(this._id2Meta.delete(e),"mesh"===t.type&&this._oid2Meta.delete(t.oid))}async loadNodeJSON(e){const o=this._id2Meta.get(e);if(null==o)throw new t(`I3SClientNodeLoader::loadNodeJSON unable to find node ${e}`);switch(o.type){case"mesh":return this._loadMeshNodeJSON(o);case"mesh-component":return this._loadMeshComponentNodeJSON(o);default:throw new t(`I3SClientNodeLoader::loadNodeJSON unable to handle node ${e}`)}}async _loadMeshNodeJSON(e){const t=e.id,o=(await this._getMeshData(e)).loadedMesh;if(null==o.components||0===o.components.length)return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null};const n=[],r=o.components;for(let s=0;s<r.length;++s){const o=`${t}-component${s}`,r={type:"mesh-component",id:o,mbs:e.mbs,componentIndex:s,meshNodeInfo:e,textureData:new Map};this._id2Meta.set(r.id,r),e.componentNodeIds.push(o),n.push({id:r.id,href:null,mbs:r.mbs,obb:null})}return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:n}}updateNodeIndex(e,t,o){if(null==e)return;const n=this._id2Meta.get(e);n&&"mesh"===n.type&&(n.nodeIndex=o)}async _loadMeshComponentNodeJSON(e){return{id:e.id,version:e.meshNodeInfo.version,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null,isEmpty:!1}}async loadNodeData(e,o){const n=e.id,r=this._id2Meta.get(n);if(null==r||"mesh-component"!==r.type)throw new t(`Failed to load client node data for node ${e.id} (unexpected node info)`);const a=r.meshNodeInfo,l=await this._getMeshData(a),i=l.loadedMesh,d=a.oid;if(null==i.components)throw new t(`Failed to load client node data for node ${e.id} (unexpected null reference)`);const m=i.components[r.componentIndex],{material:h,requiredTextures:f,textureData:p}=await w(m.material);if(null!=p)for(const t of p)null!=t&&r.textureData.set(t.id,t);const g={params:{material:h},type:"ArrayBufferView"},{vertexSpace:x,origin:y,transform:M}=i,b=y.x,I=y.y,_=y.z??0,T={featureDataPosition:[b,I,_],featureIds:[],geometries:[g]},S={attributeData:{},loadedAttributes:[]};let v=null;if(null==l.projectedVertices){const e=i.vertexAttributes.position;x.isRelative?v=c(i.spatialReference,M,x,e,this._indexSR):(v=u(e.length),s(e,i.spatialReference,0,v,this._indexSR,0,v.length/3));for(let t=0;t<v.length;t+=3)v[t]-=b,v[t+1]-=I,v[t+2]-=_;l.projectedVertices=v,l.usedMemoryInBytes+=8*v.length,this._memCache.updateSize(a.version,l,l.usedMemoryInBytes)}else v=l.projectedVertices;const{geometryBuffer:R,geometryDescriptor:D}=N(v,m.faces,i.vertexAttributes.normal,i.vertexAttributes.uv,i.vertexAttributes.color,d);return{geometryData:T,attributeDataInfo:S,geometryBuffer:R,geometryDescriptor:D,requiredTextures:f,textureData:p}}async loadTextures(e,t,o){const n=e.id,r=this._id2Meta.get(n);if(null==r||"mesh-component"!==r.type)throw new Error(`Failed to load textures for node ${e.id} (unexpected node info)`);const s=[];for(const a of t)s.push(r.textureData.get(a.id)||null);return s}async _getMeshData(e){const t=e.version,n=this._memCache.get(t);if(null==n){if(null!=e.loadMeshPromise)return e.loadMeshPromise;const n=async(n,r)=>{const s=e.unloadedMesh.clone();try{await s.load()}catch(c){r(c)}s.vertexSpace.isRelative||a(s.spatialReference,this._indexSR)||l()||await i();const u=s.memoryUsage,d={loadedMesh:s,projectedVertices:null,usedMemoryInBytes:u};this._memCache.put(t,d,u,o),e.loadMeshPromise=null,n(d)};return e.loadMeshPromise=new Promise(((e,t)=>n(e,t))),e.loadMeshPromise}return n}}function M(e,t){const o=[1,-1],n=[.5*e.width,.5*e.height,e.hasZ?.5*(e.zmax-e.zmin):0],r=e.center;let s=0;if(e.hasZ)for(let a=0;a<2;++a)for(let e=0;e<2;++e)for(let l=0;l<2;++l){const i=r.x+o[a]*n[0]-t.x,u=r.y+o[e]*n[1]-t.y,d=r.z+o[l]*n[2]-t.z;s=Math.max(i*i+u*u+d*d,s)}else for(let a=0;a<2;++a)for(let e=0;e<2;++e){const l=r.x+o[a]*n[0]-t.x,i=r.y+o[e]*n[1]-t.y;s=Math.max(l*l+i*i,s)}return d([t.x,t.y,t.z],Math.sqrt(s))}async function w(t){const o=[],n=[];if(null==t){return{material:{alphaMode:"opaque",alphaCutoff:.1,doubleSided:!0,cullFace:0,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[1,1,1,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6000000238418579},wrapTextures:!1,hasParametersFromSource:!0},requiredTextures:o,textureData:n}}const r=_(t);"auto"===t.alphaMode&&console.warn('alphaMode "auto" not supported by I3S PBRMaterial - defaulting to "blend".');return{material:{alphaMode:"auto"===t.alphaMode?"blend":t.alphaMode,alphaCutoff:t.alphaCutoff,doubleSided:t.doubleSided,cullFace:t.doubleSided?x.None:x.Back,normalTextureId:await b(t.normalTexture,o,n,f.Normal),emissiveTextureId:r?await b(t.emissiveTexture,o,n,f.Emissive):-1,occlusionTextureId:r?await b(t.occlusionTexture,o,n,f.Occlusion):-1,emissiveFactor:r&&null!=t.emissiveColor?e.toUnitRGB(t.emissiveColor):[0,0,0],metallicRoughness:{baseColorFactor:null!=t.color?e.toUnitRGBA(t.color):[1,1,1,1],baseColorTextureId:await b(t.colorTexture,o,n,f.Color),metallicRoughnessTextureId:r?await b(t.metallicRoughnessTexture,o,n,f.MetallicRoughness):-1,metallicFactor:r?t.metallic:0,roughnessFactor:r?t.roughness:0},wrapTextures:!0,hasParametersFromSource:!g({normalTexture:t.normalTexture,emissiveTexture:r?t.emissiveTexture:null,occlusionTexture:r?t.occlusionTexture:null,metallicRoughnessTexture:r?t.metallicRoughnessTexture:null,metallicFactor:r?t.metallic:null,roughnessFactor:r?t.roughness:null})},requiredTextures:o,textureData:n}}async function b(e,o,n,r){if(null==e)return-1;const s=n.length,a=e.data,l=e.url;if(null!=a){if(a instanceof HTMLImageElement||a instanceof HTMLCanvasElement){const{data:e,downsampled:t}=I(a);return n.push({id:s,usage:r,data:e,encoding:p.PNG,downsampled:t}),o.push({id:s,usage:r,encodings:[{name:void 0,encoding:p.PNG}]}),s}if(a instanceof HTMLVideoElement)return-1;if(a instanceof ImageData)throw new t("ImageData textures not supported yet for client side I3S nodes");if(a instanceof h)throw new t("EncodedMeshTexture textures not supported yet for client side I3S nodes")}else if(null!=l){const e=new Image;e.src=l;const t=await m(e,e.src,!1,void 0),{data:a,downsampled:i}=I(t);return n.push({id:s,usage:r,data:a,encoding:p.PNG,downsampled:i}),o.push({id:s,usage:r,encodings:[{name:void 0,encoding:p.PNG}]}),s}return-1}function I(e){const t=1048576,o=4096,n=2;let r=e.width*e.height;if(r>=o){let o=e.width,s=e.height;do{o=Math.ceil(o/n),s=Math.ceil(s/n),r=o*s}while(r>t);const a=document.createElement("canvas");a.width=o,a.height=s;return a.getContext("2d").drawImage(e,0,0,o,s),{data:a,downsampled:!0}}return{data:e,downsampled:!1}}function _(e){return e.hasOwnProperty("metallicRoughnessTexture")}function N(e,t,o,n,r,s){const a=1,l=t.length/3,i=3*l;let u=0,d=0,c=!1,m=0,h=!1,f=0,p=!1,g=0,x=0,y=0;u+=v,u+=v,d=u,u+=3*i*R,null!=o&&(c=!0,m=u,u+=3*i*R),null!=n&&(h=!0,f=u,u+=2*i*R),null!=r&&(p=!0,g=u,u+=4*i*D),x=u,u+=a*C,y=u,u+=2*a*v;const M=new ArrayBuffer(u),w=new Uint8Array(M);T(w,0,i),T(w,v,a);const b=new Float32Array(M,d),I=null!=o?new Float32Array(M,m):null,_=null!=n?new Float32Array(M,f):null,N=null!=r?new Uint8Array(M,g):null;for(let T=0;T<l;++T){const s=3*T;for(let a=0;a<3;++a){const l=t[s+a],i=3*l,u=9*T+3*a;if(b[u]=e[i],b[u+1]=e[i+1],b[u+2]=e[i+2],null!=I&&(I[u]=o[i],I[u+1]=o[i+1],I[u+2]=o[i+2]),null!=_){const e=2*l,t=6*T+2*a;_[t]=n[e],_[t+1]=n[e+1]}if(null!=N){const e=4*l,t=12*T+4*a;N[t]=r[e],N[t+1]=r[e+1],N[t+2]=r[e+2],N[t+3]=r[e+3]}}}T(w,x,s),T(w,x+v,s/2**32),T(w,y,0),T(w,y+v,l-1);return{geometryBuffer:M,geometryDescriptor:{isDraco:!1,isLegacy:!0,color:p,normal:c,uv0:h,uvRegion:!1,featureIndex:!0}}}function T(e,t,o){e[t]=255&o,e[t+1]=255&o>>8,e[t+2]=255&o>>16,e[t+3]=255&o>>24}function S(e){const t=e.metadata.displaySource?.source;if(null==t||!Array.isArray(t)||!t.length||t[0]instanceof File)return n();const o=t;let r="";for(const n of o)r+=n.makeHash();return r+JSON.stringify(null!=e.transform?e.transform.toJSON():"")}const v=4,R=4,D=1,C=8;export{y as I3SClientNodeLoader,N as createGeometryData};
|
|
5
|
+
import e from"../../../../Color.js";import t from"../../../../core/Error.js";import{MIN_PRIORITY as o}from"../../../../core/MemCache.js";import{generateUUID as n}from"../../../../core/uuid.js";import{projectBoundingSphere as r,projectBuffer as s,canProjectWithoutEngine as a,isLoaded as l,load as i}from"../../../../geometry/projection.js";import{newDoubleArray as u}from"../../../../geometry/support/DoubleArray.js";import{k as d}from"../../../../chunks/sphere.js";import{project as c}from"../../../../geometry/support/meshUtils/georeference.js";import{loadImageAsync as m}from"../../../../support/requestUtils.js";import{EncodedMeshTexture as h}from"../../glTF/internal/resourceUtils.js";import{TextureUsage as f,TextureEncoding as p}from"./enums.js";import{CullFaceOptions as g}from"../../webgl-engine/lib/basicInterfaces.js";import{useSchematicPBR as x}from"../../webgl-engine/materials/pbrUtils.js";class y{constructor(e,t,o,n){this._id2Meta=new Map,this._oid2Meta=new Map,this._nextMeshNodeId=2,this._uid=e,this._indexSR=t,this._renderSR=o,this._memoryController=n,this._memCache=this._memoryController.newCache(`sl-client-mesh-data-${this._uid}`)}get indexSR(){return this._indexSR}get renderSR(){return this._renderSR}createMeshNodeInfo(e,t){const o="mesh"+this._nextMeshNodeId++,n=e.extent,s=n.spatialReference,a=this._indexSR,l=M(n,e.origin);r(l,s,l,a);return{type:"mesh",id:o,version:T(e),oid:t,mbs:l,componentNodeIds:[],unloadedMesh:e,nodeIndex:null,loadMeshPromise:null}}addMeshNode(e,t){t.nodeIndex=e,this._id2Meta.set(t.id,t),this._oid2Meta.set(t.oid,t)}getMeshNodeIndex(e){const t=this._oid2Meta.get(e);return null==t||"mesh"!==t.type?null:t.nodeIndex}removeNode(e){if(null==e)return;const t=this._id2Meta.get(e);null!=t&&(this._id2Meta.delete(e),"mesh"===t.type&&this._oid2Meta.delete(t.oid))}async loadNodeJSON(e){const o=this._id2Meta.get(e);if(null==o)throw new t(`I3SClientNodeLoader::loadNodeJSON unable to find node ${e}`);switch(o.type){case"mesh":return this._loadMeshNodeJSON(o);case"mesh-component":return this._loadMeshComponentNodeJSON(o);default:throw new t(`I3SClientNodeLoader::loadNodeJSON unable to handle node ${e}`)}}async _loadMeshNodeJSON(e){const t=e.id,o=(await this._getMeshData(e)).loadedMesh;if(null==o.components||0===o.components.length)return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null};const n=[],r=o.components;for(let s=0;s<r.length;++s){const o=`${t}-component${s}`,r={type:"mesh-component",id:o,mbs:e.mbs,componentIndex:s,meshNodeInfo:e,textureData:new Map};this._id2Meta.set(r.id,r),e.componentNodeIds.push(o),n.push({id:r.id,href:null,mbs:r.mbs,obb:null})}return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:n}}updateNodeIndex(e,t,o){if(null==e)return;const n=this._id2Meta.get(e);n&&"mesh"===n.type&&(n.nodeIndex=o)}async _loadMeshComponentNodeJSON(e){return{id:e.id,version:e.meshNodeInfo.version,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null,isEmpty:!1}}async loadNodeData(e,o){const n=e.id,r=this._id2Meta.get(n);if(null==r||"mesh-component"!==r.type)throw new t(`Failed to load client node data for node ${e.id} (unexpected node info)`);const a=r.meshNodeInfo,l=await this._getMeshData(a),i=l.loadedMesh,d=a.oid;if(null==i.components)throw new t(`Failed to load client node data for node ${e.id} (unexpected null reference)`);const m=i.components[r.componentIndex],{material:h,requiredTextures:f,textureData:p}=await w(m.material);if(null!=p)for(const t of p)null!=t&&r.textureData.set(t.id,t);const g={params:{material:h},type:"ArrayBufferView"},{vertexSpace:x,origin:y,transform:M}=i,b=y.x,I=y.y,_=y.z??0,v={featureDataPosition:[b,I,_],featureIds:[],geometries:[g]},T={attributeData:{},loadedAttributes:[]};let S=null;if(null==l.projectedVertices){const e=i.vertexAttributes.position;x.isRelative?S=c(i.spatialReference,M,x,e,this._indexSR):(S=u(e.length),s(e,i.spatialReference,0,S,this._indexSR,0,S.length/3));for(let t=0;t<S.length;t+=3)S[t]-=b,S[t+1]-=I,S[t+2]-=_;l.projectedVertices=S,l.usedMemoryInBytes+=8*S.length,this._memCache.updateSize(a.version,l,l.usedMemoryInBytes)}else S=l.projectedVertices;const{geometryBuffer:R,geometryDescriptor:D}=N(S,m.faces,i.vertexAttributes.normal,i.vertexAttributes.uv,i.vertexAttributes.color,d);return{geometryData:v,attributeDataInfo:T,geometryBuffer:R,geometryDescriptor:D,requiredTextures:f,textureData:p}}async loadAttributes(e,t,o){const n=e.numFeatures;for(const{field:{name:r}}of t)new Array(n);return{}}async loadTextures(e,t,o){const n=e.id,r=this._id2Meta.get(n);if(null==r||"mesh-component"!==r.type)throw new Error(`Failed to load textures for node ${e.id} (unexpected node info)`);const s=[];for(const a of t)s.push(r.textureData.get(a.id)||null);return s}async _getMeshData(e){const t=e.version,n=this._memCache.get(t);if(null==n){if(null!=e.loadMeshPromise)return e.loadMeshPromise;const n=async(n,r)=>{const s=e.unloadedMesh.clone();try{await s.load()}catch(c){r(c)}s.vertexSpace.isRelative||a(s.spatialReference,this._indexSR)||l()||await i();const u=s.memoryUsage,d={loadedMesh:s,projectedVertices:null,usedMemoryInBytes:u};this._memCache.put(t,d,u,o),e.loadMeshPromise=null,n(d)};return e.loadMeshPromise=new Promise(((e,t)=>n(e,t))),e.loadMeshPromise}return n}}function M(e,t){const o=[1,-1],n=[.5*e.width,.5*e.height,e.hasZ?.5*(e.zmax-e.zmin):0],r=e.center;let s=0;if(e.hasZ)for(let a=0;a<2;++a)for(let e=0;e<2;++e)for(let l=0;l<2;++l){const i=r.x+o[a]*n[0]-t.x,u=r.y+o[e]*n[1]-t.y,d=r.z+o[l]*n[2]-t.z;s=Math.max(i*i+u*u+d*d,s)}else for(let a=0;a<2;++a)for(let e=0;e<2;++e){const l=r.x+o[a]*n[0]-t.x,i=r.y+o[e]*n[1]-t.y;s=Math.max(l*l+i*i,s)}return d([t.x,t.y,t.z],Math.sqrt(s))}async function w(t){const o=[],n=[];if(null==t){return{material:{alphaMode:"opaque",alphaCutoff:.1,doubleSided:!0,cullFace:0,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[1,1,1,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6000000238418579},wrapTextures:!1,hasParametersFromSource:!0},requiredTextures:o,textureData:n}}const r=_(t);"auto"===t.alphaMode&&console.warn('alphaMode "auto" not supported by I3S PBRMaterial - defaulting to "blend".');return{material:{alphaMode:"auto"===t.alphaMode?"blend":t.alphaMode,alphaCutoff:t.alphaCutoff,doubleSided:t.doubleSided,cullFace:t.doubleSided?g.None:g.Back,normalTextureId:await b(t.normalTexture,o,n,f.Normal),emissiveTextureId:r?await b(t.emissiveTexture,o,n,f.Emissive):-1,occlusionTextureId:r?await b(t.occlusionTexture,o,n,f.Occlusion):-1,emissiveFactor:r&&null!=t.emissiveColor?e.toUnitRGB(t.emissiveColor):[0,0,0],metallicRoughness:{baseColorFactor:null!=t.color?e.toUnitRGBA(t.color):[1,1,1,1],baseColorTextureId:await b(t.colorTexture,o,n,f.Color),metallicRoughnessTextureId:r?await b(t.metallicRoughnessTexture,o,n,f.MetallicRoughness):-1,metallicFactor:r?t.metallic:0,roughnessFactor:r?t.roughness:0},wrapTextures:!0,hasParametersFromSource:x({normalTexture:t.normalTexture,emissiveTexture:r?t.emissiveTexture:null,emissiveFactor:r?e.toUnitRGBA(t.emissiveColor):null,occlusionTexture:r?t.occlusionTexture:null,metallicRoughnessTexture:r?t.metallicRoughnessTexture:null,metallicFactor:r?t.metallic:null,roughnessFactor:r?t.roughness:null})},requiredTextures:o,textureData:n}}async function b(e,o,n,r){if(null==e)return-1;const s=n.length,a=e.data,l=e.url;if(null!=a){if(a instanceof HTMLImageElement||a instanceof HTMLCanvasElement){const{data:e,downsampled:t}=I(a);return n.push({id:s,usage:r,data:e,encoding:p.PNG,downsampled:t}),o.push({id:s,usage:r,encodings:[{name:void 0,encoding:p.PNG}]}),s}if(a instanceof HTMLVideoElement)return-1;if(a instanceof ImageData)throw new t("ImageData textures not supported yet for client side I3S nodes");if(a instanceof h)throw new t("EncodedMeshTexture textures not supported yet for client side I3S nodes")}else if(null!=l){const e=new Image;e.src=l;const t=await m(e,e.src,!1,void 0),{data:a,downsampled:i}=I(t);return n.push({id:s,usage:r,data:a,encoding:p.PNG,downsampled:i}),o.push({id:s,usage:r,encodings:[{name:void 0,encoding:p.PNG}]}),s}return-1}function I(e){const t=1048576,o=4096,n=2;let r=e.width*e.height;if(r>=o){let o=e.width,s=e.height;do{o=Math.ceil(o/n),s=Math.ceil(s/n),r=o*s}while(r>t);const a=document.createElement("canvas");a.width=o,a.height=s;return a.getContext("2d").drawImage(e,0,0,o,s),{data:a,downsampled:!0}}return{data:e,downsampled:!1}}function _(e){return e.hasOwnProperty("metallicRoughnessTexture")}function N(e,t,o,n,r,s){const a=1,l=t.length/3,i=3*l;let u=0,d=0,c=!1,m=0,h=!1,f=0,p=!1,g=0,x=0,y=0;u+=S,u+=S,d=u,u+=3*i*R,null!=o&&(c=!0,m=u,u+=3*i*R),null!=n&&(h=!0,f=u,u+=2*i*R),null!=r&&(p=!0,g=u,u+=4*i*D),x=u,u+=a*C,y=u,u+=2*a*S;const M=new ArrayBuffer(u),w=new Uint8Array(M);v(w,0,i),v(w,S,a);const b=new Float32Array(M,d),I=null!=o?new Float32Array(M,m):null,_=null!=n?new Float32Array(M,f):null,N=null!=r?new Uint8Array(M,g):null;for(let v=0;v<l;++v){const s=3*v;for(let a=0;a<3;++a){const l=t[s+a],i=3*l,u=9*v+3*a;if(b[u]=e[i],b[u+1]=e[i+1],b[u+2]=e[i+2],null!=I&&(I[u]=o[i],I[u+1]=o[i+1],I[u+2]=o[i+2]),null!=_){const e=2*l,t=6*v+2*a;_[t]=n[e],_[t+1]=n[e+1]}if(null!=N){const e=4*l,t=12*v+4*a;N[t]=r[e],N[t+1]=r[e+1],N[t+2]=r[e+2],N[t+3]=r[e+3]}}}v(w,x,s),v(w,x+S,s/2**32),v(w,y,0),v(w,y+S,l-1);return{geometryBuffer:M,geometryDescriptor:{isDraco:!1,isLegacy:!0,color:p,normal:c,uv0:h,uvRegion:!1,featureIndex:!0}}}function v(e,t,o){e[t]=255&o,e[t+1]=255&o>>8,e[t+2]=255&o>>16,e[t+3]=255&o>>24}function T(e){const t=e.metadata.displaySource?.source;if(null==t||!Array.isArray(t)||!t.length||t[0]instanceof File)return n();const o=t;let r="";for(const n of o)r+=n.makeHash();return r+JSON.stringify(null!=e.transform?e.transform.toJSON():"")}const S=4,R=4,D=1,C=8;export{y as I3SClientNodeLoader,N as createGeometryData};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"../../../../core/has.js";import{clamp as e}from"../../../../core/mathUtils.js";import{TextureEncoding as
|
|
5
|
+
import has from"../../../../core/has.js";import{clamp as e}from"../../../../core/mathUtils.js";import{TextureEncoding as a,TextureUsage as o}from"./enums.js";import{RenderTexture as r}from"../../webgl-engine/core/material/RenderTexture.js";import{PBRSchematicMRRValues as s}from"../../webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{defaultMaskAlphaCutoff as l}from"../../webgl-engine/core/shaderLibrary/util/AlphaCutoff.js";import{getEllipsoidMode as t}from"../../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{TextureEncodingMimeType as n,CullFaceOptions as i,AlphaDiscardMode as u}from"../../webgl-engine/lib/basicInterfaces.js";import{Texture as c}from"../../webgl-engine/lib/Texture.js";import{useSchematicPBR as m}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as d}from"../../../webgl/enums.js";function g(e,a){const r=new Map,l=(e,a)=>{if(null==e)return-1;const o=r.get(e.id);if(o)return o.usage|=a,o.id;const s=r.size;return r.set(e.id,{id:s,usage:a}),s},t=a.pbrMetallicRoughness,n=t?.baseColorFactor,u=a.emissiveFactor,c=m({normalTexture:a.normalTexture,emissiveTexture:a.emissiveTexture,emissiveFactor:a.emissiveFactor,occlusionTexture:a.occlusionTexture,metallicRoughnessTexture:t?.metallicRoughnessTexture,metallicFactor:t?.metallicFactor,roughnessFactor:t?.roughnessFactor}),d=c?s[0]:t?.metallicFactor??1,g=c?s[1]:t?.roughnessFactor??1,f="mask"===a.alphaMode?o.Color|o.AlphaMask:o.Color,T={baseColorFactor:n?[n[0],n[1],n[2],n[3]]:[1,1,1,1],baseColorTextureId:l(t&&t.baseColorTexture,f),metallicRoughnessTextureId:l(t&&t.metallicRoughnessTexture,o.MetallicRoughness),metallicFactor:d,roughnessFactor:g},x={alphaMode:a.alphaMode,alphaCutoff:a.alphaCutoff,doubleSided:a.doubleSided,cullFace:"none"===a.cullFace?i.None:"back"===a.cullFace?i.Back:"front"===a.cullFace?i.Front:i.None,normalTextureId:l(a.normalTexture,o.Normal),emissiveTextureId:l(a.emissiveTexture,o.Emissive),occlusionTextureId:l(a.occlusionTexture,o.Occlusion),emissiveFactor:u?[u[0],u[1],u[2]]:[0,0,0],metallicRoughness:T,wrapTextures:!1,hasParametersFromSource:c},b=[];return r.forEach((({usage:a},o)=>{const r=null!=e&&e[o]&&e[o].formats,s=r?p(r.map((({name:e,format:a})=>({name:e,encoding:h[a]})))):[];b.push({id:o,usage:a,encodings:s})})),{material:x,textures:b}}function p(e){return e.sort(((e,a)=>e.encoding-a.encoding))}const h={ktx2:a.KTX2,basis:a.Basis,dds:a.DDS_S3TC,png:a.PNG,jpg:a.JPG,"ktx-etc2":a.KTX_ETC2},f={[n.KTX2_ENCODING]:a.Basis,[n.BASIS_ENCODING]:a.Basis,[n.DDS_ENCODING]:a.DDS_S3TC,"image/png":a.PNG,"image/jpg":a.JPG,"image/jpeg":a.JPG,"image/ktx":a.KTX_ETC2};function T(a){const r=a&&a.materialDefinitions?Object.keys(a.materialDefinitions)[0]:null,s=a&&a.textureDefinitions?Object.keys(a.textureDefinitions)[0]:null,l=r?a.materialDefinitions?.[r]:null,t=s?a.textureDefinitions?.[s]:null,n=x();if(null!=l){const a=l.params;a.diffuse&&(n.metallicRoughness.baseColorFactor=[a.diffuse[0],a.diffuse[1],a.diffuse[2],1]),null!=a.doubleSided&&(n.doubleSided=a.doubleSided,n.cullFace=a.doubleSided?i.None:i.Back),"none"!==a.cullFace&&"front"!==a.cullFace&&"back"!==a.cullFace||(n.cullFace="none"===a.cullFace?i.None:"back"===a.cullFace?i.Back:i.Front),a.transparency&&(n.metallicRoughness.baseColorFactor[3]=e(1-a.transparency,0,1)),(a.useVertexColorAlpha||n.metallicRoughness.baseColorFactor[3]<1)&&(n.alphaMode="blend")}const u=[];if(null!=t){const e=0;!t.wrap||"repeat"!==t.wrap[0]&&"repeat"!==t.wrap[1]||(n.wrapTextures=!0);let a=o.Color;"rgba"===t.channels&&(n.alphaMode="blend",a|=o.AlphaMask);const r=t.images.length-1,s=t.images[r],l=e=>e&&e.split("/").pop(),i=Array.isArray(t.encoding)?p(t.encoding.map(((e,a)=>({name:l(s.href[a]),encoding:f[e]||0})))):[{name:l(s.href),encoding:f[t.encoding]||0}];u.push({id:e,usage:a,encodings:i}),n.metallicRoughness.baseColorTextureId=e}return{material:n,textures:u}}const x=()=>({alphaMode:"opaque",alphaCutoff:l,doubleSided:!0,cullFace:i.None,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[.8,.8,.8,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6},wrapTextures:!1,hasParametersFromSource:!0});function b(e,a,r,s){if(null==e||null==e.data)return null;const l=e.data,t=s.renderingContext.parameters.maxMaxAnisotropy,n=!e.downsampled&&t>1,i=r||!a.wrapTextures?F:C,u=R(e.encoding),m=e.usage&o.Color?"opaque"===a.alphaMode?3:4:3;return new c(l,{mipmap:n,maxAnisotropy:t,encoding:u,wrap:i,components:m,noUnpackFlip:!0})}const F={s:d.CLAMP_TO_EDGE,t:d.CLAMP_TO_EDGE},C={s:d.REPEAT,t:d.REPEAT};function P(a,s,n,i,c,m){const d=m.rendererTextureUsage,g=e=>D(i,n,e&d),p=s.metallicRoughness.baseColorFactor,h=e(s.metallicRoughness.baseColorFactor[3],0,1);a.baseColor=[p[0],p[1],p[2],h],a.hasParametersFromSource=!!s.hasParametersFromSource,a.usePBR=m.usePBR,a.mrrFactors=[s.metallicRoughness.metallicFactor,s.metallicRoughness.roughnessFactor,s.hasParametersFromSource?.2:.5],a.emissiveFactor=s.emissiveFactor,a.isIntegratedMesh=m.isIntegratedMesh,a.textureAlphaCutoff="mask"===s.alphaMode?s.alphaCutoff:l,a.alphaDiscardMode="opaque"===s.alphaMode?u.Opaque:"mask"===s.alphaMode?u.Mask:u.MaskBlend;const f=[],T=g(o.Color|o.AlphaMask);null!=T&&(a.baseColorTexture=new r(c,T),f.push(a.baseColorTexture.loadPromise));const x=g(o.MetallicRoughness);null!=x&&(a.metallicRoughnessTexture=new r(c,x),f.push(a.metallicRoughnessTexture.loadPromise));const b=g(o.Emissive);null!=b&&(a.emissionTexture=new r(c,b),f.push(a.emissionTexture.loadPromise));const F=g(o.Occlusion);null!=F&&(a.occlusionTexture=new r(c,F),f.push(a.occlusionTexture.loadPromise));const C=g(o.Normal);return null!=C&&(a.normalTexture=new r(c,C),f.push(a.normalTexture.loadPromise)),a.commonMaterialParameters.hasSlicePlane=m.slicePlaneEnabled,a.commonMaterialParameters.doubleSided=s.doubleSided,a.commonMaterialParameters.cullFace=s.cullFace,a.ellipsoidMode=t(m.viewSpatialReference),Promise.all(f)}function S(e){const o=!!e.compressedTextureS3TC,r=!!e.compressedTextureETC,s=has("disable-feature:i3s-basis")?0:a.Basis|a.KTX2,l=a.JPG|a.PNG,t=s|a.DDS_S3TC;return l|(o?t:0)|(r?s:0)}function M(e,a){if(null!=a)return e.find((e=>0!=(e.encoding&a)))}function D(e,a,r){if(null==e||r===o.None)return null;for(let o=0;o<e.length;o++){const s=e[o];if(null!=s&&0!=(s.usage&r)){const e=a[o];return null!=e?e.id:null}}return null}function R(e){switch(e){case a.KTX2:return n.KTX2_ENCODING;case a.Basis:return n.BASIS_ENCODING;case a.DDS_S3TC:return n.DDS_ENCODING;case a.PNG:return"image/png";case a.JPG:return"image/jpeg";case a.KTX_ETC2:return"image/ktx";default:return""}}export{P as configureMaterial,b as createTexture,x as defaultMaterial,g as getMaterialAndTextures,T as getMaterialAndTexturesFromShared,S as getSupportedEncodings,M as selectEncoding};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../request.js";import s from"../../../../core/Accessor.js";import{splitIntoChunks as i}from"../../../../core/arrayUtils.js";import{resultOrAbort as r,result as o}from"../../../../core/asyncUtils.js";import{estimateStringByteSize as n,estimateNumberByteSize as a}from"../../../../core/byteSizeEstimations.js";import d from"../../../../core/Collection.js";import c from"../../../../core/Logger.js";import{destroyMaybe as h,abortMaybe as l}from"../../../../core/maybe.js";import{whenOrAbort as u}from"../../../../core/promiseUtils.js";import{watch as m,initial as g}from"../../../../core/reactiveUtils.js";import{property as y}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/has.js";import{subclass as p}from"../../../../core/accessorSupport/decorators/subclass.js";import{formatNumber as _}from"../../../../intl/number.js";import{getMaximumQuerySize as b,queryAllJSON as f}from"../../../../layers/support/featureQueryAll.js";import{assetMapFromAssetMapsJSON as O,extractMesh as C}from"../../../../rest/support/meshFeatureSet.js";import{direct3DObjectFeatureLayerDisplayEnabled as j,i3sPatchingEnabled as v,sceneLayerEditingEnabled as I}from"../../../../support/featureFlags.js";import F from"../FeatureLayerView3D.js";let A=class extends s{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this._maximumNumberOfEditOVerrides=x,this._original3DOFLDefinitionExpression=null,this._interactiveEditingSessions=new d,this.geometryOverrides=new d,this._clientGeometryCache=new Map,this._associatedLayerView=null,this._attributeChangedObjectIds=new Set,this._geometryChangedObjectIds=new Set,this._pendingFetchChangedObjectIds=null,this._pendingFetchAbortController=new AbortController}initialize(){this._memCache=this.memoryController.newCache(`i3s-attribute-overrides-${this.layer.uid}`),this._pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this._pendingFetchAbortController?.signal),this._pendingFetchChangedObjectIds.then((async()=>{this._pendingFetchAbortController=null,this._pendingFetchChangedObjectIds=null})),this.is3DOFL&&null!=this._associatedLayer&&(j()?this._associatedLayer.load().then((e=>{this.destroyed||(this._original3DOFLDefinitionExpression=e.definitionExpression,this.addHandles(m((()=>this._definitionExpression),(t=>e.definitionExpression=t),g)),this._associatedLayerView=new F({layer:this._associatedLayer,view:this.view}))})):v())}destroy(){this.is3DOFL&&null!=this._associatedLayer&&(j()?null!=this._associatedLayerView&&(this._associatedLayer.definitionExpression=this._original3DOFLDefinitionExpression):v()),this._set("layer",null),this._memCache=h(this._memCache),this._pendingFetchAbortController=l(this._pendingFetchAbortController),this._pendingFetchChangedObjectIds=null}get is3DOFL(){return I()&&null!=this._associatedLayer&&null!=this._associatedLayer.infoFor3D}get sortedGeometryChangedObjectIds(){return this.is3DOFL?[...this._geometryChangedObjectIds].sort(((e,t)=>e-t)):[]}get _associatedLayer(){return null==this.layer?null:this.layer.associatedLayer}get _definitionExpression(){const e=this.sortedGeometryChangedObjectIds;return 0===e.length?"1 = 0":`OBJECTID IN (${e.join(",")})`}get updating(){if(!this.is3DOFL)return!1;if(j()){return!(null!=this._associatedLayerView)||null!=this._associatedLayerView&&this._associatedLayerView.updating}return v(),!1}get isEmpty(){return null==this._pendingFetchChangedObjectIds&&0===this._attributeChangedObjectIds.size&&0===this._geometryChangedObjectIds.size}createInteractiveEditSession(e){this._attributeChangedObjectIds.add(e),this.notifyChange("_attributeChangedObjectIds");const t=I()&&v()&&null!=this.is3DOFL,s=this._clientGeometryCache.get(e),i=this._interactiveEditingSessions,r=new L(e,{rollback:()=>{i.remove(r),t&&s?.mesh&&this.updateGeometry(e,s.mesh)},commit:(s,i)=>{for(const[t,r]of s)this.updateAttributeValue(e,t,r);t&&void 0!==i&&this.updateGeometry(e,i)}});return i.unshift(r),r}async applyAttributeOverrides(e,t,s){if(null==t)return;const{loadedAttributes:i,attributeData:r}=t;if(null==i||0===i.length||null==r)return;if(this._pendingFetchChangedObjectIds&&await u(this._pendingFetchChangedObjectIds,s),0===this._attributeChangedObjectIds.size)return;const o={loadedAttributes:i,attributeData:r},n=this._getOverridesFromCache(e,o,this._attributeChangedObjectIds),{objectIds:a,fieldNames:d}=n;if(0===a.length||0===d.length)return;const c=await this._queryOverridesFromAssociatedLayer(a,d,!1,s);null!=c&&this._processOverridesFromAssociatedLayer(e,c,d,o)}updateGeometry(e,t){this._geometryChangedObjectIds.add(e);const s=this._clientGeometryCache.get(e);if(null!=s&&(this.geometryOverrides.remove(s),this._clientGeometryCache.delete(e)),null!=t){const s={oid:e,mesh:t};this.geometryOverrides.add(s),this._clientGeometryCache.set(e,s)}this.notifyChange("_geometryChangedObjectIds")}updateAttributeValue(e,t,s){this._attributeChangedObjectIds.add(e),this._cacheAttributeValue(e,t,s),this.notifyChange("_attributeChangedObjectIds")}_cacheAttributeValue(e,t,s){this._memCache.put(this._getAttributeCacheKey(e,t),s,this._memCacheAttributeValueSize(s))}_cacheGeometry(e,t){this._memCache.put(this._getGeometryCacheKey(e),t,this._memCacheGeometrySize(t))}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:s},i){const r=new Set,o=new Array;if(this.is3DOFL&&0===Object.keys(s).length)return{objectIds:Array.from(e),fieldNames:t.map((e=>e.name))};for(const a of t)o[a.index]=s[a.name];const n=new Set;for(let a=0;a<e.length;a++){const s=e[a];if(i.has(s))for(const e of t){const t=this._attributeFromCache(s,e.index);void 0===t?(r.add(s),n.add(e.name)):o[e.index][a]=t}}return{objectIds:Array.from(r),fieldNames:Array.from(n)}}_attributeFromCache(e,t){const s=this._fromInteractiveEditingSession(e,t);if(void 0!==s)return s;const i=this._getAttributeCacheKey(e,t);return this._memCache.get(i)}_fromInteractiveEditingSession(e,t){if(null!=this._interactiveEditingSessions)for(const s of this._interactiveEditingSessions){if(s.objectId!==e)continue;const i=s.getAttribute(t);if(void 0!==i)return i}}_getAttributeCacheKey(e,t){return`${e}-${t}`}_getGeometryCacheKey(e){return`${e}-geometry`}async _queryOverridesFromAssociatedLayer(e,t,s,o){if(0===e.length||!1===s&&0===t.length)return null;e=e.sort(((e,t)=>e-t)),this._warnMaximumChangedObjectsExceeded&&(this._warnMaximumChangedObjectsExceeded=!1,this._logMaximumObjectsExceededWarning());const n=this.layer.associatedLayer;if(null==n)return null;const a=s&&this.is3DOFL&&v(),d=[n.objectIdField,...t];a&&null!=n.globalIdField&&d.push(n.globalIdField);const c=n.createQuery();c.where="1=1",c.returnGeometry=s,c.outFields=d,c.cacheHint=!0,c.objectIds=e;const h=b(n),l=e.length>h?i(e,h).map((e=>{const t=c.clone();return t.objectIds=e,r(f(n,t,{signal:o}))})):[r(f(n,c,{signal:o}))],u=await Promise.all(l);if(a&&null!=n.infoFor3D){const e=n.infoFor3D,t=n.spatialReference,s=[];for(const i of u){if(!i.ok)continue;const r=i.value;if(null==r.assetMaps)continue;const o=O(e,r.assetMaps);for(const i of r.features){const n=C(i,r.globalIdFieldName,t,e,o),a=i;null!=n?(a.geometry=n,s.push(a)):a.geometry=null}}return s}return u.reduce(((e,t)=>e.concat(t.ok?t.value.features:[])),[])}_logMaximumObjectsExceededWarning(){let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${_(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`;const t=this.layer.portalItem;t&&t.loaded?e+=` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:e+=` (${this.layer.parsedUrl.path})`,c.getLogger("esri.views.3d.layers.i3s.I3SOverrides").warn("#queryOverrides()",this.layer.title,`${e}.`)}_processOverridesFromAssociatedLayer(e,t,s,{loadedAttributes:i,attributeData:r}){const o=this._associatedLayer;if(null==o)return;const n=o.objectIdField,a=s.map((t=>(t in r||(r[t]=new Array(e.length)),r[t]))),d=new Map(i.map((e=>[e.name,e.index]))),c=s.map((e=>d.get(e))),h=new Map(Array.from(e,((e,t)=>[e,t])));for(const l of t){const e=l.attributes[n];for(let t=0;t<s.length;t++){const i=c[t],r=h.get(e),o=l.attributes[s[t]];a[t][r]=o,this._cacheAttributeValue(e,i,o)}}}_memCacheAttributeValueSize(e){return"string"==typeof e?n(e):a()}_memCacheGeometrySize(e){return 256}async _fetchChangedObjectIds(e){const s=this.layer;await s.load({signal:e}),this._geometryChangedObjectIds.clear(),this._attributeChangedObjectIds.clear();const{associatedLayer:i}=s;if(null==i||!i.capabilities?.operations?.supportsChangeTracking)return;const r=this._getFetchChangedObjectIdsServerGen();if(null==r)return;const n=i.layerId,a=this.is3DOFL,d={f:"json",returnIdsOnly:!0,layers:`[${n}]`,returnUpdates:!0,returnDeletes:a,returnInserts:a,layerServerGens:JSON.stringify([{id:n,serverGen:r}])};if(a){const e=i.infoFor3D;d.fieldsToCompare=JSON.stringify({fields:[...Object.values(e.transformFieldRoles),e.sourceHashField]})}const c=await o(t(`${i.url}/extractChanges`,{method:"post",query:d,timeout:w,signal:e}));if(c.ok&&1===c.value.data?.edits?.length){const t=c.value.data.edits[0],s=t?.objectIds,r=t?.fieldUpdates,o=s?.adds??[],n=s?.updates??[],a=s?.deletes??[],d=[...o,...n,...a],h=[...o,...r??n,...a],l=Math.min(this._maximumNumberOfEditOVerrides,d.length);l<d.length&&(this._warnMaximumChangedObjectsExceeded=!0);const u=d.sort(((e,t)=>e-t));for(let e=0;e<l;++e){const t=u[e];this._attributeChangedObjectIds.add(t)}for(const e of h)this._geometryChangedObjectIds.add(e);if(this.is3DOFL&&v()&&this._geometryChangedObjectIds.size>0){const t=await this._queryOverridesFromAssociatedLayer(Array.from(this._geometryChangedObjectIds),[],!0,e);if(null!=t)for(const e of t)null!=e.geometry&&this.updateGeometry(e.attributes[i.objectIdField],e.geometry)}}this.notifyChange("_attributeChangedObjectIds"),this.notifyChange("_geometryChangedObjectIds")}_getFetchChangedObjectIdsServerGen(){const e=this.layer;if(null!=e.serviceUpdateTimeStamp&&null!=e.serviceUpdateTimeStamp.lastUpdate)return e.serviceUpdateTimeStamp.lastUpdate;const t=e.associatedLayer;return null!=t&&null!=t.serverGens&&null!=t.serverGens.minServerGen?t.serverGens.minServerGen:null}get test(){const e=Array.from(this._attributeChangedObjectIds),t=this._pendingFetchChangedObjectIds,s=this;return{changedObjectIds:e,pendingFetchChangedObjectIds:t,get maximumNumberOfEditOVerrides(){return s._maximumNumberOfEditOVerrides},set maximumNumberOfEditOVerrides(e){s._maximumNumberOfEditOVerrides=e}}}};e([y({constructOnly:!0})],A.prototype,"view",void 0),e([y({constructOnly:!0})],A.prototype,"layer",void 0),e([y({readOnly:!0})],A.prototype,"is3DOFL",null),e([y()],A.prototype,"_interactiveEditingSessions",void 0),e([y({readOnly:!0})],A.prototype,"sortedGeometryChangedObjectIds",null),e([y({readOnly:!0})],A.prototype,"geometryOverrides",void 0),e([y()],A.prototype,"_clientGeometryCache",void 0),e([y()],A.prototype,"_associatedLayer",null),e([y()],A.prototype,"_associatedLayerView",void 0),e([y({constructOnly:!0})],A.prototype,"memoryController",void 0),e([y()],A.prototype,"_attributeChangedObjectIds",void 0),e([y()],A.prototype,"_geometryChangedObjectIds",void 0),e([y()],A.prototype,"_pendingFetchChangedObjectIds",void 0),e([y()],A.prototype,"_definitionExpression",null),e([y()],A.prototype,"updating",null),e([y()],A.prototype,"isEmpty",null),A=e([p("esri.views.3d.layers.i3s.I3SOverrides")],A);class L{constructor(e,t){this.objectId=e,this._options=t,this._updates=new Map,this._updatedGeometry=void 0,this._state=E.ACTIVE}getAttribute(e){return this._updates.get(e)}setAttribute(e,t){this.isActive&&this._updates.set(e,t)}getGeometry(){return this._updatedGeometry}setGeometry(e){this.isActive&&(this._updatedGeometry=e)}rollback(){this.isActive&&(this._state=E.ROLLED_BACK,this._options.rollback(),this._updatedGeometry=void 0)}commit(){this.isActive&&(this._state=E.COMMITTED,this._options.commit(this._updates,this._updatedGeometry),this._updates.clear(),this._updatedGeometry=void 0)}get isActive(){return this._state===E.ACTIVE}}var E;!function(e){e[e.ACTIVE=0]="ACTIVE",e[e.COMMITTED=1]="COMMITTED",e[e.ROLLED_BACK=2]="ROLLED_BACK"}(E||(E={}));const w=1e4,x=5e4;export{A as I3SOverrides};
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../request.js";import s from"../../../../core/Accessor.js";import{splitIntoChunks as i}from"../../../../core/arrayUtils.js";import{resultOrAbort as r,result as o}from"../../../../core/asyncUtils.js";import{estimateStringByteSize as n,estimateNumberByteSize as a}from"../../../../core/byteSizeEstimations.js";import d from"../../../../core/Collection.js";import c from"../../../../core/Logger.js";import{destroyMaybe as h,abortMaybe as l}from"../../../../core/maybe.js";import{whenOrAbort as u}from"../../../../core/promiseUtils.js";import{watch as m,initial as g}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/has.js";import{subclass as y}from"../../../../core/accessorSupport/decorators/subclass.js";import{formatNumber as _}from"../../../../intl/number.js";import{getMaximumQuerySize as b,queryAllJSON as f}from"../../../../layers/support/featureQueryAll.js";import{assetMapFromAssetMapsJSON as O,extractMesh as C}from"../../../../rest/support/meshFeatureSet.js";import{direct3DObjectFeatureLayerDisplayEnabled as j,i3sPatchingEnabled as I,sceneLayerEditingEnabled as v}from"../../../../support/featureFlags.js";import F from"../FeatureLayerView3D.js";let A=class extends s{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this._maximumNumberOfEditOVerrides=x,this._original3DOFLDefinitionExpression=null,this._interactiveEditingSessions=new d,this.geometryOverrides=new d,this._clientGeometryCache=new Map,this._associatedLayerView=null,this._attributeChangedObjectIds=new Set,this._geometryChangedObjectIds=new Set,this._pendingFetchChangedObjectIds=null,this._pendingFetchAbortController=new AbortController}initialize(){this._memCache=this.memoryController.newCache(`i3s-attribute-overrides-${this.layer.uid}`),this._pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this._pendingFetchAbortController?.signal),this._pendingFetchChangedObjectIds.then((async()=>{this._pendingFetchAbortController=null,this._pendingFetchChangedObjectIds=null})),this.is3DOFL&&null!=this._associatedLayer&&(j()?this._associatedLayer.load().then((e=>{this.destroyed||(this._original3DOFLDefinitionExpression=e.definitionExpression,this.addHandles(m((()=>this._definitionExpression),(t=>e.definitionExpression=t),g)),this._associatedLayerView=new F({layer:this._associatedLayer,view:this.view}))})):I())}destroy(){this.is3DOFL&&null!=this._associatedLayer&&(j()?null!=this._associatedLayerView&&(this._associatedLayer.definitionExpression=this._original3DOFLDefinitionExpression):I()),this._set("layer",null),this._memCache=h(this._memCache),this._pendingFetchAbortController=l(this._pendingFetchAbortController),this._pendingFetchChangedObjectIds=null}get is3DOFL(){return v()&&null!=this._associatedLayer&&null!=this._associatedLayer.infoFor3D}get sortedGeometryChangedObjectIds(){return this.is3DOFL?[...this._geometryChangedObjectIds].sort(((e,t)=>e-t)):[]}get _associatedLayer(){return null==this.layer?null:this.layer.associatedLayer}get _definitionExpression(){const e=this.sortedGeometryChangedObjectIds;return 0===e.length?"1 = 0":`OBJECTID IN (${e.join(",")})`}get updating(){if(!this.is3DOFL)return!1;if(j()){return!(null!=this._associatedLayerView)||null!=this._associatedLayerView&&this._associatedLayerView.updating}return I(),!1}get isEmpty(){return null==this._pendingFetchChangedObjectIds&&0===this._attributeChangedObjectIds.size&&0===this._geometryChangedObjectIds.size}createInteractiveEditSession(e){this._attributeChangedObjectIds.add(e),this.notifyChange("_attributeChangedObjectIds");const t=v()&&I()&&null!=this.is3DOFL,s=this._interactiveEditingSessions,i=new L(e,{rollback:()=>{s.remove(i)},commit:(s,i)=>{for(const[t,r]of s)this.updateAttributeValue(e,t,r);t&&null!=i&&this.updateGeometry(e,i)}});return s.unshift(i),i}async applyAttributeOverrides(e,t,s){if(null==t)return;const{loadedAttributes:i,attributeData:r}=t;if(null==i||0===i.length||null==r)return;if(this._pendingFetchChangedObjectIds&&await u(this._pendingFetchChangedObjectIds,s),0===this._attributeChangedObjectIds.size)return;const o={loadedAttributes:i,attributeData:r},n=this._getOverridesFromCache(e,o,this._attributeChangedObjectIds),{objectIds:a,fieldNames:d}=n;if(0===a.length||0===d.length)return;const c=await this._queryOverridesFromAssociatedLayer(a,d,!1,s);null!=c&&this._processOverridesFromAssociatedLayer(e,c,d,o)}updateGeometry(e,t){this._geometryChangedObjectIds.add(e);const s=this._clientGeometryCache.get(e);if(null!=s&&(this.geometryOverrides.remove(s),this._clientGeometryCache.delete(e)),null!=t){const s={oid:e,mesh:t};this.geometryOverrides.add(s),this._clientGeometryCache.set(e,s)}this.notifyChange("_geometryChangedObjectIds")}updateAttributeValue(e,t,s){this._attributeChangedObjectIds.add(e),this._cacheAttributeValue(e,t,s),this.notifyChange("_attributeChangedObjectIds")}_cacheAttributeValue(e,t,s){this._memCache.put(this._getAttributeCacheKey(e,t),s,this._memCacheAttributeValueSize(s))}_cacheGeometry(e,t){this._memCache.put(this._getGeometryCacheKey(e),t,this._memCacheGeometrySize(t))}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:s},i){const r=new Set,o=new Array;if(this.is3DOFL&&0===Object.keys(s).length)return{objectIds:Array.from(e),fieldNames:t.map((e=>e.name))};for(const a of t)o[a.index]=s[a.name];const n=new Set;for(let a=0;a<e.length;a++){const s=e[a];if(i.has(s))for(const e of t){const t=this._attributeFromCache(s,e.index);void 0===t?(r.add(s),n.add(e.name)):o[e.index][a]=t}}return{objectIds:Array.from(r),fieldNames:Array.from(n)}}_attributeFromCache(e,t){const s=this._fromInteractiveEditingSession(e,t);if(void 0!==s)return s;const i=this._getAttributeCacheKey(e,t);return this._memCache.get(i)}_fromInteractiveEditingSession(e,t){if(null!=this._interactiveEditingSessions)for(const s of this._interactiveEditingSessions){if(s.objectId!==e)continue;const i=s.getAttribute(t);if(void 0!==i)return i}}_getAttributeCacheKey(e,t){return`${e}-${t}`}_getGeometryCacheKey(e){return`${e}-geometry`}async _queryOverridesFromAssociatedLayer(e,t,s,o){if(0===e.length||!1===s&&0===t.length)return null;e=e.sort(((e,t)=>e-t)),this._warnMaximumChangedObjectsExceeded&&(this._warnMaximumChangedObjectsExceeded=!1,this._logMaximumObjectsExceededWarning());const n=this.layer.associatedLayer;if(null==n)return null;const a=s&&this.is3DOFL&&I(),d=[n.objectIdField,...t];a&&null!=n.globalIdField&&d.push(n.globalIdField);const c=n.createQuery();c.where="1=1",c.returnGeometry=s,c.outFields=d,c.cacheHint=!0,c.objectIds=e;const h=b(n),l=e.length>h?i(e,h).map((e=>{const t=c.clone();return t.objectIds=e,r(f(n,t,{signal:o}))})):[r(f(n,c,{signal:o}))],u=await Promise.all(l);if(a&&null!=n.infoFor3D){const e=n.infoFor3D,t=n.spatialReference,s=[];for(const i of u){if(!i.ok)continue;const r=i.value;if(null==r.assetMaps)continue;const o=O(e,r.assetMaps);for(const i of r.features){const n=C(i,r.globalIdFieldName,t,e,o),a=i;null!=n?(a.geometry=n,s.push(a)):a.geometry=null}}return s}return u.reduce(((e,t)=>e.concat(t.ok?t.value.features:[])),[])}_logMaximumObjectsExceededWarning(){let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${_(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`;const t=this.layer.portalItem;t&&t.loaded?e+=` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:e+=` (${this.layer.parsedUrl.path})`,c.getLogger("esri.views.3d.layers.i3s.I3SOverrides").warn("#queryOverrides()",this.layer.title,`${e}.`)}_processOverridesFromAssociatedLayer(e,t,s,{loadedAttributes:i,attributeData:r}){const o=this._associatedLayer;if(null==o)return;const n=o.objectIdField,a=s.map((t=>(t in r||(r[t]=new Array(e.length)),r[t]))),d=new Map(i.map((e=>[e.name,e.index]))),c=s.map((e=>d.get(e))),h=new Map(Array.from(e,((e,t)=>[e,t])));for(const l of t){const e=l.attributes[n];for(let t=0;t<s.length;t++){const i=c[t],r=h.get(e),o=l.attributes[s[t]];a[t][r]=o,this._cacheAttributeValue(e,i,o)}}}_memCacheAttributeValueSize(e){return"string"==typeof e?n(e):a()}_memCacheGeometrySize(e){return 256}async _fetchChangedObjectIds(e){const s=this.layer;await s.load({signal:e}),this._geometryChangedObjectIds.clear(),this._attributeChangedObjectIds.clear();const{associatedLayer:i}=s;if(null==i||!i.capabilities?.operations?.supportsChangeTracking)return;const r=this._getFetchChangedObjectIdsServerGen();if(null==r)return;const n=i.layerId,a=this.is3DOFL,d={f:"json",returnIdsOnly:!0,layers:`[${n}]`,returnUpdates:!0,returnDeletes:a,returnInserts:a,layerServerGens:JSON.stringify([{id:n,serverGen:r}])};if(a){const e=i.infoFor3D;d.fieldsToCompare=JSON.stringify({fields:[...Object.values(e.transformFieldRoles),e.sourceHashField]})}const c=await o(t(`${i.url}/extractChanges`,{method:"post",query:d,timeout:w,signal:e}));if(c.ok&&1===c.value.data?.edits?.length){const t=c.value.data.edits[0],s=t?.objectIds,r=t?.fieldUpdates,o=s?.adds??[],n=s?.updates??[],a=s?.deletes??[],d=[...o,...n,...a],h=[...o,...r??n,...a],l=Math.min(this._maximumNumberOfEditOVerrides,d.length);l<d.length&&(this._warnMaximumChangedObjectsExceeded=!0);const u=d.sort(((e,t)=>e-t));for(let e=0;e<l;++e){const t=u[e];this._attributeChangedObjectIds.add(t)}for(const e of h)this._geometryChangedObjectIds.add(e);if(this.is3DOFL&&I()&&this._geometryChangedObjectIds.size>0){const t=await this._queryOverridesFromAssociatedLayer(Array.from(this._geometryChangedObjectIds),[],!0,e);if(null!=t)for(const e of t)null!=e.geometry&&this.updateGeometry(e.attributes[i.objectIdField],e.geometry)}}this.notifyChange("_attributeChangedObjectIds"),this.notifyChange("_geometryChangedObjectIds")}_getFetchChangedObjectIdsServerGen(){const e=this.layer;if(null!=e.serviceUpdateTimeStamp&&null!=e.serviceUpdateTimeStamp.lastUpdate)return e.serviceUpdateTimeStamp.lastUpdate;const t=e.associatedLayer;return null!=t&&null!=t.serverGens&&null!=t.serverGens.minServerGen?t.serverGens.minServerGen:null}get test(){const e=Array.from(this._attributeChangedObjectIds),t=this._pendingFetchChangedObjectIds,s=this;return{changedObjectIds:e,pendingFetchChangedObjectIds:t,get maximumNumberOfEditOVerrides(){return s._maximumNumberOfEditOVerrides},set maximumNumberOfEditOVerrides(e){s._maximumNumberOfEditOVerrides=e}}}};e([p({constructOnly:!0})],A.prototype,"view",void 0),e([p({constructOnly:!0})],A.prototype,"layer",void 0),e([p({readOnly:!0})],A.prototype,"is3DOFL",null),e([p()],A.prototype,"_interactiveEditingSessions",void 0),e([p({readOnly:!0})],A.prototype,"sortedGeometryChangedObjectIds",null),e([p({readOnly:!0})],A.prototype,"geometryOverrides",void 0),e([p()],A.prototype,"_clientGeometryCache",void 0),e([p()],A.prototype,"_associatedLayer",null),e([p()],A.prototype,"_associatedLayerView",void 0),e([p({constructOnly:!0})],A.prototype,"memoryController",void 0),e([p()],A.prototype,"_attributeChangedObjectIds",void 0),e([p()],A.prototype,"_geometryChangedObjectIds",void 0),e([p()],A.prototype,"_pendingFetchChangedObjectIds",void 0),e([p()],A.prototype,"_definitionExpression",null),e([p()],A.prototype,"updating",null),e([p()],A.prototype,"isEmpty",null),A=e([y("esri.views.3d.layers.i3s.I3SOverrides")],A);class L{constructor(e,t){this.objectId=e,this._options=t,this._updates=new Map,this._updatedGeometry=void 0,this._state=E.ACTIVE}getAttribute(e){return this._updates.get(e)}setAttribute(e,t){this.isActive&&this._updates.set(e,t)}getGeometry(){return this._updatedGeometry}setGeometry(e){this.isActive&&(this._updatedGeometry=e)}rollback(){this.isActive&&(this._state=E.ROLLED_BACK,this._options.rollback(),this._updatedGeometry=void 0)}commit(){this.isActive&&(this._state=E.COMMITTED,this._options.commit(this._updates,this._updatedGeometry),this._updates.clear(),this._updatedGeometry=void 0)}get isActive(){return this._state===E.ACTIVE}}var E;!function(e){e[e.ACTIVE=0]="ACTIVE",e[e.COMMITTED=1]="COMMITTED",e[e.ROLLED_BACK=2]="ROLLED_BACK"}(E||(E={}));const w=1e4,x=5e4;export{A as I3SOverrides};
|