@arcgis/core 5.1.0-next.57 → 5.1.0-next.59
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/applications/Components/SelectionOperation.d.ts +2 -2
- package/applications/Components/SelectionOperation.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/04ea806b933d4dd41609.js +1 -0
- package/assets/esri/core/workers/chunks/{278eecd729bed2832702.js → 0622e238693c257abacb.js} +1 -1
- package/assets/esri/core/workers/chunks/{05bc675c029ed311427f.js → 155c741a9839d24f04a2.js} +1 -1
- package/assets/esri/core/workers/chunks/1ae4e43a399e1974f106.js +1 -0
- package/assets/esri/core/workers/chunks/1f8e22df08c2f5fbb8c8.js +1 -0
- package/assets/esri/core/workers/chunks/{2327b368673a974dee8b.js → 2339465190c9d5ede25f.js} +1 -1
- package/assets/esri/core/workers/chunks/23f6d24bf850bc3280ec.js +1 -0
- package/assets/esri/core/workers/chunks/2541ac6e0ed1184edc9b.js +1 -0
- package/assets/esri/core/workers/chunks/34207774bc371e95ba3c.js +1 -0
- package/assets/esri/core/workers/chunks/{01777e91cd4e0bf04fd0.js → 35217befc8f9882d139e.js} +1 -1
- package/assets/esri/core/workers/chunks/{40bcfc4f8efe7de7ec9d.js → 3de17e89973160b42923.js} +1 -1
- package/assets/esri/core/workers/chunks/{992e74570b76f3f9e52e.js → 48d289db3145ce6c02bb.js} +1 -1
- package/assets/esri/core/workers/chunks/4c73c2f4331351e2a50c.js +1 -0
- package/assets/esri/core/workers/chunks/{2757cf54656b5d318b11.js → 55a0b69cf034ac32fc25.js} +1 -1
- package/assets/esri/core/workers/chunks/{4d54beab8ae5ff31e7b0.js → 5a9f5a49dc68b42762bb.js} +1 -1
- package/assets/esri/core/workers/chunks/{7cec3252e3ee56424b9e.js → 5c6e5f22450dd0583074.js} +1 -1
- package/assets/esri/core/workers/chunks/{b39b4db86a1049f0b901.js → 6be9d00839002f24fafd.js} +1 -1
- package/assets/esri/core/workers/chunks/6c886f19875291d02407.js +1 -0
- package/assets/esri/core/workers/chunks/75e28458e08b0738b35a.js +2 -0
- package/assets/esri/core/workers/chunks/{c460ca93ed8e20d8b53a.js → 86a6dd19903fa5023cc7.js} +1 -1
- package/assets/esri/core/workers/chunks/{4afddb66242438b38df0.js → 8ccf2f65d8ed3c48ffff.js} +1 -1
- package/assets/esri/core/workers/chunks/{fcfaaced184f8da3e28d.js → 9b53aa2429573f1b977f.js} +1 -1
- package/assets/esri/core/workers/chunks/9d580b5bcd59857a5702.js +1405 -0
- package/assets/esri/core/workers/chunks/a37697ef360e2425768a.js +1 -0
- package/assets/esri/core/workers/chunks/{a787fe09d3df9d4254ba.js → ab3183f2327ff26e2b45.js} +1 -1
- package/assets/esri/core/workers/chunks/b0f2ce61d3cad413898e.js +1 -0
- package/assets/esri/core/workers/chunks/{53c149bca42595b7dd1e.js → bbdf27bc34fadbe8e6fe.js} +1 -1
- package/assets/esri/core/workers/chunks/be42fe0b7ba0e27030b2.js +1 -0
- package/assets/esri/core/workers/chunks/d0c3ab70f390cd579fed.js +1 -0
- package/assets/esri/core/workers/chunks/{5a573fa1012092328b88.js → d816d1a4220d827faf63.js} +1 -1
- package/assets/esri/core/workers/chunks/e26894655823849947f4.js +1 -0
- package/assets/esri/core/workers/chunks/e59f5dc8c85bcea66e98.js +1 -0
- package/assets/esri/core/workers/chunks/{ccf845ac0ac354507a25.js → ec1b2eb05410848081c9.js} +1 -1
- package/assets/esri/core/workers/chunks/{851dd71d28681d4eccfd.js → f7af90c5f9d371eb7009.js} +1 -1
- package/assets/esri/core/workers/chunks/fa6e1ad099b43a6f5501.js +1 -0
- package/assets/esri/core/workers/chunks/{4a6186001323b47c23a4.js → fee1d873127dca02459f.js} +1 -1
- package/chunks/GlobalIllumination.glsl.js +101 -0
- package/chunks/GlobalIlluminationBlur.glsl.js +68 -0
- package/chunks/ScreenSpaceShadowHighlight.glsl.js +6 -0
- package/chunks/ShadowCastAccumulate.glsl.js +1 -1
- package/chunks/ShadowHighlight.glsl.js +15 -8
- package/config.js +1 -1
- package/geometry/Mesh.js +1 -1
- package/geometry/support/polygonUtils.js +1 -1
- package/geometry/support/{triangulationUtils.js → triangulationUtilsDeprecated.js} +1 -1
- package/kernel.js +1 -1
- package/layers/support/SceneModification.js +1 -1
- package/networks/support/jsonTypes.d.ts +6 -0
- package/package.json +2 -2
- package/renderers/ClassBreaksRenderer.js +1 -1
- package/renderers/DictionaryRenderer.js +1 -1
- package/renderers/DotDensityRenderer.js +1 -1
- package/renderers/HeatmapRenderer.js +1 -1
- package/renderers/PieChartRenderer.js +1 -1
- package/renderers/Renderer.js +1 -1
- package/renderers/SimpleRenderer.js +1 -1
- package/renderers/UniqueValueRenderer.js +1 -1
- package/renderers/support/AttributeColorInfo.js +1 -1
- package/renderers/support/ClassBreakInfo.d.ts +6 -0
- package/renderers/support/ClassBreakInfo.js +1 -1
- package/renderers/support/UniqueValueClass.d.ts +12 -0
- package/renderers/support/UniqueValueClass.js +1 -1
- package/renderers/support/UniqueValueInfo.d.ts +12 -0
- package/renderers/support/UniqueValueInfo.js +1 -1
- package/renderers/visualVariables/ColorVariable.js +1 -1
- package/renderers/visualVariables/OpacityVariable.js +1 -1
- package/renderers/visualVariables/SizeVariable.js +1 -1
- package/renderers/visualVariables/VisualVariable.js +1 -1
- package/rest/networks/support/FunctionResult.d.ts +6 -0
- package/rest/networks/support/FunctionResult.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
- package/views/2d/engine/vectorTiles/VTLPainter3D.js +1 -1
- package/views/2d/engine/webgl/GlyphMosaic.js +1 -1
- package/views/2d/engine/webgl/GlyphSource.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueFill.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/engine/webgl/util/IntervalMatcher.js +1 -1
- package/views/2d/engine/webgl/util/MapMatcher.js +1 -1
- package/views/2d/layers/features/schema/processor/MatcherSchema.js +1 -1
- package/views/2d/layers/features/schema/processor/SimpleProcessorSchema.js +1 -1
- package/views/3d/FocusAreasView.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
- package/views/3d/interactive/visualElements/MeasurementArrowVisualElement.js +1 -1
- package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
- package/views/3d/layers/Lyr3DWorker.js +1 -1
- package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/extrudeUtils.js +1 -1
- package/views/3d/layers/graphics/extrudeUtilsDeprecated.js +2 -0
- package/views/3d/layers/graphics/tessellationUtils.js +2 -0
- package/views/3d/layers/i3s/PointCloudHighlights.js +1 -1
- package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
- package/views/3d/layers/i3s/PointCloudRendererNode.js +1 -1
- package/views/3d/layers/support/Tiles3DBVH.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatDataStore.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatIntersectionHandler.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianTile.js +1 -1
- package/views/3d/support/renderInfoUtils/line.js +1 -1
- package/views/3d/support/renderInfoUtils/polygon.js +1 -1
- package/views/3d/support/renderInfoUtils/polygonDeprecated.js +2 -0
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/webgl/RenderNode.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentData.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/collections/Component/RenderGeometry.js +1 -1
- package/views/3d/webgl-engine/collections/Component/RenderSubmitSystem.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPass.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/output/ReadDepth.glsl.js +6 -5
- package/views/3d/webgl-engine/core/shaderLibrary/output/ReadDepthLastFrame.glsl.js +4 -0
- package/views/3d/webgl-engine/core/shaderLibrary/shading/EncodingColor.glsl.js +7 -0
- package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateAmbientLighting.glsl.js +6 -6
- package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +93 -72
- package/views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRendering.glsl.js +46 -22
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadGlobalIllumination.glsl.js +20 -0
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +18 -13
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceReflections.glsl.js +23 -9
- package/views/3d/webgl-engine/core/shaderLibrary/shading/WaterColor.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/CloudsParallaxShading.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/RenderPlugin.js +1 -1
- package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
- package/views/3d/webgl-engine/effects/emissive/emissions.js +2 -0
- package/views/3d/webgl-engine/effects/globalIllumination/BlueNoise.js +2 -0
- package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +2 -0
- package/views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationBlurTechnique.js +2 -0
- package/views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationTechnique.js +2 -0
- package/views/3d/webgl-engine/effects/globalIllumination/GlobalIlluminationTechniqueConfiguration.js +2 -0
- package/views/3d/webgl-engine/effects/highlight/ScreenSpaceShadowHighlight.glsl.js +2 -0
- package/views/3d/webgl-engine/effects/highlight/ScreenSpaceShadowHighlightRenderNode.js +2 -0
- package/views/3d/webgl-engine/effects/highlight/ScreenSpaceShadowHighlightTechnique.js +2 -0
- package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
- package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
- package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
- package/views/3d/webgl-engine/effects/transparency/OITBlend.js +1 -1
- package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
- package/views/3d/webgl-engine/lib/Material.js +1 -1
- package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
- package/views/3d/webgl-engine/lib/RenderFeature.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/ReprojectionUniforms.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodComponentData.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodLevel.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/WaterTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterialTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/shaders/GaussianSplatTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/shaders/GlobalIllumination.glsl.js +2 -0
- package/views/3d/webgl-engine/shaders/GlobalIlluminationBlur.glsl.js +2 -0
- package/views/3d/webgl-engine/shaders/MeasurementArrowTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/MeasurementArrowTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/shaders/ReceiveShadowsConfiguration.js +1 -1
- package/views/3d/webgl-engine/shaders/TerrainTechniqueConfiguration.js +1 -1
- package/views/3d/webgl.js +1 -1
- package/views/selection/SelectionOperation.d.ts +190 -0
- package/views/selection/SelectionOperation.js +2 -0
- package/views/selection/types.d.ts +146 -1
- package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/009db7b459b18f6a668b.js +0 -1
- package/assets/esri/core/workers/chunks/0fc60b4c44c4e865b699.js +0 -2
- package/assets/esri/core/workers/chunks/34484afe767d60f85982.js +0 -1
- package/assets/esri/core/workers/chunks/55bb5b7817c2963c8bfa.js +0 -1
- package/assets/esri/core/workers/chunks/572fcd33ae3648ed4f9c.js +0 -1
- package/assets/esri/core/workers/chunks/66a4d764937918a2779f.js +0 -1
- package/assets/esri/core/workers/chunks/6b56c8ba978ec6edd6b8.js +0 -1
- package/assets/esri/core/workers/chunks/9806cc96414065ae0afe.js +0 -1
- package/assets/esri/core/workers/chunks/9b365a6242b0287f8727.js +0 -1
- package/assets/esri/core/workers/chunks/a029db48079af4b5cccd.js +0 -1
- package/assets/esri/core/workers/chunks/ea068f75397c3b3337ec.js +0 -1034
- package/assets/esri/core/workers/chunks/ec91d5081f423755cb07.js +0 -1
- package/assets/esri/core/workers/chunks/f9fe89ced41b49608667.js +0 -1
- package/assets/esri/core/workers/chunks/fce30184f354fb7d11af.js +0 -1
- package/widgets/support/Selector2D/SelectionOperation.js +0 -2
- /package/assets/esri/core/workers/chunks/{0fc60b4c44c4e865b699.js.LICENSE.txt → 75e28458e08b0738b35a.js.LICENSE.txt} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{fromRotation as t,multiply as
|
|
2
|
+
import{fromRotation as t,multiply as e,translate as s,rotate as i}from"../../../../../../core/libs/gl-matrix-2/math/mat2d.js";import{create as n}from"../../../../../../core/libs/gl-matrix-2/factories/mat2df32.js";import{transformMat2d as o,set as h}from"../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as r}from"../../../../../../core/libs/gl-matrix-2/factories/vec2f32.js";import{getXAnchorDirection as a,getYAnchorDirection as f}from"../../alignmentUtils.js";import c from"../../Rect.js";import d from"../../collisions/BoundingBox.js";const l=22,m=4,g=l+m,u=l-6,x=Math.PI/180,p=8,_=1.5;class b{constructor(t,e,s,i){this._rotationT=n(),this._transform=n(),this._angle=0,this._bounds=null;const o=s.rect;t*=i,e*=i,this.width=0===s.code?s.metrics.width:o.width*i,this.height=0===s.code?s.metrics.height:o.height*i,this.x=t,this.y=e,this.textureBinding=s.textureBinding,this.texcoords={topLeft:[o.x,o.y],topRight:[o.x+o.width,o.y],bottomLeft:[o.x,o.y+o.height],bottomRight:[o.x+o.width,o.y+o.height]}}set angle(e){this._angle=e,t(this._rotationT,-e),this._offsets=this._bounds=null}get angle(){return this._angle}get offsets(){if(!this._offsets){const{x:s,y:i,width:h,height:r}=this,a=t(n(),-this.angle),f=e(n(),a,this._transform);this._offsets={topLeft:o([0,0],[s,i],f),topRight:o([0,0],[s+h,i],f),bottomLeft:o([0,0],[s,i+r],f),bottomRight:o([0,0],[s+h,i+r],f)}}return this._offsets}get bounds(){if(this.width<=0)return null;if(!this._bounds){const t=this.offsets;let e=1/0,s=1/0,i=-1/0,n=-1/0;for(const[f,c]of[t.topLeft,t.topRight,t.bottomLeft,t.bottomRight])e=Math.min(e,f),s=Math.min(s,c),i=Math.max(i,f),n=Math.max(n,c);const o=i-e,h=n-s,r=e+o/2,a=s+h/2;this._bounds=new d(r,a,o,h)}return this._bounds}setTransform(t){this._transform=t,this._offsets=null}}const w=(t,e)=>({code:0,page:0,sdf:!0,rect:new c(0,0,11,8),textureBinding:e,metrics:{advance:0,height:4,width:t,left:0,top:0}});function y(t,e){return t.forEach(t=>o(t,t,e)),{topLeft:t[0],topRight:t[1],bottomLeft:t[2],bottomRight:t[3]}}class M{constructor(t,e,s,i){this._rotation=0,this._decorate(t,e,s,i),this.glyphs=t,this.bounds=this._createBounds(t),this.isMultiline=e.length>1,this._hasRotation=0!==s.angle,this._transform=this._createGlyphTransform(this.bounds,s),this._borderLineSizePx=s.borderLineSizePx,(s.borderLineSizePx||s.hasBackground)&&([this.bounds,this.textBox]=this.shapeBackground(this._transform));for(const n of t)n.setTransform(this._transform)}setRotation(s){if(0===s&&0===this._rotation)return;this._rotation=s;const i=this._transform,o=t(n(),s);e(i,o,i);for(const t of this.glyphs)t.setTransform(this._transform)}_decorate(t,e,s,i){if(!s.decoration||"none"===s.decoration||!t.length)return;const n=s.scale,o="underline"===s.decoration?i?.baseline??g:i?.midline??u,h=t[0].textureBinding;for(const r of e){const e=r.startX*n,s=r.startY*n,i=(r.width+r.glyphWidthEnd)*n;t.push(new b(e,s+o*n,w(i,h),1))}}shapeBackground(t){const e=this._borderLineSizePx||0,s=(_+e)/2,i=this._borderLineSizePx?s:0,{xmin:n,ymin:o,xmax:h,ymax:r,x:a,y:f,width:c,height:l}=this.bounds,m=[n-p,o-p],g=[h+p,o-p],u=[n-p,r+p],x=[h+p,r+p],b=y([[m[0]-s,m[1]-s],[g[0]+s,g[1]-s],[m[0]+i,m[1]+i],[g[0]-i,g[1]+i]],t),w=y([[u[0]+i,u[1]-i],[x[0]-i,x[1]-i],[u[0]-s,u[1]+s],[x[0]+s,x[1]+s]],t),M=y([[m[0]-s,m[1]-s],[m[0]+i,m[1]+i],[u[0]-s,u[1]+s],[u[0]+i,u[1]-i]],t),L=y([[g[0]-i,g[1]+i],[g[0]+s,g[1]-s],[x[0]-i,x[1]-i],[x[0]+s,x[1]+s]],t),R={main:y([m,g,u,x],t),top:b,bot:w,left:M,right:L};return[new d(a,f,c+2*s,l+2*s),R]}get boundsT(){const t=this.bounds,e=h(r(),t.x,t.y);if(o(e,e,this._transform),this._hasRotation){const s=Math.max(t.width,t.height);return new d(e[0],e[1],s,s)}return new d(e[0],e[1],t.width,t.height)}_createBounds(t){let e=1/0,s=1/0,i=0,n=0;for(const r of t)e=Math.min(e,r.offsets.topLeft[0]),s=Math.min(s,r.offsets.topLeft[1]),i=Math.max(i,r.offsets.bottomRight[0]),n=Math.max(n,r.offsets.bottomRight[1]);const o=i-e,h=n-s;return new d(e+o/2,s+h/2,o,h)}_createGlyphTransform(t,e){const o=x*e.angle,a=n(),f=r();return s(a,a,h(f,e.xOffset,-e.yOffset)),e.useCIMAngleBehavior?i(a,a,o):(s(a,a,h(f,t.x,t.y)),i(a,a,o),s(a,a,h(f,-t.x,-t.y))),a}}class L{constructor(t,e,s,i,n,o){this.glyphWidthEnd=0,this.startX=0,this.startY=0,this.start=Math.max(0,Math.min(e,s)),this.end=Math.max(0,Math.max(e,s)),this.end<t.length&&(this.glyphWidthEnd=t[this.end].metrics.width),this.width=i,this.yMin=n,this.yMax=o}}const R=t=>10===t,B=t=>32===t;function v(t,e,s){const i=new Array,n=1/s.scale,o=s.maxLineWidth*n,h=e?t.length-1:0,r=e?-1:t.length,a=e?-1:1;let f=h,c=0,d=0,l=f,m=l,g=0,u=1/0,x=0;for(;f!==r;){const{code:e,metrics:s}=t[f],n=Math.abs(s.top);if(R(e)||B(e)||(u=Math.min(u,n),x=Math.max(x,n+s.height)),R(e))f!==h&&(i.push(new L(t,l,f-a,c,u===1/0?0:u,x)),u=1/0,x=0),c=0,l=f+a,m=f+a,d=0;else if(B(e))m=f+a,d=0,g=s.advance,c+=s.advance;else if(c>o){if(m!==l){const e=m-2*a;c-=g,i.push(new L(t,l,e,c-d,u,x)),u=1/0,x=0,l=m,c=d}else i.push(new L(t,l,f-a,c,u,x)),u=1/0,x=0,l=f,m=f,c=0;c+=s.advance,d+=s.advance}else c+=s.advance,d+=s.advance;f+=a}const p=new L(t,l,f-a,c,u,x);return p.start>=0&&p.end<t.length&&i.push(p),i}function T(t,e){let s=0;for(let o=0;o<t.length;o++){const{width:e}=t[o];s=Math.max(e,s)}const i="underline"===e.decoration?m:0,n=t[0].yMin;return{x:0,y:n,height:t[t.length-1].yMax+e.lineHeight*(t.length-1)+i-n,width:s}}function j(t,e){const s=e.scale,i=new Array,n=t.sdfPadding,{faceInfo:o,glyphs:h,isRightToLeft:r}=t,c=v(h,r,e),d=c.length?T(c,e):{y:0,height:0},m=a(e.horizontalAlignment),g=f(e.verticalAlignment),u=2===g?1:0,x=u?0:g-1,p=(1-u)*-d.y+x*(d.height/2)+u*-l;for(let a=0;a<c.length;a++){const{start:o,end:r,width:f}=c[a];let d=-1*(m+1)*(f/2)-n;const l=(t.isRightToLeft?c.length-1-a:a)*e.lineHeight+p-n;c[a].startX=d,c[a].startY=l;for(let t=o;t<=r;t++){const e=h[t];if(R(e.code))continue;const n=new b(d+e.metrics.left,l-e.metrics.top,e,s);d+=e.metrics.advance,i.push(n)}}return new M(i,c,e,o)}export{b as ShapedGlyph,M as ShapingInfo,j as shapeGlyphs};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{memoize as e}from"../../../../../../../core/MapUtils.js";import{pt2px as t}from"../../../../../../../core/screenUtils.js";import{numericHash as i}from"../../../../../../../core/string.js";import{fromRotation as r,translate as s}from"../../../../../../../core/libs/gl-matrix-2/math/mat2d.js";import{create as o}from"../../../../../../../core/libs/gl-matrix-2/factories/mat2df32.js";import{transformMat2d as n,set as a,sub as l,normalize as c,add as h,scale as m}from"../../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as u}from"../../../../../../../core/libs/gl-matrix-2/factories/vec2f32.js";import{create as d}from"../../../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{convertGeometryToFlat as f,convertOptimizedGeometryToFlat as g,convertFlatToOptimizedGeometry as p,FlatGeometry as _}from"../../../../../../../geometry/FlatGeometry.js";import{GeometryCursor as y}from"../../../../../../../geometry/GeometryCursor.js";import{getLabelPoint as x}from"../../../../../../../geometry/support/labelPoint.js";import{generalizeOptimizedGeometry as P,convertToGeometry as b}from"../../../../../../../layers/graphics/featureConversionUtils.js";import v from"../../../../../../../layers/graphics/OptimizedGeometry.js";import{importLazily as M}from"../../../../../../../symbols/cim/utils.js";import{tileSize as w,minMaxZoomPrecisionFactor as L}from"../../../definitions.js";import I from"../../../collisions/BoundingBox.js";import{LabelMetric as B}from"../../../collisions/LabelMetric.js";import{smoothPaths as S,pathDivide as z}from"../../../mesh/templates/segmentUtils.js";import{getMinMaxZoom as G,processColorInput as j}from"../fill/meshWriterUtils.js";import{TextMeshWriter as D,maxLabelZoom as A}from"../text/TextMeshWriter.js";const F=1,k=0,R=128,$=w*w/16,C=M(()=>import("../../../../../../../geometry/operators/gx/operatorIntersection.js")),O=M(()=>import("../../../../../../../chunks/FlatGeometry.js"));function E(e,t,r){return i(`${e}${t}${r}`)}function Z(e,t,r,s,o){return i(`${e}${t}${r}${s*2**(A-o)}`)}function T(e,t,r){return i(`${e}${t}${r}`)}function W(e,t,r,s,o){return i(`${e}${o}${t}${r*2**(A-s)}`)}const U=e(e=>{let t=0;if(0===e)return 1/0;for(;!(e%2);)t++,e/=2;return t});class X extends D{constructor(){super(...arguments),this._zoomLevel=0}async loadDependencies(){await Promise.all([super.loadDependencies(),C.getImportPromise(),O.getImportPromise()])}_write(e,t,i,r,s){if(this._zoomLevel=r||0,null!=i)throw new Error("InternalError: EffectGeometry not support for LabelMeshWriter");switch(t.geometryType){case"esriGeometryPoint":{const i=t.readXForDisplay(),r=t.readYForDisplay();this._writePoint(e,i,r,0,t);break}case"esriGeometryEnvelope":case"esriGeometryPolygon":this._writePolygon(e,t,s);break;case"esriGeometryMultipoint":{let i=0;const r=y.fromFeatureSetReader(t);if(r?.nextPath())for(;r.nextPoint();)this._writePoint(e,r.x,r.y,i++,t);break}case"esriGeometryPolyline":this._writeLines(e,t)}}_getMetricDir(){const{horizontalAlignment:e,verticalAlignment:t}=this.evaluatedMeshParams;return["center"===e?0:"right"===e?-1:1,"middle"===t?0:"bottom"===t?-1:1]}_createLineLabelMetric(e,t,i,r,s,o){const[n,a]=this._getMetricDir(),l=this.evaluatedMeshParams.scaleInfo?.maxScale??0,c=this.evaluatedMeshParams.scaleInfo?.minScale??0,h=this.evaluatedMeshParams.labelClassId;return new B(e,h,t,i,r,s,n,a,l,c,o)}_writePolygon(e,t,i){const r=C.module,s=O.module.constructFromFlatGeometry,o=t.readGeometryForDisplay(),n=t.readCentroidForDisplay()?.coords,a=o?.area()||0;if(!n)return;const l=a>=$;e.requiresRefresh||=l;const c=s(f(i)),h=s(f({x:n[0],y:n[1]})),m=!!r.execute(h,c,null);if(!o||!l||!m)return void this._writePoint(e,n[0],n[1],0,t);const u=s(g("polygon",o,null)),d=r.execute(u,c,null);if(!d)return void this._writePoint(e,n[0],n[1],0,t);const P=p(new _(d.toFlatGeometry())),b=y.fromOptimized(P,"esriGeometryPolygon",1),v=x(b)??n;this._writePoint(e,v[0],v[1],0,t)}_writePoint(e,t,i,r,s){if(t<0||t>w||i<0||i>w)return;const o=this._getShaping();if(!o)return;const n=s.getDisplayId(),a=this.evaluatedMeshParams.labelClassId,l=E(this.evaluatedMeshParams.layerId,s.getObjectId(),r),c=T(s.getObjectId(),a,r),[h,m]=this._getMetricDir(),u=this.evaluatedMeshParams.scaleInfo?.maxScale??0,d=this.evaluatedMeshParams.scaleInfo?.minScale??0,f=this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0};e.metricStart(new B(n,a,l,c,t,i,h,m,u,d,f)),this._writeGlyphs(e,n,t,i,o,0,f,void 0,!1),e.metricBoxWrite(o.boundsT),e.metricEnd()}_getPointReferenceBounds(){if(!this._references)return null;for(const e of this._references){const t=e.getBoundsInfo();if(t)return t}return null}_writeLines(e,t){const{scaleInfo:i,verticalAlignment:r}=this.evaluatedMeshParams,s=this.evaluatedMeshParams.repeatLabelDistance||128,o=this._getShaping("middle");if(!o)return;const n=(e,t,i,r)=>this._placeSubdivGlyphs(e,t,i,r),a=(o.bounds.width+s)/(1<<F);this._current={out:e,id:t.getDisplayId(),objId:t.getObjectId(),shaping:o,zoomRange:G(i,this.getTileInfo()),referenceBounds:this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0},offsetDirection:null,pathIndex:0},this._verticalPlacement="bottom"===r?"above":"top"===r?"below":null,this._verticalPlacement?this._writeAboveAndBelowAlong(t,n,a):this._writeCenterAlong(t,n,a)}_writeAboveAndBelowAlong(e,t,i){const{repeatLabel:r}=this.evaluatedMeshParams,{shaping:s}=this._current,o=s.bounds.halfHeight,n=e.readGeometryForDisplay();if(!n)return;const a=P(n,"esriGeometryPolyline",1)??new v,l=Y(a,o),c=Y(a,-o),h=b(c,"esriGeometryPolyline",!1,!1),m=b(l,"esriGeometryPolyline",!1,!1),u=S(m.paths,s.bounds.width),d=S(h.paths,s.bounds.width);this._current.offsetDirection="above";for(let f=0;f<u.length;f++)this._current.pathIndex=f,z(u[f],i,t,!!r);this._current.offsetDirection="below";for(let f=0;f<d.length;f++)this._current.pathIndex=f,z(d[f],i,t,!!r)}_writeCenterAlong(e,t,i){const{repeatLabel:r}=this.evaluatedMeshParams,{shaping:s}=this._current,o=S(e.readLegacyGeometryForDisplay().paths,s.bounds.width);for(let n=0;n<o.length;n++)this._current.pathIndex=n,z(o[n],i,t,!!r)}_placeSubdivGlyphs(e,t,i,r){const{allowOverrun:s,labelPosition:o,repeatLabelDistance:n,layerId:a,labelClassId:l}=this.evaluatedMeshParams,{objId:c,shaping:h,pathIndex:m}=this._current,u=this._current.zoomRange[0],d=U(t),f=this._current.shaping.bounds.width/(1<<F),g=Math.sqrt(n||R)/(1<<F),p=Math.min(i,r-i),_=h.isMultiline?A:Math.log2(p/(g+f/2)),y=0===t?_:Math.min(d,_),x=Math.max(u,this._zoomLevel+F-y),P=this._zoomLevel-x,b=h.bounds.width/2*2**P,v=Z(a,c,m,t,this._zoomLevel),M=W(c,m,t,this._zoomLevel,l);this._current.shaping.isMultiline?0===t&&this._placeStraight(e,x,v,M):s&&P<0?this._placeStraightAlong(e,u,v,M):"parallel"===o?this._placeStraightAlong(e,x,v,M):"curved"===o&&this._placeCurved(e,x,b,v,M)}_placeStraight(e,t,i,r){const{out:s,id:o,shaping:n,referenceBounds:a}=this._current,{x:l,y:c}=e;s.metricStart(this._createLineLabelMetric(o,i,r,l,c)),s.metricBoxWrite(n.boundsT);const h=e.angle*(180/Math.PI)%360,m=(e.angle*(180/Math.PI)+180)%360;if(!this._verticalPlacement||this._verticalPlacement===this._current.offsetDirection){const e={clipAngle:h,mapAligned:!0,isLineLabel:!0,minZoom:t};this._writeGlyphs(s,o,l,c,n,0,a,e,!1)}if(!this._verticalPlacement||this._verticalPlacement!==this._current.offsetDirection){const e={clipAngle:m,mapAligned:!0,isLineLabel:!0,minZoom:t};this._writeGlyphs(s,o,l,c,n,0,a,e,!1)}s.metricEnd()}_placeCurved(e,t,i,r,s){const{out:o,id:n}=this._current;o.metricStart(this._createLineLabelMetric(n,r,s,e.x,e.y));const a=e.clone(),l=e.angle*(180/Math.PI)%360,c=(e.angle*(180/Math.PI)+180)%360;this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||(this._placeFirst(a,t,1,l),this._placeBack(e,a,t,i,1,l),this._placeForward(e,a,t,i,1,l)),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||(this._placeFirst(a,t,0,c),this._placeBack(e,a,t,i,0,c),this._placeForward(e,a,t,i,0,c)),o.metricEnd()}_placeStraightAlong(e,i,n,a){const{out:l,id:c,shaping:h,zoomRange:m,referenceBounds:d}=this._current,{boxBorderLineColor:f,boxBackgroundColor:g}=this.evaluatedMeshParams,p=e.clone(),_=e.angle*(180/Math.PI)%360,y=(e.angle*(180/Math.PI)+180)%360,x=h.glyphs.length>0&&!(!f&&!g);if(l.metricStart(this._createLineLabelMetric(c,n,a,e.x,e.y)),x){const n=Math.max(i,m[0],0),a=Math.min(A,m[1]),f=r(o(),-e.angle),g={minZoom:n,maxZoom:a,clipAngle:_,mapAligned:!0,isLineLabel:!0},p=t(this.evaluatedMeshParams.offsetX),x=t(this.evaluatedMeshParams.offsetY);if(!this._verticalPlacement||this._verticalPlacement===this._current.offsetDirection){const t=u(p,-1*x),[i,r]=h.shapeBackground(s(o(),f,t));l.recordStart(this.instanceId,this.attributeLayout,h.glyphs[0].textureBinding),this._writeTextBox(l,c,e.x,e.y,r,d,g),l.recordEnd()}if(!this._verticalPlacement||this._verticalPlacement!==this._current.offsetDirection){const t=u(p,x),[i,r]=h.shapeBackground(s(o(),f,t));g.clipAngle=y,l.recordStart(this.instanceId,this.attributeLayout,h.glyphs[0].textureBinding),this._writeTextBox(l,c,e.x,e.y,r,d,g),l.recordEnd()}}this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||this._placeFirst(p,i,1,_,!0),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||this._placeFirst(p,i,0,y,!0),l.metricEnd()}_placeBack(e,t,i,r,s,o){const n=e.clone();let a=e.backwardLength+k;for(;n.prev()&&!(a>=r);)this._placeOnSegment(n,t,a,i,-1,s,o),a+=n.length+k}_placeForward(e,t,i,r,s,o){const n=e.clone();let a=e.remainingLength+k;for(;n.next()&&!(a>=r);)this._placeOnSegment(n,t,a,i,1,s,o),a+=n.length+k}_placeFirst(e,t,i,r,s=!1){const{out:o,id:n,shaping:a,zoomRange:l,referenceBounds:c}=this._current,h=a.glyphs,m=this._getBoundsOffset(e.angle);for(const u of h){const h=u.x>a.bounds.x?i:1-i,d=h*e.remainingLength+(1-h)*e.backwardLength,f=Math.abs(u.x+u.width/2-a.bounds.x),g=Math.max(0,this._zoomLevel+Math.log2(f/(d+k))),p=Math.max(t,s?0:g);u.angle=e.angle+(1-i)*Math.PI;const _=[Math.max(l[0],p),Math.min(l[1],A)];this._writeLineGlyph(o,n,e.x,e.y,u,_,r,c),this._writeLineGlyphBox(o,u.bounds,i,_,m)}}_placeOnSegment(e,t,i,r,s,o,n){const{out:a,id:l,shaping:c,referenceBounds:h}=this._current,m=c.glyphs,u=e.dx/e.length,d=e.dy/e.length,f={x:e.x+i*-s*u,y:e.y+i*-s*d},g=this._getBoundsOffset(e.angle);for(const p of m){const t=p.x>c.bounds.x?o:1-o;if(!(t&&1===s||!t&&-1===s))continue;const m=Math.abs(p.x+p.width/2-c.bounds.x),u=Math.max(0,this._zoomLevel+Math.log2(m/i)-.1),d=Math.max(r,this._zoomLevel+Math.log2(m/(i+e.length+k)));if(0===u)continue;p.angle=e.angle+(1-o)*Math.PI;const _=[d,u];this._writeLineGlyph(a,l,f.x,f.y,p,_,n,h),this._writeLineGlyphBox(a,p.bounds,o,_,g)}}_getBoundsOffset(e){const i=t(this.evaluatedMeshParams.offsetX),s=t(this.evaluatedMeshParams.offsetY),a=u(i,s),l=r(o(),-e);return n(a,a,l)}_writeLineGlyph(e,t,i,r,s,o,n,a){if(i<0||i>w||r<0||r>w)return;e.recordStart(this.instanceId,this.attributeLayout,s.textureBinding);const{texcoords:l,offsets:c}=s,{fontSize:h,haloSize:m,outlineSize:u}=this._textMeshTransformProps,{sdfSize:d,sdfRadius:f}=this.evaluatedMeshParams.glyphs;this._writeQuad(e,t,i,r,{sdfSize:d,sdfRadius:f,texcoords:l,offsets:c,fontSize:h,haloSize:m,outlineSize:u,color:j(this.evaluatedMeshParams.color),isBackground:!1,referenceBounds:a,minZoom:Math.max(this._current.zoomRange[0],o[0]),maxZoom:Math.min(this._current.zoomRange[1],o[1]),clipAngle:n,mapAligned:!0,isLineLabel:!0}),e.recordEnd()}_writeLineGlyphBox(e,t,i,r,s){if((i||this._current.offsetDirection)&&this._isVisible(r)){const i=new I(t.x+s[0],t.y+s[1],t.width,t.height);e.metricBoxWrite(i)}}_packedZoom(e){return Math.floor(e*L)/L}_isVisible(e){let t=Math.max(this._current.zoomRange[0],e[0]),i=Math.min(this._current.zoomRange[1],e[1]);t=this._packedZoom(t),i=this._packedZoom(i);const r=this._packedZoom(this._zoomLevel);return t<=r&&r<=i}}function Y(e,t){const i=new v,{coords:r,lengths:s}=e,o=d(),n=d(),u=d(),f=d(),g=d(),p=d(),_=2;let y=0;for(let d=0;d<s.length;d++){const e=s[d];for(let s=0;s<e;s++){const d=_*(s+y-1),x=_*(s+y),P=_*(s+y+1);s>0?a(o,r[d],r[d+1]):a(o,0,0),a(n,r[x],r[x+1]),s<e-1?a(u,r[P],r[P+1]):a(u,0,0),0===s?a(f,0,0):(l(f,n,o),c(f,f),a(f,f[1],-f[0])),s===e-1?a(g,0,0):(l(g,u,n),c(g,g),a(g,g[1],-g[0])),h(p,f,g),c(p,p);const b=p[0]*g[0]+p[1]*g[1];0!==b&&m(p,p,b),m(p,p,t),i.coords.push(n[0]+p[0],n[1]+p[1])}i.lengths.push(e),y+=e}return i}export{X as LabelMeshWriter,E as labelIdHash,T as labelMetricHash,Z as lineLabelIdHash,W as lineLabelMetricHash};
|
|
2
|
+
import{memoize as e}from"../../../../../../../core/MapUtils.js";import{pt2px as t}from"../../../../../../../core/screenUtils.js";import{numericHash as i}from"../../../../../../../core/string.js";import{fromRotation as r,translate as s}from"../../../../../../../core/libs/gl-matrix-2/math/mat2d.js";import{create as o}from"../../../../../../../core/libs/gl-matrix-2/factories/mat2df32.js";import{transformMat2d as n,set as a,sub as l,normalize as c,add as h,scale as m}from"../../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as u}from"../../../../../../../core/libs/gl-matrix-2/factories/vec2f32.js";import{create as d}from"../../../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{convertGeometryToFlat as f,convertOptimizedGeometryToFlat as g,convertFlatToOptimizedGeometry as p,FlatGeometry as _}from"../../../../../../../geometry/FlatGeometry.js";import{GeometryCursor as y}from"../../../../../../../geometry/GeometryCursor.js";import{getLabelPoint as x}from"../../../../../../../geometry/support/labelPoint.js";import{generalizeOptimizedGeometry as P,convertToGeometry as b}from"../../../../../../../layers/graphics/featureConversionUtils.js";import v from"../../../../../../../layers/graphics/OptimizedGeometry.js";import{importLazily as M}from"../../../../../../../symbols/cim/utils.js";import{tileSize as w,minMaxZoomPrecisionFactor as L}from"../../../definitions.js";import I from"../../../collisions/BoundingBox.js";import{LabelMetric as B}from"../../../collisions/LabelMetric.js";import{smoothPaths as S,pathDivide as z}from"../../../mesh/templates/segmentUtils.js";import{getMinMaxZoom as G,processColorInput as j}from"../fill/meshWriterUtils.js";import{TextMeshWriter as D,maxLabelZoom as A}from"../text/TextMeshWriter.js";const F=1,k=0,R=128,$=w*w/16,C=M(()=>import("../../../../../../../geometry/operators/gx/operatorIntersection.js")),O=M(()=>import("../../../../../../../chunks/FlatGeometry.js"));function E(e,t,r){return i(`${e}${t}${r}`)}function Z(e,t,r,s,o){return i(`${e}${t}${r}${s*2**(A-o)}`)}function T(e,t,r){return i(`${e}${t}${r}`)}function W(e,t,r,s,o){return i(`${e}${o}${t}${r*2**(A-s)}`)}const U=e(e=>{let t=0;if(0===e)return 1/0;for(;!(e%2);)t++,e/=2;return t});class X extends D{constructor(){super(...arguments),this._zoomLevel=0}async loadDependencies(){await Promise.all([super.loadDependencies(),C.getImportPromise(),O.getImportPromise()])}_write(e,t,i,r,s){if(this._zoomLevel=r||0,null!=i)throw new Error("InternalError: EffectGeometry not support for LabelMeshWriter");switch(t.geometryType){case"esriGeometryPoint":{const i=t.readXForDisplay(),r=t.readYForDisplay();this._writePoint(e,i,r,0,t);break}case"esriGeometryEnvelope":case"esriGeometryPolygon":this._writePolygon(e,t,s);break;case"esriGeometryMultipoint":{let i=0;const r=y.fromFeatureSetReader(t);if(r?.nextPath())for(;r.nextPoint();)this._writePoint(e,r.x,r.y,i++,t);break}case"esriGeometryPolyline":this._writeLines(e,t)}}_getMetricDir(){const{horizontalAlignment:e,verticalAlignment:t}=this.evaluatedMeshParams;return["center"===e?0:"right"===e?-1:1,"middle"===t?0:"bottom"===t?-1:1]}_createLineLabelMetric(e,t,i,r,s,o){const[n,a]=this._getMetricDir(),l=this.evaluatedMeshParams.scaleInfo?.maxScale??0,c=this.evaluatedMeshParams.scaleInfo?.minScale??0,h=this.evaluatedMeshParams.labelClassId;return new B(e,h,t,i,r,s,n,a,l,c,o)}_writePolygon(e,t,i){const r=C.module,s=O.module.constructFromFlatGeometry,o=t.readGeometryForDisplay(),n=t.readCentroidForDisplay()?.coords,a=o?.area()||0;if(!n)return;const l=a>=$;e.requiresRefresh||=l;const c=s(f(i)),h=s(f({x:n[0],y:n[1]})),m=!!r.execute(h,c,null);if(!o||!l||!m)return void this._writePoint(e,n[0],n[1],0,t);const u=s(g("polygon",o,null)),d=r.execute(u,c,null);if(!d)return void this._writePoint(e,n[0],n[1],0,t);const P=p(new _(d.toFlatGeometry())),b=y.fromOptimized(P,"esriGeometryPolygon",1),v=x(b)??n;this._writePoint(e,v[0],v[1],0,t)}_writePoint(e,t,i,r,s){if(t<0||t>w||i<0||i>w)return;const o=this._getShaping();if(!o)return;const n=s.getDisplayId(),a=this.evaluatedMeshParams.labelClassId,l=E(this.evaluatedMeshParams.layerId,s.getObjectId(),r),c=T(s.getObjectId(),a,r),[h,m]=this._getMetricDir(),u=this.evaluatedMeshParams.scaleInfo?.maxScale??0,d=this.evaluatedMeshParams.scaleInfo?.minScale??0,f=this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0};e.metricStart(new B(n,a,l,c,t,i,h,m,u,d,f)),this._writeGlyphs(e,n,t,i,o,0,f,void 0,!1),e.metricBoxWrite(o.boundsT),e.metricEnd()}_getPointReferenceBounds(){if(!this._references)return null;for(const e of this._references){const t=e.getBoundsInfo();if(t)return t}return null}_writeLines(e,t){const{scaleInfo:i,verticalAlignment:r}=this.evaluatedMeshParams,s=this.evaluatedMeshParams.repeatLabelDistance||128,o=this._getShaping("middle");if(!o)return;const n=(e,t,i,r)=>this._placeSubdivGlyphs(e,t,i,r),a=(o.bounds.width+s)/(1<<F);this._current={out:e,id:t.getDisplayId(),objId:t.getObjectId(),shaping:o,zoomRange:G(i,this.getTileInfo()),referenceBounds:this._getPointReferenceBounds()||{offsetX:0,offsetY:0,size:0},offsetDirection:null,pathIndex:0},this._verticalPlacement="bottom"===r?"above":"top"===r?"below":null,this._verticalPlacement?this._writeAboveAndBelowAlong(t,n,a):this._writeCenterAlong(t,n,a)}_writeAboveAndBelowAlong(e,t,i){const{repeatLabel:r}=this.evaluatedMeshParams,{shaping:s}=this._current,o=s.bounds.halfHeight,n=e.readGeometryForDisplay();if(!n)return;const a=P(n,"esriGeometryPolyline",1)??new v,l=Y(a,o),c=Y(a,-o),h=b(c,"esriGeometryPolyline",!1,!1),m=b(l,"esriGeometryPolyline",!1,!1),u=S(m.paths,s.bounds.width),d=S(h.paths,s.bounds.width);this._current.offsetDirection="above";for(let f=0;f<u.length;f++)this._current.pathIndex=f,z(u[f],i,t,!!r);this._current.offsetDirection="below";for(let f=0;f<d.length;f++)this._current.pathIndex=f,z(d[f],i,t,!!r)}_writeCenterAlong(e,t,i){const{repeatLabel:r}=this.evaluatedMeshParams,{shaping:s}=this._current,o=S(e.readLegacyGeometryForDisplay().paths,s.bounds.width);for(let n=0;n<o.length;n++)this._current.pathIndex=n,z(o[n],i,t,!!r)}_placeSubdivGlyphs(e,t,i,r){const{allowOverrun:s,labelPosition:o,repeatLabelDistance:n,layerId:a,labelClassId:l}=this.evaluatedMeshParams,{objId:c,shaping:h,pathIndex:m}=this._current,u=this._current.zoomRange[0],d=U(t),f=this._current.shaping.bounds.width/(1<<F),g=Math.sqrt(n||R)/(1<<F),p=Math.min(i,r-i),_=h.isMultiline?A:Math.log2(p/(g+f/2)),y=0===t?_:Math.min(d,_),x=Math.max(u,this._zoomLevel+F-y),P=this._zoomLevel-x,b=h.bounds.width/2*2**P,v=Z(a,c,m,t,this._zoomLevel),M=W(c,m,t,this._zoomLevel,l);this._current.shaping.isMultiline?0===t&&this._placeStraight(e,x,v,M):s&&P<0?this._placeStraightAlong(e,u,v,M):"parallel"===o?this._placeStraightAlong(e,x,v,M):"curved"===o&&this._placeCurved(e,x,b,v,M)}_placeStraight(e,t,i,r){const{out:s,id:o,shaping:n,referenceBounds:a}=this._current,{x:l,y:c}=e;s.metricStart(this._createLineLabelMetric(o,i,r,l,c)),s.metricBoxWrite(n.boundsT);const h=e.angle*(180/Math.PI)%360,m=(e.angle*(180/Math.PI)+180)%360;if(!this._verticalPlacement||this._verticalPlacement===this._current.offsetDirection){const e={clipAngle:h,mapAligned:!0,isLineLabel:!0,minZoom:t};this._writeGlyphs(s,o,l,c,n,0,a,e,!1)}if(!this._verticalPlacement||this._verticalPlacement!==this._current.offsetDirection){const e={clipAngle:m,mapAligned:!0,isLineLabel:!0,minZoom:t};this._writeGlyphs(s,o,l,c,n,0,a,e,!1)}s.metricEnd()}_placeCurved(e,t,i,r,s){const{out:o,id:n}=this._current;o.metricStart(this._createLineLabelMetric(n,r,s,e.x,e.y));const a=e.clone(),l=e.angle*(180/Math.PI)%360,c=(e.angle*(180/Math.PI)+180)%360;this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||(this._placeFirst(a,t,1,l),this._placeBack(e,a,t,i,1,l),this._placeForward(e,a,t,i,1,l)),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||(this._placeFirst(a,t,0,c),this._placeBack(e,a,t,i,0,c),this._placeForward(e,a,t,i,0,c)),o.metricEnd()}_placeStraightAlong(e,i,n,a){const{out:l,id:c,shaping:h,zoomRange:m,referenceBounds:d}=this._current,{boxBorderLineColor:f,boxBackgroundColor:g}=this.evaluatedMeshParams,p=e.clone(),_=e.angle*(180/Math.PI)%360,y=(e.angle*(180/Math.PI)+180)%360,x=h.glyphs.length>0&&!(!f&&!g);if(l.metricStart(this._createLineLabelMetric(c,n,a,e.x,e.y)),x){const n=Math.max(i,m[0],0),a=Math.min(A,m[1]),f=r(o(),-e.angle),g={minZoom:n,maxZoom:a,clipAngle:_,mapAligned:!0,isLineLabel:!0},p=t(this.evaluatedMeshParams.offsetX),x=t(this.evaluatedMeshParams.offsetY);if(!this._verticalPlacement||this._verticalPlacement===this._current.offsetDirection){const t=u(p,-1*x),[i,r]=h.shapeBackground(s(o(),f,t));l.recordStart(this.instanceId,this.attributeLayout,h.glyphs[0].textureBinding),this._writeTextBox(l,c,e.x,e.y,r,d,g),l.recordEnd()}if(!this._verticalPlacement||this._verticalPlacement!==this._current.offsetDirection){const t=u(p,x),[i,r]=h.shapeBackground(s(o(),f,t));g.clipAngle=y,l.recordStart(this.instanceId,this.attributeLayout,h.glyphs[0].textureBinding),this._writeTextBox(l,c,e.x,e.y,r,d,g),l.recordEnd()}}this._verticalPlacement&&this._verticalPlacement!==this._current.offsetDirection||this._placeFirst(p,i,1,_,!0),this._verticalPlacement&&this._verticalPlacement===this._current.offsetDirection||this._placeFirst(p,i,0,y,!0),l.metricEnd()}_placeBack(e,t,i,r,s,o){const n=e.clone();let a=e.backwardLength+k;for(;n.prev()&&!(a>=r);)this._placeOnSegment(n,t,a,i,-1,s,o),a+=n.length+k}_placeForward(e,t,i,r,s,o){const n=e.clone();let a=e.remainingLength+k;for(;n.next()&&!(a>=r);)this._placeOnSegment(n,t,a,i,1,s,o),a+=n.length+k}_placeFirst(e,t,i,r,s=!1){const{out:o,id:n,shaping:a,zoomRange:l,referenceBounds:c}=this._current,h=a.glyphs,m=this._getBoundsOffset(e.angle);for(const u of h){const h=u.x>a.bounds.x?i:1-i,d=h*e.remainingLength+(1-h)*e.backwardLength,f=Math.abs(u.x+u.width/2-a.bounds.x),g=Math.max(0,this._zoomLevel+Math.log2(f/(d+k))),p=Math.max(t,s?0:g);u.angle=e.angle+(1-i)*Math.PI;const _=[Math.max(l[0],p),Math.min(l[1],A)];this._writeLineGlyph(o,n,e.x,e.y,u,_,r,c),this._writeLineGlyphBox(o,u,i,_,m)}}_placeOnSegment(e,t,i,r,s,o,n){const{out:a,id:l,shaping:c,referenceBounds:h}=this._current,m=c.glyphs,u=e.dx/e.length,d=e.dy/e.length,f={x:e.x+i*-s*u,y:e.y+i*-s*d},g=this._getBoundsOffset(e.angle);for(const p of m){const t=p.x>c.bounds.x?o:1-o;if(!(t&&1===s||!t&&-1===s))continue;const m=Math.abs(p.x+p.width/2-c.bounds.x),u=Math.max(0,this._zoomLevel+Math.log2(m/i)-.1),d=Math.max(r,this._zoomLevel+Math.log2(m/(i+e.length+k)));if(0===u)continue;p.angle=e.angle+(1-o)*Math.PI;const _=[d,u];this._writeLineGlyph(a,l,f.x,f.y,p,_,n,h),this._writeLineGlyphBox(a,p,o,_,g)}}_getBoundsOffset(e){const i=t(this.evaluatedMeshParams.offsetX),s=t(this.evaluatedMeshParams.offsetY),a=u(i,s),l=r(o(),-e);return n(a,a,l)}_writeLineGlyph(e,t,i,r,s,o,n,a){if(i<0||i>w||r<0||r>w)return;e.recordStart(this.instanceId,this.attributeLayout,s.textureBinding);const{texcoords:l,offsets:c}=s,{fontSize:h,haloSize:m,outlineSize:u}=this._textMeshTransformProps,{sdfSize:d,sdfRadius:f}=this.evaluatedMeshParams.glyphs;this._writeQuad(e,t,i,r,{sdfSize:d,sdfRadius:f,texcoords:l,offsets:c,fontSize:h,haloSize:m,outlineSize:u,color:j(this.evaluatedMeshParams.color),isBackground:!1,referenceBounds:a,minZoom:Math.max(this._current.zoomRange[0],o[0]),maxZoom:Math.min(this._current.zoomRange[1],o[1]),clipAngle:n,mapAligned:!0,isLineLabel:!0}),e.recordEnd()}_writeLineGlyphBox(e,t,i,r,s){if((i||this._current.offsetDirection)&&this._isVisible(r)&&t.bounds){const i=t.bounds,r=new I(i.x+s[0],i.y+s[1],i.width,i.height);e.metricBoxWrite(r)}}_packedZoom(e){return Math.floor(e*L)/L}_isVisible(e){let t=Math.max(this._current.zoomRange[0],e[0]),i=Math.min(this._current.zoomRange[1],e[1]);t=this._packedZoom(t),i=this._packedZoom(i);const r=this._packedZoom(this._zoomLevel);return t<=r&&r<=i}}function Y(e,t){const i=new v,{coords:r,lengths:s}=e,o=d(),n=d(),u=d(),f=d(),g=d(),p=d(),_=2;let y=0;for(let d=0;d<s.length;d++){const e=s[d];for(let s=0;s<e;s++){const d=_*(s+y-1),x=_*(s+y),P=_*(s+y+1);s>0?a(o,r[d],r[d+1]):a(o,0,0),a(n,r[x],r[x+1]),s<e-1?a(u,r[P],r[P+1]):a(u,0,0),0===s?a(f,0,0):(l(f,n,o),c(f,f),a(f,f[1],-f[0])),s===e-1?a(g,0,0):(l(g,u,n),c(g,g),a(g,g[1],-g[0])),h(p,f,g),c(p,p);const b=p[0]*g[0]+p[1]*g[1];0!==b&&m(p,p,b),m(p,p,t),i.coords.push(n[0]+p[0],n[1]+p[1])}i.lengths.push(e),y+=e}return i}export{X as LabelMeshWriter,E as labelIdHash,T as labelMetricHash,Z as lineLabelIdHash,W as lineLabelMetricHash};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{clamp as t}from"../../../../../../../core/mathUtils.js";import{pt2px as e}from"../../../../../../../core/screenUtils.js";import{GeometryCursor as o}from"../../../../../../../geometry/GeometryCursor.js";import{CIMMarkerPlacementHelper as i}from"../../../../../../../symbols/cim/placements/CIMMarkerPlacementHelper.js";import{getXDirection as s,getYDirection as r}from"../../../alignmentUtils.js";import{minMaxZoomPrecisionFactor as n,maxTextLineWidth as a,minTextLineWidth as l,magicLabelLineHeight as c}from"../../../definitions.js";import{shapeGlyphs as d}from"../../../mesh/templates/shapingUtils.js";import{getMinMaxZoom as h,processColorInput as f,packBitset as p}from"../fill/meshWriterUtils.js";import{MeshWriter as m}from"../mesh/MeshWriter.js";import{bitsetTextIsBackground as u,bitsetTextIsMapAligned as g}from"../shaders/constants.js";import{TextMeshTransformProps as x}from"./TextParams.js";import{DataType as y}from"../../../../../../webgl/enums.js";const S=28,_=[4,4],z=[16,4],P={topLeft:z,topRight:z,bottomLeft:z,bottomRight:z},b=[4,2],R=[4,6],T={topLeft:b,topRight:b,bottomLeft:R,bottomRight:R},B={topLeft:b,topRight:R,bottomLeft:b,bottomRight:R},k={topLeft:R,topRight:R,bottomLeft:_,bottomRight:_},M={topLeft:_,topRight:_,bottomLeft:R,bottomRight:R},L={topLeft:R,topRight:_,bottomLeft:R,bottomRight:_},w={topLeft:_,topRight:R,bottomLeft:_,bottomRight:R},A={createComputedParams:t=>t,optionalAttributes:{zoomRange:{type:y.UNSIGNED_SHORT,count:2,packPrecisionFactor:n,packTessellation:({minZoom:t,maxZoom:e})=>[t||0,e||S]},clipAngle:{type:y.UNSIGNED_BYTE,count:1,packTessellation:({clipAngle:t})=>I(t||0)},referenceSymbol:{type:y.BYTE,count:4,packTessellation:(t,o)=>{const i=t.isLineLabel||!t.referenceBounds,n=s(i?"center":o.horizontalAlignment),a=r(i?"middle":o.verticalAlignment),{offsetX:l,offsetY:c,size:d}=i?{offsetX:0,offsetY:0,size:0}:t.referenceBounds;return[e(l),-e(c),Math.round(e(d)),n+1<<2|a+1]}},visibility:{type:y.FLOAT,count:1,otherSource:!0}},attributes:{pos:{type:y.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:y.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:y.UNSIGNED_BYTE,count:1,packTessellation:({isBackground:t,mapAligned:e})=>p([[u,t],[g,!!e]])},offset:{type:y.SHORT,count:2,packPrecisionFactor:8,packAlternating:{count:4,packTessellation:({offsets:t})=>{const{bottomLeft:e,bottomRight:o,topLeft:i,topRight:s}=t;return[i,s,e,o]}}},textureUV:{type:y.UNSIGNED_SHORT,count:2,packAlternating:{count:4,packTessellation:({texcoords:t})=>{const{bottomLeft:e,bottomRight:o,topLeft:i,topRight:s}=t;return[i,s,e,o]}}},color:{type:y.UNSIGNED_BYTE,count:4,normalized:!0,packTessellation:({color:t})=>t},fontAndReferenceSize:{type:y.UNSIGNED_SHORT,count:4,packPrecisionFactor:4,packTessellation:({fontSize:t,sdfSize:o,sdfRadius:i},{referenceSize:s})=>[Math.round(e(t)),Math.round(e(s??t)),o,i]},outlineColor:{type:y.UNSIGNED_BYTE,count:4,normalized:!0,pack:({outlineColor:t})=>f(t)},haloColor:{type:y.UNSIGNED_BYTE,count:4,normalized:!0,pack:({haloColor:t})=>f(t)},outlineAndHaloSize:{type:y.UNSIGNED_SHORT,count:2,packPrecisionFactor:4,packTessellation:({outlineSize:t,haloSize:o})=>[Math.round(e(t)),Math.round(e(o))]}}};class v extends m{constructor(){super(...arguments),this.vertexSpec=A,this._textMeshParamsPropsInitialized=!1}ensurePacked(t,e,o){super.ensurePacked(t,e,o),this._textMeshParamsPropsInitialized&&!this._evaluator.hasDynamicProperties||(this._textMeshTransformProps=new x(this.evaluatedMeshParams),this._textMeshParamsPropsInitialized=!0)}_write(t,e,o){const i=this._getShaping();if(!i)return;const s=1===this.evaluatedMeshParams.alignment,r=e.getDisplayId();if(null!=this.evaluatedMeshParams.placement)return this._writePlacedTextMarkers(t,e,i,o);if(o?.nextPath())return o.nextPoint(),this._writeGlyphs(t,r,o.x,o.y,i,0,void 0,{mapAligned:s});if("esriGeometryPolygon"===e.geometryType){const o=e.readCentroidForDisplay();if(!o)return;const[n,a]=o.coords;return this._writeGlyphs(t,r,n,a,i,0,void 0,{mapAligned:s})}if("esriGeometryMultipoint"===e.geometryType){const o=e.readGeometryForDisplay();return void o?.forEachVertex((e,o)=>this._writeGlyphs(t,r,e,o,i,0,void 0,{mapAligned:s}))}const n=e.readXForDisplay(),a=e.readYForDisplay();return this._writeGlyphs(t,r,n,a,i,0,void 0,{mapAligned:s})}_writePlacedTextMarkers(t,s,r,n){const a=n??o.fromFeatureSetReaderCIM(s);if(!a)return;const l=-1,c=i.getPlacement(a,l,this.evaluatedMeshParams.placement,e(1),t.id);if(!c)return;const d=s.getDisplayId();let h=c.next();for(;null!=h;){const e=h.tx,o=-h.ty,i=-h.getAngle();this._writeGlyphs(t,d,e,o,r,i,void 0,{mapAligned:1===this.evaluatedMeshParams.alignment}),h=c.next()}}_getShaping(o){const i=this._textMeshTransformProps,s=this.evaluatedMeshParams;if(!s.glyphs?.glyphs.length)return null;const r=e(i.fontSize),n=e(i.offsetX),h=e(i.offsetY),f=s.glyphs.sdfSize,p=t(e(s.lineWidth),l,a),m=f/24*c*t(s.lineHeightRatio,.25,4);return d(s.glyphs,{scale:r/f,angle:i.postAngle,xOffset:n,yOffset:h,horizontalAlignment:s.horizontalAlignment,verticalAlignment:o||s.verticalAlignment,maxLineWidth:p,lineHeight:m,decoration:s.decoration,borderLineSizePx:e(s.boxBorderLineSize),hasBackground:!!s.boxBackgroundColor,useCIMAngleBehavior:s.useCIMAngleBehavior})}_writeGlyphs(t,o,i,s,r,n,a,l,c=!0){const d=this.evaluatedMeshParams,p=this._textMeshTransformProps,m=e(p.fontSize),u=p.haloSize,g=p.outlineSize,x=e(p.offsetX),y=e(p.offsetY),{sdfSize:S,sdfRadius:_}=d.glyphs,[z,P]=h(d.scaleInfo,this.getTileInfo());0!==n&&r.setRotation(n);const b=r.bounds,R=i+b.x+x,T=s+b.y-y,B=2*(d.minPixelBuffer?d.minPixelBuffer/m:1),k=Math.max(b.width,b.height)*B;r.textBox&&(t.recordStart(this.instanceId,this.attributeLayout,r.glyphs[0].textureBinding),c&&t.recordBounds(R,T,k,k),this._writeTextBox(t,o,i,s,r.textBox,a,l),t.recordEnd());for(const e of r.glyphs){t.recordStart(this.instanceId,this.attributeLayout,e.textureBinding),c&&t.recordBounds(R,T,k,k);const{texcoords:r,offsets:n}=e;this._writeQuad(t,o,i,s,{texcoords:r,offsets:n,fontSize:m,haloSize:u,outlineSize:g,sdfSize:S,sdfRadius:_,color:f(d.color),isBackground:!1,referenceBounds:a,minZoom:z,maxZoom:P,...l}),t.recordEnd()}0!==n&&r.setRotation(-n)}_writeTextBox(t,e,o,i,s,r,n){const a=this.evaluatedMeshParams,{fontSize:l,haloSize:c,outlineSize:d}=this._textMeshTransformProps,{boxBackgroundColor:h,boxBorderLineColor:p,boxBorderLineSize:m}=a,{sdfSize:u,sdfRadius:g}=a.glyphs,x=!!p&&m>0,y={isBackground:!0,fontSize:l,haloSize:c,outlineSize:d,referenceBounds:r,sdfSize:u,sdfRadius:g,...n};h&&(this._writeQuad(t,e,o,i,{texcoords:P,offsets:s.main,color:f(h),...y}),x||(this._writeQuad(t,e,o,i,{texcoords:k,offsets:s.top,color:f(h),...y}),this._writeQuad(t,e,o,i,{texcoords:M,offsets:s.bot,color:f(h),...y}),this._writeQuad(t,e,o,i,{texcoords:L,offsets:s.left,color:f(h),...y}),this._writeQuad(t,e,o,i,{texcoords:w,offsets:s.right,color:f(h),...y}))),x&&(this._writeQuad(t,e,o,i,{texcoords:T,offsets:s.top,color:f(p),...y}),this._writeQuad(t,e,o,i,{texcoords:T,offsets:s.bot,color:f(p),...y}),this._writeQuad(t,e,o,i,{texcoords:B,offsets:s.left,color:f(p),...y}),this._writeQuad(t,e,o,i,{texcoords:B,offsets:s.right,color:f(p),...y}))}_writeQuad(t,e,o,i,s){const r=t.vertexCount();this._writeVertex(t,e,o,i,s),t.indexWrite(r+0),t.indexWrite(r+1),t.indexWrite(r+2),t.indexWrite(r+1),t.indexWrite(r+3),t.indexWrite(r+2)}}const I=t=>Math.round(t*(
|
|
2
|
+
import{clamp as t}from"../../../../../../../core/mathUtils.js";import{pt2px as e}from"../../../../../../../core/screenUtils.js";import{GeometryCursor as o}from"../../../../../../../geometry/GeometryCursor.js";import{CIMMarkerPlacementHelper as i}from"../../../../../../../symbols/cim/placements/CIMMarkerPlacementHelper.js";import{getXDirection as s,getYDirection as r}from"../../../alignmentUtils.js";import{minMaxZoomPrecisionFactor as n,maxTextLineWidth as a,minTextLineWidth as l,magicLabelLineHeight as c}from"../../../definitions.js";import{shapeGlyphs as d}from"../../../mesh/templates/shapingUtils.js";import{getMinMaxZoom as h,processColorInput as f,packBitset as p}from"../fill/meshWriterUtils.js";import{MeshWriter as m}from"../mesh/MeshWriter.js";import{bitsetTextIsBackground as u,bitsetTextIsMapAligned as g}from"../shaders/constants.js";import{TextMeshTransformProps as x}from"./TextParams.js";import{DataType as y}from"../../../../../../webgl/enums.js";const S=28,_=[4,4],z=[16,4],P={topLeft:z,topRight:z,bottomLeft:z,bottomRight:z},b=[4,2],R=[4,6],T={topLeft:b,topRight:b,bottomLeft:R,bottomRight:R},B={topLeft:b,topRight:R,bottomLeft:b,bottomRight:R},k={topLeft:R,topRight:R,bottomLeft:_,bottomRight:_},M={topLeft:_,topRight:_,bottomLeft:R,bottomRight:R},L={topLeft:R,topRight:_,bottomLeft:R,bottomRight:_},w={topLeft:_,topRight:R,bottomLeft:_,bottomRight:R},A={createComputedParams:t=>t,optionalAttributes:{zoomRange:{type:y.UNSIGNED_SHORT,count:2,packPrecisionFactor:n,packTessellation:({minZoom:t,maxZoom:e})=>[t||0,e||S]},clipAngle:{type:y.UNSIGNED_BYTE,count:1,packTessellation:({clipAngle:t})=>I(t||0)},referenceSymbol:{type:y.BYTE,count:4,packTessellation:(t,o)=>{const i=t.isLineLabel||!t.referenceBounds,n=s(i?"center":o.horizontalAlignment),a=r(i?"middle":o.verticalAlignment),{offsetX:l,offsetY:c,size:d}=i?{offsetX:0,offsetY:0,size:0}:t.referenceBounds;return[e(l),-e(c),Math.round(e(d)),n+1<<2|a+1]}},visibility:{type:y.FLOAT,count:1,otherSource:!0}},attributes:{pos:{type:y.SHORT,count:2,pack:"position",packPrecisionFactor:10},id:{type:y.UNSIGNED_BYTE,count:3,pack:"id"},bitset:{type:y.UNSIGNED_BYTE,count:1,packTessellation:({isBackground:t,mapAligned:e})=>p([[u,t],[g,!!e]])},offset:{type:y.SHORT,count:2,packPrecisionFactor:8,packAlternating:{count:4,packTessellation:({offsets:t})=>{const{bottomLeft:e,bottomRight:o,topLeft:i,topRight:s}=t;return[i,s,e,o]}}},textureUV:{type:y.UNSIGNED_SHORT,count:2,packAlternating:{count:4,packTessellation:({texcoords:t})=>{const{bottomLeft:e,bottomRight:o,topLeft:i,topRight:s}=t;return[i,s,e,o]}}},color:{type:y.UNSIGNED_BYTE,count:4,normalized:!0,packTessellation:({color:t})=>t},fontAndReferenceSize:{type:y.UNSIGNED_SHORT,count:4,packPrecisionFactor:4,packTessellation:({fontSize:t,sdfSize:o,sdfRadius:i},{referenceSize:s})=>[Math.round(e(t)),Math.round(e(s??t)),o,i]},outlineColor:{type:y.UNSIGNED_BYTE,count:4,normalized:!0,pack:({outlineColor:t})=>f(t)},haloColor:{type:y.UNSIGNED_BYTE,count:4,normalized:!0,pack:({haloColor:t})=>f(t)},outlineAndHaloSize:{type:y.UNSIGNED_SHORT,count:2,packPrecisionFactor:4,packTessellation:({outlineSize:t,haloSize:o})=>[Math.round(e(t)),Math.round(e(o))]}}};class v extends m{constructor(){super(...arguments),this.vertexSpec=A,this._textMeshParamsPropsInitialized=!1}ensurePacked(t,e,o){super.ensurePacked(t,e,o),this._textMeshParamsPropsInitialized&&!this._evaluator.hasDynamicProperties||(this._textMeshTransformProps=new x(this.evaluatedMeshParams),this._textMeshParamsPropsInitialized=!0)}_write(t,e,o){const i=this._getShaping();if(!i)return;const s=1===this.evaluatedMeshParams.alignment,r=e.getDisplayId();if(null!=this.evaluatedMeshParams.placement)return this._writePlacedTextMarkers(t,e,i,o);if(o?.nextPath())return o.nextPoint(),this._writeGlyphs(t,r,o.x,o.y,i,0,void 0,{mapAligned:s});if("esriGeometryPolygon"===e.geometryType){const o=e.readCentroidForDisplay();if(!o)return;const[n,a]=o.coords;return this._writeGlyphs(t,r,n,a,i,0,void 0,{mapAligned:s})}if("esriGeometryMultipoint"===e.geometryType){const o=e.readGeometryForDisplay();return void o?.forEachVertex((e,o)=>this._writeGlyphs(t,r,e,o,i,0,void 0,{mapAligned:s}))}const n=e.readXForDisplay(),a=e.readYForDisplay();return this._writeGlyphs(t,r,n,a,i,0,void 0,{mapAligned:s})}_writePlacedTextMarkers(t,s,r,n){const a=n??o.fromFeatureSetReaderCIM(s);if(!a)return;const l=-1,c=i.getPlacement(a,l,this.evaluatedMeshParams.placement,e(1),t.id);if(!c)return;const d=s.getDisplayId();let h=c.next();for(;null!=h;){const e=h.tx,o=-h.ty,i=-h.getAngle();this._writeGlyphs(t,d,e,o,r,i,void 0,{mapAligned:1===this.evaluatedMeshParams.alignment}),h=c.next()}}_getShaping(o){const i=this._textMeshTransformProps,s=this.evaluatedMeshParams;if(!s.glyphs?.glyphs.length)return null;const r=e(i.fontSize),n=e(i.offsetX),h=e(i.offsetY),f=s.glyphs.sdfSize,p=t(e(s.lineWidth),l,a),m=f/24*c*t(s.lineHeightRatio,.25,4);return d(s.glyphs,{scale:r/f,angle:i.postAngle,xOffset:n,yOffset:h,horizontalAlignment:s.horizontalAlignment,verticalAlignment:o||s.verticalAlignment,maxLineWidth:p,lineHeight:m,decoration:s.decoration,borderLineSizePx:e(s.boxBorderLineSize),hasBackground:!!s.boxBackgroundColor,useCIMAngleBehavior:s.useCIMAngleBehavior})}_writeGlyphs(t,o,i,s,r,n,a,l,c=!0){const d=this.evaluatedMeshParams,p=this._textMeshTransformProps,m=e(p.fontSize),u=p.haloSize,g=p.outlineSize,x=e(p.offsetX),y=e(p.offsetY),{sdfSize:S,sdfRadius:_}=d.glyphs,[z,P]=h(d.scaleInfo,this.getTileInfo());0!==n&&r.setRotation(n);const b=r.bounds,R=i+b.x+x,T=s+b.y-y,B=2*(d.minPixelBuffer?d.minPixelBuffer/m:1),k=Math.max(b.width,b.height)*B;r.textBox&&(t.recordStart(this.instanceId,this.attributeLayout,r.glyphs[0].textureBinding),c&&t.recordBounds(R,T,k,k),this._writeTextBox(t,o,i,s,r.textBox,a,l),t.recordEnd());for(const e of r.glyphs){t.recordStart(this.instanceId,this.attributeLayout,e.textureBinding),c&&t.recordBounds(R,T,k,k);const{texcoords:r,offsets:n}=e;this._writeQuad(t,o,i,s,{texcoords:r,offsets:n,fontSize:m,haloSize:u,outlineSize:g,sdfSize:S,sdfRadius:_,color:f(d.color),isBackground:!1,referenceBounds:a,minZoom:z,maxZoom:P,...l}),t.recordEnd()}0!==n&&r.setRotation(-n)}_writeTextBox(t,e,o,i,s,r,n){const a=this.evaluatedMeshParams,{fontSize:l,haloSize:c,outlineSize:d}=this._textMeshTransformProps,{boxBackgroundColor:h,boxBorderLineColor:p,boxBorderLineSize:m}=a,{sdfSize:u,sdfRadius:g}=a.glyphs,x=!!p&&m>0,y={isBackground:!0,fontSize:l,haloSize:c,outlineSize:d,referenceBounds:r,sdfSize:u,sdfRadius:g,...n};h&&(this._writeQuad(t,e,o,i,{texcoords:P,offsets:s.main,color:f(h),...y}),x||(this._writeQuad(t,e,o,i,{texcoords:k,offsets:s.top,color:f(h),...y}),this._writeQuad(t,e,o,i,{texcoords:M,offsets:s.bot,color:f(h),...y}),this._writeQuad(t,e,o,i,{texcoords:L,offsets:s.left,color:f(h),...y}),this._writeQuad(t,e,o,i,{texcoords:w,offsets:s.right,color:f(h),...y}))),x&&(this._writeQuad(t,e,o,i,{texcoords:T,offsets:s.top,color:f(p),...y}),this._writeQuad(t,e,o,i,{texcoords:T,offsets:s.bot,color:f(p),...y}),this._writeQuad(t,e,o,i,{texcoords:B,offsets:s.left,color:f(p),...y}),this._writeQuad(t,e,o,i,{texcoords:B,offsets:s.right,color:f(p),...y}))}_writeQuad(t,e,o,i,s){const r=t.vertexCount();this._writeVertex(t,e,o,i,s),t.indexWrite(r+0),t.indexWrite(r+1),t.indexWrite(r+2),t.indexWrite(r+1),t.indexWrite(r+3),t.indexWrite(r+2)}}const I=t=>Math.round(t*(256/360));export{v as TextMeshWriter,A as TextVertexSpec,S as maxLabelZoom};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as t,__param as e}from"tslib";import{minMaxZoomPrecisionFactor as i,labelPlacementOffsetPadding as o}from"../../../definitions.js";import{location as s,option as l,uniform as r,define as a,input as n,ComputeVertexInput as d}from"../../GraphShaderModule.js";import{
|
|
2
|
+
import{__decorate as t,__param as e}from"tslib";import{minMaxZoomPrecisionFactor as i,labelPlacementOffsetPadding as o}from"../../../definitions.js";import{location as s,option as l,uniform as r,define as a,input as n,ComputeVertexInput as d}from"../../GraphShaderModule.js";import{mod as p,Float as u,floor as y,step as m,and as f,lessThan as c,greaterThanEqual as h,Vec3 as v,Mat3 as w,Vec2 as x,ifElse as b,equal as V,greaterThan as S,Bool as g,Vec4 as z,texture2D as R,smoothstep as j,Int as A,bitRShift as C,bitAnd as M}from"../../graph/glsl.js";import{AFeatureShader as O,FeatureVertexInput as P,FeatureFragmentInput as L}from"../shaders/AFeatureShader.js";import{bitsetTextIsBackground as N,bitsetTextIsMapAligned as U}from"../shaders/constants.js";import{distPointTriangle as T,failHittest as H}from"../shaders/hittestUtils.js";import{MosaicInfo as _}from"../shaders/MosaicInfo.js";import{getBit as k}from"../shaders/utils.js";import{VisualVariableColor as I}from"../shaders/VisualVariableColor.js";import{VisualVariableOpacity as D}from"../shaders/VisualVariableOpacity.js";import{VisualVariableRotation as B}from"../shaders/VisualVariableRotation.js";import{VisualVariableSizeMinMaxValue as q}from"../shaders/VisualVariableSizeMinMaxValue.js";import{VisualVariableSizeScaleStops as E}from"../shaders/VisualVariableSizeScaleStops.js";import{VisualVariableSizeStops as F}from"../shaders/VisualVariableSizeStops.js";import{VisualVariableSizeUnitValue as W}from"../shaders/VisualVariableSizeUnitValue.js";import{getVisualVariableSize as G,getVisualVariableRotation as Z}from"../shaders/vvUtils.js";const J=360/254;class K extends P{}t([s(3,z)],K.prototype,"color",void 0),t([s(4,x)],K.prototype,"offset",void 0),t([s(5,x)],K.prototype,"textureUV",void 0),t([s(6,z)],K.prototype,"fontAndReferenceSize",void 0),t([s(7,z)],K.prototype,"outlineColor",void 0),t([s(8,z)],K.prototype,"haloColor",void 0),t([s(9,x)],K.prototype,"outlineAndHaloSize",void 0),t([s(10,x)],K.prototype,"zoomRange",void 0),t([s(11,u)],K.prototype,"clipAngle",void 0),t([s(12,z)],K.prototype,"referenceSymbol",void 0),t([s(15,u)],K.prototype,"visibility",void 0);class Q extends d{}t([s(13,x)],Q.prototype,"offsetNextVertex1",void 0),t([s(14,x)],Q.prototype,"offsetNextVertex2",void 0);class X extends L{}class Y extends O{constructor(){super(...arguments),this.type="TextShader",this.computeAttributes={offset:["offsetNextVertex1","offsetNextVertex2"]},this.textRenderPassType=0,this.isBackgroundPass=!1,this.isLabel=!1}clipLabel(t,e){const{clipAngle:o,zoomRange:s,visibility:l}=t,r=o.multiply(J),a=p(r.subtract(this.view.rotation),new u(360));let n=new u(0);const d=y(this.view.currentZoom.multiply(i)).divide(i),v=s.x,w=s.y,x=new u(1).subtract(m(v,d)).multiply(2),b=new u(f(h(a,new u(90)),c(a,new u(270)))).multiply(2),V=new u(2).multiply(new u(1).subtract(m(d,w)));return n=n.add(e.multiply(x)),n=n.add(e.multiply(b)),n=n.add(V),l&&(n=n.add(l)),n}vertex(t,e){const i=k(t.bitset,N),s=new u(1).subtract(i);let l=t.fontAndReferenceSize[0];const r=t.fontAndReferenceSize[1],a=t.fontAndReferenceSize[2],n=t.fontAndReferenceSize[3];let d=l.divide(a);const p=1===this.textRenderPassType?t.outlineColor:2===this.textRenderPassType?t.haloColor:this._getVertexColor(t),y=this.view.displayViewScreenMat3.multiply(new v(t.pos,1));let m=t.offset,f=new u(1),c=w.identity(),h=new x(0);if(this.isLabel){if(!t.referenceSymbol)throw new Error("InternalError: Optional attribute 'referenceSymbol' expected for labels");const e=t.referenceSymbol,i=e.xy,s=e.z,l=this._unpackDirection(e.w),r=G(this,t.id,s).divide(2),a=l.multiply(r.add(o));h=i.add(a),m=m.add(h)}else{f=G(this,t.id,r).divide(r),l=l.multiply(f),d=d.multiply(f),m=m.multiply(f),c=Z(this,t.id),m=c.multiply(new v(m,0)).xy}const R=k(t.bitset,U),j=this._getViewRotationMatrix(R).multiply(new v(m,0));let A=this.isLabel?this.clipLabel(t,R):this.clip(t.id,t.zoomRange);A=this.isBackgroundPass?A.add(s.multiply(2)):A.add(i.multiply(2));let C=new u(0);if(1===this.textRenderPassType){A=A.add(b(V(t.outlineAndHaloSize.x,new u(0)),new u(2),new u(0)));C=new u(t.outlineAndHaloSize.x).divide(d).divide(n)}if(2===this.textRenderPassType){const e=t.outlineAndHaloSize.x,i=new u(t.outlineAndHaloSize.y);A=A.add(b(V(i,new u(0)),new u(2),new u(0)));C=i.add(e).divide(d).divide(n)}const M=this.isLabel?S(A,new u(1)):new g(!1);return{glPosition:new z(y.xy.add(j.xy),A,1),color:p,size:d,textureUV:t.textureUV.divide(this.mosaicInfo.size),antialiasingWidth:new u(.315).divide(a.divide(n)).multiply(a).divide(l).divide(this.view.pixelRatio),outlineDistanceOffset:C,...this.maybeRunHittest(t,e,{vvSizeAdjustment:f,vvRotation:c,labelOffset:h,labelClipped:M})}}_getViewRotationMatrix(t){const e=this.view.displayViewMat3,i=this.view.displayMat3,o=new u(1).subtract(t);return e.multiply(t).add(i.multiply(o))}fragment(t){const e=new u(2/8),i=new u(1).subtract(e),o=R(this.mosaicInfo.texture,t.textureUV).a;let s=i.subtract(t.outlineDistanceOffset);this.highlight&&(s=s.divide(2));const l=t.antialiasingWidth,r=j(s.subtract(l),s.add(l),o);return this.getFragmentOutput(t.color.multiply(r),t)}hittest(t,e,{vvSizeAdjustment:i,vvRotation:o,labelOffset:s,labelClipped:l}){let r,a,n;this.isLabel?(r=new v(t.offset.add(s),0),a=new v(e.offsetNextVertex1.add(s),0),n=new v(e.offsetNextVertex2.add(s),0)):(r=o.multiply(new v(t.offset.multiply(i),0)),a=o.multiply(new v(e.offsetNextVertex1.multiply(i),0)),n=o.multiply(new v(e.offsetNextVertex2.multiply(i),0)));const{viewMat3:d,tileMat3:p}=this.view,u=d.multiply(p).multiply(new v(t.pos,1)),y=u.add(p.multiply(r)).xy,m=u.add(p.multiply(a)).xy,f=u.add(p.multiply(n)).xy,c=T(this.hittestRequest.position,y.xy,m.xy,f.xy);return this.isLabel?b(l,H(this.hittestRequest),c):c}_unpackDirection(t){const e=new A(t),i=C(e,new A(2)),o=M(e,new A(3));return new x(new u(i).subtract(1),new u(o).subtract(1))}_getVertexColor(t){let e=t.color;if(this.visualVariableColor){const i=this.storage.getColorValue(t.id);e=this.visualVariableColor.getColor(i,t.color,new g(!1))}if(this.visualVariableOpacity){const i=this.storage.getOpacityValue(t.id),o=this.visualVariableOpacity.getOpacity(i);e=e.multiply(o)}return e}}t([l(I)],Y.prototype,"visualVariableColor",void 0),t([l(D)],Y.prototype,"visualVariableOpacity",void 0),t([l(B)],Y.prototype,"visualVariableRotation",void 0),t([l(q)],Y.prototype,"visualVariableSizeMinMaxValue",void 0),t([l(E)],Y.prototype,"visualVariableSizeScaleStops",void 0),t([l(F)],Y.prototype,"visualVariableSizeStops",void 0),t([l(W)],Y.prototype,"visualVariableSizeUnitValue",void 0),t([r(_)],Y.prototype,"mosaicInfo",void 0),t([a],Y.prototype,"textRenderPassType",void 0),t([a],Y.prototype,"isBackgroundPass",void 0),t([a],Y.prototype,"isLabel",void 0),t([e(0,n(K)),e(1,n(Q))],Y.prototype,"vertex",null),t([e(0,n(X))],Y.prototype,"fragment",null);export{X as TextFragmentInput,Y as TextShader,K as TextVertexInput};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{getDefinesKey as t}from"../../../../vectorTiles/shaders/vtlMaterialUtils.js";import{vtlTextureBindingUnitSprites as e,vtlHighResCutoff as i}from"../../../definitions.js";import{Technique as l}from"../Technique.js";import{VTLShaderFill as s}from"../shaders/vector-tiles/VTLShaderFill.js";import{VTLShaderOutline as
|
|
2
|
+
import{getDefinesKey as t}from"../../../../vectorTiles/shaders/vtlMaterialUtils.js";import{vtlTextureBindingUnitSprites as e,vtlHighResCutoff as i}from"../../../definitions.js";import{Technique as l}from"../Technique.js";import{VTLShaderFill as s}from"../shaders/vector-tiles/VTLShaderFill.js";import{VTLShaderOutline as a}from"../shaders/vector-tiles/VTLShaderOutline.js";const n=1/65536;class o extends l{constructor(){super(...arguments),this.type=40,this._fillMesh=null,this._outlineMesh=null,this.shaders={fill:new s,outline:new a}}shutdown(){this._fillMesh&&(this._fillMesh.destroy(),this._fillMesh=null),this._outlineMesh&&(this._outlineMesh.destroy(),this._outlineMesh=null)}render(t,e){const{displayLevel:i,is3D:l,renderPass:s,spriteMosaic:a,styleLayer:n,styleLayerUID:o}=t,{tiles:r}=e;let u=!1;for(const D of r)if(D.layerData.has(o)){const t=D.layerData.get(o);if(t.fillIndexCount>0||t.outlineIndexCount>0){u=!0;break}}if(!u)return;const c=n,f=c.getPaintProperty("fill-pattern"),p=void 0!==f,h=p&&f.isDataDriven;let d;if(p&&!h){const t=f.getValue(i);d=a.getMosaicItemPosition(t,!0)}const y=!p&&c.getPaintValue("fill-antialias",i);let M=!l||p,g=1;if(!p){const t=c.getPaintProperty("fill-color"),e=c.getPaintProperty("fill-opacity");if(!t?.isDataDriven&&!e?.isDataDriven){const t=c.getPaintValue("fill-color",i);g=c.getPaintValue("fill-opacity",i)*t[3],g<1&&(M=!0)}}if((c.hasDataDrivenColor||c.hasDataDrivenOpacity)&&(M=!0),M&&"opaque"===s)return;const m=c.getPaintValue("fill-translate",i),v=c.getPaintValue("fill-translate-anchor",i);("opaque"===s&&!M||"translucent"===s&&M)&&this._drawFill(t,o,c,r,m,v,p,d,h);const x=!c.hasDataDrivenOutlineColor&&c.outlineUsesFillColor&&g<1;y&&"translucent"===s&&!x&&this._drawOutline(t,o,c,r,m,v)}_drawFill(l,s,a,o,r,u,c,f,p){if(c&&!p&&null==f)return;const{context:h,displayLevel:d,drawPhase:y,state:M,painter:g,pixelRatio:m,spriteMosaic:v}=l,x=m>i?2:1,D=a.fillMaterial,P={transform:{dvsMat:null,displayMat:1===u?M.displayMat3:M.displayViewMat3},config:{depth:a.z+n,fillTranslation:r,tileOpacity:1},patternOptions:p||c&&null!=f?{mosaicSize:[0,0],patternFactor:1,tlbr:[0,0,0,0],texture:{texture:null,unit:0}}:null,color:null,opacity:null,colorMix:null,opacityMix:null},_=c?1:0,w=D.key+t({hasPattern:c});if(null!=f){const{page:t,tl:i,br:l}=f,s=i[0],a=l[1],n=l[0],o=i[1],r=v.getPageSize(t);null!=r&&(v.bind(h,9729,t,e),P.patternOptions={mosaicSize:[r[0],r[1]],patternFactor:1,tlbr:[s,a,n,o],texture:{texture:v.getTexture(t),unit:e}})}let O=-1;for(const t of o){if(!t.layerData.has(s))continue;if(t.key.level!==O){O=t.key.level;const e=D.getUniforms();for(const t of e){const e=t.getValue(a,d,O,v);P[t.name]={value:e}}if(c&&null!=P.patternOptions){const e=Math.max(2**(Math.round(d)-t.key.level),1),i=t.rangeX/(x*t.width*e);P.patternOptions.patternFactor=i}}const i=t.layerData.get(s);if(this._fillMesh=i.getMesh(h,{value:0}),!this._fillMesh)continue;const{transform:l,config:n}=P;l.dvsMat=t.transforms.displayViewScreenMat3,n.tileOpacity=1===y?t.fader.value():1;const o={shader:this.shaders.fill,uniforms:P,defines:{fillType:_},optionalAttributes:D.getUsedAttributes(),useComputeBuffer:!1,precisionFactors:D.getPrecisionFactors(),materialKey:w};if(p){const l=P.patternOptions,s=i.patternMap;if(!s||null==l)continue;let a=0;for(const[i,n]of s){const s=v.getPageSize(i);null!=s&&(v.bind(h,9729,i,e),l.mosaicSize=s,l.texture={texture:v.getTexture(i),unit:e},g.submitDrawMeshUntyped(h,o,this._fillMesh,{stencilRef:t.stencilRef,parts:[a++]}))}}else g.submitDrawMeshUntyped(h,o,this._fillMesh,{stencilRef:t.stencilRef});t.triangleCount+=i.fillIndexCount/3}}_drawOutline(t,e,i,l,s,a){const{context:o,displayLevel:r,drawPhase:u,state:c,spriteMosaic:f,painter:p,pixelRatio:h}=t,d=i.outlineMaterial,y=d.key,M=.75/h,g={transform:{dvsMat3:null,displayMat3:1===a?c.displayMat3:c.displayViewMat3},config:{depth:i.z+n,fillTranslation:s,outlineWidth:M,tileOpacity:1},color:null,opacity:null,colorMix:null,opacityMix:null};let m=-1;for(const n of l){if(!n.layerData.has(e))continue;if(n.key.level!==m){m=n.key.level;const t=d.getUniforms();for(const e of t){const t=e.getValue(i,r,m,f);e.name in g&&(g[e.name]={value:t})}}const t=n.layerData.get(e);if(this._outlineMesh=t.getMesh(o,{value:1}),null==this._outlineMesh)continue;const{transform:l,config:s}=g;l.dvsMat3=n.transforms.displayViewScreenMat3,s.tileOpacity=1===u?n.fader.value():1;const a={shader:this.shaders.outline,uniforms:g,defines:{},optionalAttributes:d.getUsedAttributes(),useComputeBuffer:!1,precisionFactors:d.getPrecisionFactors(),materialKey:y};p.submitDrawMeshUntyped(o,a,this._outlineMesh,{stencilRef:n.stencilRef}),n.triangleCount+=t.outlineIndexCount/3}}}export{o as VTLTechniqueFill};
|