@antv/l7-layers 2.6.0 → 2.6.4

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.
Files changed (38) hide show
  1. package/es/core/BaseLayer.d.ts +1 -0
  2. package/es/core/BaseLayer.js +5 -0
  3. package/es/core/BaseLayer.js.map +1 -1
  4. package/es/core/triangulation.d.ts +5 -0
  5. package/es/core/triangulation.js +30 -1
  6. package/es/core/triangulation.js.map +1 -1
  7. package/es/line/models/arc.js +1 -1
  8. package/es/line/models/arc_3d.js +1 -1
  9. package/es/line/models/arcmini.js +2 -2
  10. package/es/plugins/ShaderUniformPlugin.js +1 -1
  11. package/es/plugins/ShaderUniformPlugin.js.map +1 -1
  12. package/es/point/models/extrude.d.ts +6 -0
  13. package/es/point/models/extrude.js +42 -5
  14. package/es/point/models/extrude.js.map +1 -1
  15. package/es/point/models/fill.js +1 -1
  16. package/es/polygon/models/fill.d.ts +2 -0
  17. package/es/polygon/models/fill.js +52 -10
  18. package/es/polygon/models/fill.js.map +1 -1
  19. package/es/utils/geo.d.ts +9 -0
  20. package/es/utils/geo.js +29 -0
  21. package/es/utils/geo.js.map +1 -1
  22. package/lib/core/BaseLayer.js +5 -0
  23. package/lib/core/BaseLayer.js.map +1 -1
  24. package/lib/core/triangulation.js +32 -0
  25. package/lib/core/triangulation.js.map +1 -1
  26. package/lib/line/models/arc.js +1 -1
  27. package/lib/line/models/arc_3d.js +1 -1
  28. package/lib/line/models/arcmini.js +2 -2
  29. package/lib/plugins/ShaderUniformPlugin.js +1 -1
  30. package/lib/plugins/ShaderUniformPlugin.js.map +1 -1
  31. package/lib/point/models/extrude.js +43 -5
  32. package/lib/point/models/extrude.js.map +1 -1
  33. package/lib/point/models/fill.js +1 -1
  34. package/lib/polygon/models/fill.js +50 -8
  35. package/lib/polygon/models/fill.js.map +1 -1
  36. package/lib/utils/geo.js +31 -0
  37. package/lib/utils/geo.js.map +1 -1
  38. package/package.json +5 -5
@@ -47,7 +47,7 @@ var ShaderUniformPlugin = (_dec = injectable(), _dec2 = inject(TYPES.ICameraServ
47
47
  layer.models.forEach(function (model) {
48
48
  var _model$addUniforms;
49
49
 
50
- model.addUniforms((_model$addUniforms = {}, _defineProperty(_model$addUniforms, CameraUniform.ProjectionMatrix, _this.cameraService.getProjectionMatrix()), _defineProperty(_model$addUniforms, CameraUniform.ViewMatrix, _this.cameraService.getViewMatrix()), _defineProperty(_model$addUniforms, CameraUniform.ViewProjectionMatrix, _this.cameraService.getViewProjectionMatrix()), _defineProperty(_model$addUniforms, CameraUniform.Zoom, _this.cameraService.getZoom()), _defineProperty(_model$addUniforms, CameraUniform.ZoomScale, _this.cameraService.getZoomScale()), _defineProperty(_model$addUniforms, CameraUniform.FocalDistance, _this.cameraService.getFocalDistance()), _defineProperty(_model$addUniforms, CameraUniform.CameraPosition, _this.cameraService.getCameraPosition()), _defineProperty(_model$addUniforms, CoordinateUniform.CoordinateSystem, _this.coordinateSystemService.getCoordinateSystem()), _defineProperty(_model$addUniforms, CoordinateUniform.ViewportCenter, _this.coordinateSystemService.getViewportCenter()), _defineProperty(_model$addUniforms, CoordinateUniform.ViewportCenterProjection, _this.coordinateSystemService.getViewportCenterProjection()), _defineProperty(_model$addUniforms, CoordinateUniform.PixelsPerDegree, _this.coordinateSystemService.getPixelsPerDegree()), _defineProperty(_model$addUniforms, CoordinateUniform.PixelsPerDegree2, _this.coordinateSystemService.getPixelsPerDegree2()), _defineProperty(_model$addUniforms, CoordinateUniform.PixelsPerMeter, _this.coordinateSystemService.getPixelsPerMeter()), _defineProperty(_model$addUniforms, CoordinateUniform.Mvp, mvp), _defineProperty(_model$addUniforms, "u_SceneCenterMKT", sceneCenterMKT), _defineProperty(_model$addUniforms, "u_ViewportSize", [width, height]), _defineProperty(_model$addUniforms, "u_ModelMatrix", _this.cameraService.getModelMatrix()), _defineProperty(_model$addUniforms, "u_DevicePixelRatio", $window.devicePixelRatio), _defineProperty(_model$addUniforms, "u_PickingBuffer", layer.getLayerConfig().pickingBuffer || 0), _defineProperty(_model$addUniforms, "u_Dragging", Number(_this.mapService.dragging)), _model$addUniforms));
50
+ model.addUniforms((_model$addUniforms = {}, _defineProperty(_model$addUniforms, CameraUniform.ProjectionMatrix, _this.cameraService.getProjectionMatrix()), _defineProperty(_model$addUniforms, CameraUniform.ViewMatrix, _this.cameraService.getViewMatrix()), _defineProperty(_model$addUniforms, CameraUniform.ViewProjectionMatrix, _this.cameraService.getViewProjectionMatrix()), _defineProperty(_model$addUniforms, CameraUniform.Zoom, _this.cameraService.getZoom()), _defineProperty(_model$addUniforms, CameraUniform.ZoomScale, _this.cameraService.getZoomScale()), _defineProperty(_model$addUniforms, CameraUniform.FocalDistance, _this.cameraService.getFocalDistance()), _defineProperty(_model$addUniforms, CameraUniform.CameraPosition, _this.cameraService.getCameraPosition()), _defineProperty(_model$addUniforms, CoordinateUniform.CoordinateSystem, _this.coordinateSystemService.getCoordinateSystem()), _defineProperty(_model$addUniforms, CoordinateUniform.ViewportCenter, _this.coordinateSystemService.getViewportCenter()), _defineProperty(_model$addUniforms, CoordinateUniform.ViewportCenterProjection, _this.coordinateSystemService.getViewportCenterProjection()), _defineProperty(_model$addUniforms, CoordinateUniform.PixelsPerDegree, _this.coordinateSystemService.getPixelsPerDegree()), _defineProperty(_model$addUniforms, CoordinateUniform.PixelsPerDegree2, _this.coordinateSystemService.getPixelsPerDegree2()), _defineProperty(_model$addUniforms, CoordinateUniform.PixelsPerMeter, _this.coordinateSystemService.getPixelsPerMeter()), _defineProperty(_model$addUniforms, CoordinateUniform.Mvp, mvp), _defineProperty(_model$addUniforms, "u_SceneCenterMKT", sceneCenterMKT), _defineProperty(_model$addUniforms, "u_ViewportSize", [width, height]), _defineProperty(_model$addUniforms, "u_ModelMatrix", _this.cameraService.getModelMatrix()), _defineProperty(_model$addUniforms, "u_DevicePixelRatio", $window.devicePixelRatio), _defineProperty(_model$addUniforms, "u_PickingBuffer", layer.getLayerConfig().pickingBuffer || 0), _defineProperty(_model$addUniforms, "u_shaderPick", Number(layer.getShaderPickStat())), _model$addUniforms));
51
51
  });
52
52
  });
53
53
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugins/ShaderUniformPlugin.ts"],"names":["CameraUniform","CoordinateUniform","TYPES","$window","inject","injectable","ShaderUniformPlugin","ICameraService","ICoordinateSystemService","IRendererService","IMapService","layer","version","mapService","mvp","sceneCenterMKT","hooks","beforeRender","tap","coordinateSystemService","refresh","map","customCoords","getMVPMatrix","getCustomCoordCenter","rendererService","getViewportSize","width","height","models","forEach","model","addUniforms","ProjectionMatrix","cameraService","getProjectionMatrix","ViewMatrix","getViewMatrix","ViewProjectionMatrix","getViewProjectionMatrix","Zoom","getZoom","ZoomScale","getZoomScale","FocalDistance","getFocalDistance","CameraPosition","getCameraPosition","CoordinateSystem","getCoordinateSystem","ViewportCenter","getViewportCenter","ViewportCenterProjection","getViewportCenterProjection","PixelsPerDegree","getPixelsPerDegree","PixelsPerDegree2","getPixelsPerDegree2","PixelsPerMeter","getPixelsPerMeter","Mvp","getModelMatrix","devicePixelRatio","getLayerConfig","pickingBuffer","Number","dragging"],"mappings":";;;;;;;;;AAAA,SACEA,aADF,EAEEC,iBAFF,EASEC,KATF,QAUO,eAVP;AAWA,SAASC,OAAT,QAAwB,gBAAxB;AACA,SAASC,MAAT,EAAiBC,UAAjB,QAAmC,WAAnC;AACA,OAAO,kBAAP;IAUqBC,mB,WADpBD,UAAU,E,UAERD,MAAM,CAACF,KAAK,CAACK,cAAP,C,UAGNH,MAAM,CAACF,KAAK,CAACM,wBAAP,C,UAGNJ,MAAM,CAACF,KAAK,CAACO,gBAAP,C,UAGNL,MAAM,CAACF,KAAK,CAACQ,WAAP,C;;;;;;;;;;;;;;;WAGP,eAAaC,KAAb,EAA4B;AAAA;;AAC1B,UAAMC,OAAO,GAAG,KAAKC,UAAL,CAAgBD,OAAhC;AAEA,UAAIE,GAAG,GAAG,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP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3C,aAAa,CAAC4C,aAPjB,EAOiC,KAAI,CAACV,aAAL,CAAmBW,gBAAnB,EAPjC,uCAQG7C,aAAa,CAAC8C,cARjB,EAQkC,KAAI,CAACZ,aAAL,CAAmBa,iBAAnB,EARlC,uCAUG9C,iBAAiB,CAAC+C,gBAVrB,EAUwC,KAAI,CAAC7B,uBAAL,CAA6B8B,mBAA7B,EAVxC,uCAWGhD,iBAAiB,CAACiD,cAXrB,EAWsC,KAAI,CAAC/B,uBAAL,CAA6BgC,iBAA7B,EAXtC,uCAYGlD,iBAAiB,CAACmD,wBAZrB,EAYgD,KAAI,CAACjC,uBAAL,CAA6BkC,2BAA7B,EAZhD,uCAaGpD,iBAAiB,CAACqD,eAbrB,EAauC,KAAI,CAACnC,uBAAL,CAA6BoC,kBAA7B,EAbvC,uCAcGtD,iBAAiB,CAACuD,gBAdrB,EAcwC,KAAI,CAACrC,uBAAL,CAA6BsC,mBAA7B,EAdxC,uCAeGxD,iBAAiB,CAACyD,cAfrB,EAesC,KAAI,CAACvC,uBAAL,CAA6BwC,iBAA7B,EAftC,uCAiBG1D,iBAAiB,CAAC2D,GAjBrB,EAiB2B9C,GAjB3B,2DAkBoBC,cAlBpB,yDAoBkB,CAACY,KAAD,EAAQC,MAAR,CApBlB,wDAqBiB,KAAI,CAACM,aAAL,CAAmB2B,cAAnB,EArBjB,6DAsBsB1D,OAAO,CAAC2D,gBAtB9B,0DAwBmBnD,KAAK,CAACoD,cAAN,GAAuBC,aAAvB,IAAwC,CAxB3D,qDA0BcC,MAAM,CAAC,KAAI,CAACpD,UAAL,CAAgBqD,QAAjB,CA1BpB;AA4BD,SA7BD;AAgCD,OA7CD;AA8CD;;;;;;;;;;;;;;;;;;;;;;;;;SAhEkB5D,mB","sourcesContent":["import {\n CameraUniform,\n CoordinateUniform,\n ICameraService,\n ICoordinateSystemService,\n ILayer,\n ILayerPlugin,\n IMapService,\n IRendererService,\n TYPES,\n} from '@antv/l7-core';\nimport { $window } from '@antv/l7-utils';\nimport { inject, injectable } from 'inversify';\nimport 'reflect-metadata';\n\n/**\n * 在渲染之前需要获取当前 Shader 所需 Uniform,例如:\n * 1. 从相机服务中获取 View & ProjectionMatrix,当前缩放等级等等\n * 2. 从坐标系服务中获取当前坐标系,例如是否是偏移坐标系\n * @see https://yuque.antfin-inc.com/yuqi.pyq/fgetpa/doml91\n * 3. 当前 Layer 本身的样式属性\n */\n@injectable()\nexport default class ShaderUniformPlugin implements ILayerPlugin {\n @inject(TYPES.ICameraService)\n private readonly cameraService: ICameraService;\n\n @inject(TYPES.ICoordinateSystemService)\n private readonly coordinateSystemService: ICoordinateSystemService;\n\n @inject(TYPES.IRendererService)\n private readonly rendererService: IRendererService;\n\n @inject(TYPES.IMapService)\n private readonly mapService: IMapService;\n\n public apply(layer: ILayer) {\n const version = this.mapService.version;\n\n let mvp = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; // default matrix (for gaode2.x)\n let sceneCenterMKT = [0, 0];\n layer.hooks.beforeRender.tap('ShaderUniformPlugin', () => {\n // 重新计算坐标系参数\n this.coordinateSystemService.refresh();\n\n if (version === 'GAODE2.x') {\n // @ts-ignore\n mvp = this.mapService.map.customCoords.getMVPMatrix();\n // mvp = amapCustomCoords.getMVPMatrix()\n // @ts-ignore\n sceneCenterMKT = this.mapService.getCustomCoordCenter();\n }\n\n const { width, height } = this.rendererService.getViewportSize();\n layer.models.forEach((model) => {\n model.addUniforms({\n // 相机参数,包含 VP 矩阵、缩放等级\n [CameraUniform.ProjectionMatrix]: this.cameraService.getProjectionMatrix(),\n [CameraUniform.ViewMatrix]: this.cameraService.getViewMatrix(),\n [CameraUniform.ViewProjectionMatrix]: this.cameraService.getViewProjectionMatrix(),\n [CameraUniform.Zoom]: this.cameraService.getZoom(),\n [CameraUniform.ZoomScale]: this.cameraService.getZoomScale(),\n [CameraUniform.FocalDistance]: this.cameraService.getFocalDistance(),\n [CameraUniform.CameraPosition]: this.cameraService.getCameraPosition(),\n // 坐标系参数\n [CoordinateUniform.CoordinateSystem]: this.coordinateSystemService.getCoordinateSystem(),\n [CoordinateUniform.ViewportCenter]: this.coordinateSystemService.getViewportCenter(),\n [CoordinateUniform.ViewportCenterProjection]: this.coordinateSystemService.getViewportCenterProjection(),\n [CoordinateUniform.PixelsPerDegree]: this.coordinateSystemService.getPixelsPerDegree(),\n [CoordinateUniform.PixelsPerDegree2]: this.coordinateSystemService.getPixelsPerDegree2(),\n [CoordinateUniform.PixelsPerMeter]: this.coordinateSystemService.getPixelsPerMeter(),\n // 坐标系是高德2.0的时候单独计算\n [CoordinateUniform.Mvp]: mvp,\n u_SceneCenterMKT: sceneCenterMKT,\n // 其他参数,例如视口大小、DPR 等\n u_ViewportSize: [width, height],\n u_ModelMatrix: this.cameraService.getModelMatrix(),\n u_DevicePixelRatio: $window.devicePixelRatio,\n // u_ModelMatrix: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],\n u_PickingBuffer: layer.getLayerConfig().pickingBuffer || 0,\n // TODO: 当前地图是否在拖动\n u_Dragging: Number(this.mapService.dragging),\n });\n });\n\n // TODO:脏检查,决定是否需要渲染\n });\n }\n}\n"],"file":"ShaderUniformPlugin.js"}
1
+ {"version":3,"sources":["../../src/plugins/ShaderUniformPlugin.ts"],"names":["CameraUniform","CoordinateUniform","TYPES","$window","inject","injectable","ShaderUniformPlugin","ICameraService","ICoordinateSystemService","IRendererService","IMapService","layer","version","mapService","mvp","sceneCenterMKT","hooks","beforeRender","tap","coordinateSystemService","refresh","map","customCoords","getMVPMatrix","getCustomCoordCenter","rendererService","getViewportSize","width","height","models","forEach","model","addUniforms","ProjectionMatrix","cameraService","getProjectionMatrix","ViewMatrix","getViewMatrix","ViewProjectionMatrix","getViewProjectionMatrix","Zoom","getZoom","ZoomScale","getZoomScale","FocalDistance","getFocalDistance","CameraPosition","getCameraPosition","CoordinateSystem","getCoordinateSystem","ViewportCenter","getViewportCenter","ViewportCenterProjection","getViewportCenterProjection","PixelsPerDegree","getPixelsPerDegree","PixelsPerDegree2","getPixelsPerDegree2","PixelsPerMeter","getPixelsPerMeter","Mvp","getModelMatrix","devicePixelRatio","getLayerConfig","pickingBuffer","Number","getShaderPickStat"],"mappings":";;;;;;;;;AAAA,SACEA,aADF,EAEEC,iBAFF,EASEC,KATF,QAUO,eAVP;AAWA,SAASC,OAAT,QAAwB,gBAAxB;AACA,SAASC,MAAT,EAAiBC,UAAjB,QAAmC,WAAnC;AACA,OAAO,kBAAP;IAUqBC,mB,WADpBD,UAAU,E,UAERD,MAAM,CAACF,KAAK,CAACK,cAAP,C,UAGNH,MAAM,CAACF,KAAK,CAACM,wBAAP,C,UAGNJ,MAAM,CAACF,KAAK,CAACO,gBAAP,C,UAGNL,MAAM,CAACF,KAAK,CAACQ,WAAP,C;;;;;;;;;;;;;;;WAGP,eAAaC,KAAb,EAA4B;AAAA;;AAC1B,UAAMC,OAAO,GAAG,KAAKC,UAAL,CAAgBD,OAAhC;AAEA,UAAIE,GAAG,GAAG,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,EAAa,CAAb,EAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,EAA4B,CAA5B,EAA+B,CAA/B,EAAkC,CAAlC,EAAqC,CAArC,EAAwC,CAAxC,EAA2C,CAA3C,EAA8C,CAA9C,CAAV;AACA,UAAIC,cAAc,GAAG,CAAC,CAAD,EAAI,CAAJ,CAArB;AACAJ,MAAAA,KAAK,CAACK,KAAN,CAAYC,YAAZ,CAAyBC,GAAzB,CAA6B,qBAA7B,EAAoD,YAAM;AAExD,QAAA,KAAI,CAACC,uBAAL,CAA6BC,OAA7B;;AAEA,YAAIR,OAAO,KAAK,UAAhB,EAA4B;AAE1BE,UAAAA,GAAG,GAAG,KAAI,CAACD,UAAL,CAAgBQ,GAAhB,CAAoBC,YAApB,CAAiCC,YAAjC,EAAN;AAGAR,UAAAA,cAAc,GAAG,KAA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C,uBAAL,CAA6BsC,mBAA7B,EAdxC,uCAeGxD,iBAAiB,CAACyD,cAfrB,EAesC,KAAI,CAACvC,uBAAL,CAA6BwC,iBAA7B,EAftC,uCAiBG1D,iBAAiB,CAAC2D,GAjBrB,EAiB2B9C,GAjB3B,2DAkBoBC,cAlBpB,yDAoBkB,CAACY,KAAD,EAAQC,MAAR,CApBlB,wDAqBiB,KAAI,CAACM,aAAL,CAAmB2B,cAAnB,EArBjB,6DAsBsB1D,OAAO,CAAC2D,gBAtB9B,0DAwBmBnD,KAAK,CAACoD,cAAN,GAAuBC,aAAvB,IAAwC,CAxB3D,uDA0BgBC,MAAM,CAACtD,KAAK,CAACuD,iBAAN,EAAD,CA1BtB;AA4BD,SA7BD;AAgCD,OA7CD;AA8CD;;;;;;;;;;;;;;;;;;;;;;;;;SAhEkB5D,mB","sourcesContent":["import {\n CameraUniform,\n CoordinateUniform,\n ICameraService,\n ICoordinateSystemService,\n ILayer,\n ILayerPlugin,\n IMapService,\n IRendererService,\n TYPES,\n} from '@antv/l7-core';\nimport { $window } from '@antv/l7-utils';\nimport { inject, injectable } from 'inversify';\nimport 'reflect-metadata';\n\n/**\n * 在渲染之前需要获取当前 Shader 所需 Uniform,例如:\n * 1. 从相机服务中获取 View & ProjectionMatrix,当前缩放等级等等\n * 2. 从坐标系服务中获取当前坐标系,例如是否是偏移坐标系\n * @see https://yuque.antfin-inc.com/yuqi.pyq/fgetpa/doml91\n * 3. 当前 Layer 本身的样式属性\n */\n@injectable()\nexport default class ShaderUniformPlugin implements ILayerPlugin {\n @inject(TYPES.ICameraService)\n private readonly cameraService: ICameraService;\n\n @inject(TYPES.ICoordinateSystemService)\n private readonly coordinateSystemService: ICoordinateSystemService;\n\n @inject(TYPES.IRendererService)\n private readonly rendererService: IRendererService;\n\n @inject(TYPES.IMapService)\n private readonly mapService: IMapService;\n\n public apply(layer: ILayer) {\n const version = this.mapService.version;\n\n let mvp = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; // default matrix (for gaode2.x)\n let sceneCenterMKT = [0, 0];\n layer.hooks.beforeRender.tap('ShaderUniformPlugin', () => {\n // 重新计算坐标系参数\n this.coordinateSystemService.refresh();\n\n if (version === 'GAODE2.x') {\n // @ts-ignore\n mvp = this.mapService.map.customCoords.getMVPMatrix();\n // mvp = amapCustomCoords.getMVPMatrix()\n // @ts-ignore\n sceneCenterMKT = this.mapService.getCustomCoordCenter();\n }\n\n const { width, height } = this.rendererService.getViewportSize();\n layer.models.forEach((model) => {\n model.addUniforms({\n // 相机参数,包含 VP 矩阵、缩放等级\n [CameraUniform.ProjectionMatrix]: this.cameraService.getProjectionMatrix(),\n [CameraUniform.ViewMatrix]: this.cameraService.getViewMatrix(),\n [CameraUniform.ViewProjectionMatrix]: this.cameraService.getViewProjectionMatrix(),\n [CameraUniform.Zoom]: this.cameraService.getZoom(),\n [CameraUniform.ZoomScale]: this.cameraService.getZoomScale(),\n [CameraUniform.FocalDistance]: this.cameraService.getFocalDistance(),\n [CameraUniform.CameraPosition]: this.cameraService.getCameraPosition(),\n // 坐标系参数\n [CoordinateUniform.CoordinateSystem]: this.coordinateSystemService.getCoordinateSystem(),\n [CoordinateUniform.ViewportCenter]: this.coordinateSystemService.getViewportCenter(),\n [CoordinateUniform.ViewportCenterProjection]: this.coordinateSystemService.getViewportCenterProjection(),\n [CoordinateUniform.PixelsPerDegree]: this.coordinateSystemService.getPixelsPerDegree(),\n [CoordinateUniform.PixelsPerDegree2]: this.coordinateSystemService.getPixelsPerDegree2(),\n [CoordinateUniform.PixelsPerMeter]: this.coordinateSystemService.getPixelsPerMeter(),\n // 坐标系是高德2.0的时候单独计算\n [CoordinateUniform.Mvp]: mvp,\n u_SceneCenterMKT: sceneCenterMKT,\n // 其他参数,例如视口大小、DPR 等\n u_ViewportSize: [width, height],\n u_ModelMatrix: this.cameraService.getModelMatrix(),\n u_DevicePixelRatio: $window.devicePixelRatio,\n // u_ModelMatrix: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],\n u_PickingBuffer: layer.getLayerConfig().pickingBuffer || 0,\n // TODO: 当前地图是否在拖动\n u_shaderPick: Number(layer.getShaderPickStat()),\n });\n });\n\n // TODO:脏检查,决定是否需要渲染\n });\n }\n}\n"],"file":"ShaderUniformPlugin.js"}
@@ -6,6 +6,12 @@ export default class ExtrudeModel extends BaseModel {
6
6
  u_dataTexture: import("@antv/l7-core").ITexture2D;
7
7
  u_cellTypeLayout: number[];
8
8
  u_opacity: number;
9
+ u_linearColor: number;
10
+ u_sourceColor: number[];
11
+ u_targetColor: number[];
12
+ u_opacitylinear: number;
13
+ u_opacitylinear_dir: number;
14
+ u_lightEnable: number;
9
15
  };
10
16
  initModels(): IModel[];
11
17
  buildModels(): IModel[];
@@ -10,12 +10,13 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
10
10
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
11
11
 
12
12
  import { AttributeType, gl } from '@antv/l7-core';
13
+ import { rgb2arr } from '@antv/l7-utils';
13
14
  import BaseModel from '../../core/BaseModel';
14
15
  import { PointExtrudeTriangulation } from '../../core/triangulation';
15
16
  import { lglt2xyz } from '../../earth/utils';
16
17
  import { calculateCentroid } from '../../utils/geo';
17
- var pointExtrudeFrag = "varying vec4 v_color;\nuniform float u_opacity: 1.0;\n\n#pragma include \"picking\"\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n gl_FragColor = v_color;\n // gl_FragColor.a *= u_opacity;\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
18
- var pointExtrudeVert = "precision highp float;\n\n#define pi 3.1415926535\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec3 a_Position;\nattribute vec3 a_Pos;\nattribute vec4 a_Color;\nattribute vec3 a_Size;\nattribute vec3 a_Normal;\n\nuniform float u_globel;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nvarying vec4 v_color;\n\nuniform float u_opacity : 1;\n\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nfloat getYRadian(float x, float z) {\n if(x > 0.0 && z > 0.0) {\n return atan(x/z);\n } else if(x > 0.0 && z <= 0.0){\n return atan(-z/x) + pi/2.0;\n } else if(x <= 0.0 && z <= 0.0) {\n return pi + atan(x/z); //atan(x/z) + \n } else {\n return atan(z/-x) + pi*3.0/2.0;\n }\n}\n\nfloat getXRadian(float y, float r) {\n return atan(y/r);\n}\n\nvoid main() {\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n vec3 size = a_Size * a_Position;\n\n vec2 offset = project_pixel(size.xy);\n\n vec4 project_pos = project_position(vec4(a_Pos.xy, 0., 1.0));\n\n vec4 pos = vec4(project_pos.xy + offset, project_pixel(size.z), 1.0);\n\n float lightWeight = calc_lighting(pos);\n v_color =vec4(a_Color.rgb * lightWeight, a_Color.w);\n\n // gl_Position = project_common_position_to_clipspace(pos);\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * pos;\n } else {\n gl_Position = project_common_position_to_clipspace(pos);\n }\n \n if(u_globel > 0.0) {\n // \u5728\u5730\u7403\u6A21\u5F0F\u4E0B\uFF0C\u5C06\u539F\u672C\u5782\u76F4\u4E8E xy \u5E73\u9762\u7684\u5706\u67F1\u8C03\u6574\u59FF\u6001\u5230\u9002\u5E94\u5706\u7684\u89D2\u5EA6\n //\u65CB\u8F6C\u77E9\u9635mx\uFF0C\u521B\u5EFA\u7ED5x\u8F74\u65CB\u8F6C\u77E9\u9635\n float r = sqrt(a_Pos.z*a_Pos.z + a_Pos.x*a_Pos.x);\n float xRadian = getXRadian(a_Pos.y, r);\n float xcos = cos(xRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u4F59\u5F26\u503C\n float xsin = sin(xRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u6B63\u5F26\u503C\n mat4 mx = mat4(\n 1,0,0,0, \n 0,xcos,-xsin,0, \n 0,xsin,xcos,0, \n 0,0,0,1);\n\n //\u65CB\u8F6C\u77E9\u9635my\uFF0C\u521B\u5EFA\u7ED5y\u8F74\u65CB\u8F6C\u77E9\u9635\n float yRadian = getYRadian(a_Pos.x, a_Pos.z);\n float ycos = cos(yRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u4F59\u5F26\u503C\n float ysin = sin(yRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u6B63\u5F26\u503C\n mat4 my = mat4(\n ycos,0,-ysin,0, \n 0,1,0,0, \n ysin,0,ycos,0, \n 0,0,0,1);\n\n gl_Position = u_ViewProjectionMatrix * vec4(( my * mx * vec4(a_Position * a_Size, 1.0)).xyz + a_Pos, 1.0);\n }\n\n setPickingColor(a_PickingColor);\n}\n";
18
+ var pointExtrudeFrag = "varying vec4 v_color;\nuniform float u_opacity: 1.0;\n\nvarying float v_z;\nvarying float v_lightWeight;\n\n#pragma include \"picking\"\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\nuniform float u_linearColor: 0;\nuniform vec4 u_sourceColor;\nuniform vec4 u_targetColor;\n\nuniform float u_opacitylinear: 0.0;\nuniform float u_opacitylinear_dir: 1.0;\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n\n // \u8BBE\u7F6E\u5706\u67F1\u7684\u5E95\u8272\n if(u_linearColor == 1.0) { // \u4F7F\u7528\u6E10\u53D8\u989C\u8272\n gl_FragColor = mix(u_sourceColor, u_targetColor, v_z);\n gl_FragColor.rgb *= v_lightWeight;\n } else { // \u4F7F\u7528 color \u65B9\u6CD5\u4F20\u5165\u7684\u989C\u8272\n gl_FragColor = v_color;\n }\n\n // \u5E94\u7528\u900F\u660E\u5EA6\n gl_FragColor.a *= opacity;\n\n // \u5F00\u542F\u900F\u660E\u5EA6\u6E10\u53D8\n if(u_opacitylinear > 0.0) {\n gl_FragColor.a *= u_opacitylinear_dir > 0.0 ? (1.0 - v_z): v_z;\n }\n\n // picking\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
19
+ var pointExtrudeVert = "precision highp float;\n\n#define pi 3.1415926535\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute vec3 a_Position;\nattribute vec3 a_Pos;\nattribute vec4 a_Color;\nattribute vec3 a_Size;\nattribute vec3 a_Normal;\n\nuniform float u_globel;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nvarying vec4 v_color;\n\nuniform float u_opacity : 1;\nuniform float u_lightEnable: 1;\n\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\nvarying float v_z;\nvarying float v_lightWeight;\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"light\"\n#pragma include \"picking\"\n\nfloat getYRadian(float x, float z) {\n if(x > 0.0 && z > 0.0) {\n return atan(x/z);\n } else if(x > 0.0 && z <= 0.0){\n return atan(-z/x) + pi/2.0;\n } else if(x <= 0.0 && z <= 0.0) {\n return pi + atan(x/z); //atan(x/z) + \n } else {\n return atan(z/-x) + pi*3.0/2.0;\n }\n}\n\nfloat getXRadian(float y, float r) {\n return atan(y/r);\n}\n\nvoid main() {\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n vec3 size = a_Size * a_Position;\n\n // a_Position.z \u662F\u5728\u6784\u5EFA\u7F51\u683C\u7684\u65F6\u5019\u4F20\u5165\u7684\u6807\u51C6\u503C 0 - 1\uFF0C\u5728\u63D2\u503C\u5668\u63D2\u503C\u53EF\u4EE5\u83B7\u53D6 0\uFF5E1 \u7EBF\u6027\u6E10\u53D8\u7684\u503C\n v_z = a_Position.z;\n\n vec2 offset = project_pixel(size.xy);\n\n vec4 project_pos = project_position(vec4(a_Pos.xy, 0., 1.0));\n\n vec4 pos = vec4(project_pos.xy + offset, project_pixel(size.z), 1.0);\n\n float lightWeight = u_lightEnable > 0.0 ? calc_lighting(pos): 1.0;\n v_lightWeight = lightWeight;\n v_color =vec4(a_Color.rgb * lightWeight, a_Color.w);\n\n // gl_Position = project_common_position_to_clipspace(pos);\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * pos;\n } else {\n gl_Position = project_common_position_to_clipspace(pos);\n }\n \n if(u_globel > 0.0) {\n // \u5728\u5730\u7403\u6A21\u5F0F\u4E0B\uFF0C\u5C06\u539F\u672C\u5782\u76F4\u4E8E xy \u5E73\u9762\u7684\u5706\u67F1\u8C03\u6574\u59FF\u6001\u5230\u9002\u5E94\u5706\u7684\u89D2\u5EA6\n //\u65CB\u8F6C\u77E9\u9635mx\uFF0C\u521B\u5EFA\u7ED5x\u8F74\u65CB\u8F6C\u77E9\u9635\n float r = sqrt(a_Pos.z*a_Pos.z + a_Pos.x*a_Pos.x);\n float xRadian = getXRadian(a_Pos.y, r);\n float xcos = cos(xRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u4F59\u5F26\u503C\n float xsin = sin(xRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u6B63\u5F26\u503C\n mat4 mx = mat4(\n 1,0,0,0, \n 0,xcos,-xsin,0, \n 0,xsin,xcos,0, \n 0,0,0,1);\n\n //\u65CB\u8F6C\u77E9\u9635my\uFF0C\u521B\u5EFA\u7ED5y\u8F74\u65CB\u8F6C\u77E9\u9635\n float yRadian = getYRadian(a_Pos.x, a_Pos.z);\n float ycos = cos(yRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u4F59\u5F26\u503C\n float ysin = sin(yRadian);//\u6C42\u89E3\u65CB\u8F6C\u89D2\u5EA6\u6B63\u5F26\u503C\n mat4 my = mat4(\n ycos,0,-ysin,0, \n 0,1,0,0, \n ysin,0,ycos,0, \n 0,0,0,1);\n\n gl_Position = u_ViewProjectionMatrix * vec4(( my * mx * vec4(a_Position * a_Size, 1.0)).xyz + a_Pos, 1.0);\n }\n\n setPickingColor(a_PickingColor);\n}\n";
19
20
 
20
21
  var ExtrudeModel = function (_BaseModel) {
21
22
  _inherits(ExtrudeModel, _BaseModel);
@@ -33,7 +34,16 @@ var ExtrudeModel = function (_BaseModel) {
33
34
  value: function getUninforms() {
34
35
  var _ref = this.layer.getLayerConfig(),
35
36
  _ref$opacity = _ref.opacity,
36
- opacity = _ref$opacity === void 0 ? 1 : _ref$opacity;
37
+ opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
38
+ sourceColor = _ref.sourceColor,
39
+ targetColor = _ref.targetColor,
40
+ _ref$opacityLinear = _ref.opacityLinear,
41
+ opacityLinear = _ref$opacityLinear === void 0 ? {
42
+ enable: false,
43
+ dir: 'up'
44
+ } : _ref$opacityLinear,
45
+ _ref$lightEnable = _ref.lightEnable,
46
+ lightEnable = _ref$lightEnable === void 0 ? true : _ref$lightEnable;
37
47
 
38
48
  if (this.dataTextureTest && this.dataTextureNeedUpdate({
39
49
  opacity: opacity
@@ -66,11 +76,27 @@ var ExtrudeModel = function (_BaseModel) {
66
76
  });
67
77
  }
68
78
 
79
+ var useLinearColor = 0;
80
+ var sourceColorArr = [0, 0, 0, 0];
81
+ var targetColorArr = [0, 0, 0, 0];
82
+
83
+ if (sourceColor && targetColor) {
84
+ sourceColorArr = rgb2arr(sourceColor);
85
+ targetColorArr = rgb2arr(targetColor);
86
+ useLinearColor = 1;
87
+ }
88
+
69
89
  return {
70
90
  u_globel: this.mapService.version === 'GLOBEL' ? 1 : 0,
71
91
  u_dataTexture: this.dataTexture,
72
92
  u_cellTypeLayout: this.getCellTypeLayout(),
73
- u_opacity: _isNumber(opacity) ? opacity : 1.0
93
+ u_opacity: _isNumber(opacity) ? opacity : 1.0,
94
+ u_linearColor: useLinearColor,
95
+ u_sourceColor: sourceColorArr,
96
+ u_targetColor: targetColorArr,
97
+ u_opacitylinear: Number(opacityLinear.enable),
98
+ u_opacitylinear_dir: opacityLinear.dir === 'up' ? 1.0 : 0.0,
99
+ u_lightEnable: Number(lightEnable)
74
100
  };
75
101
  }
76
102
  }, {
@@ -81,12 +107,23 @@ var ExtrudeModel = function (_BaseModel) {
81
107
  }, {
82
108
  key: "buildModels",
83
109
  value: function buildModels() {
110
+ var _ref2 = this.layer.getLayerConfig(),
111
+ _ref2$depth = _ref2.depth,
112
+ depth = _ref2$depth === void 0 ? true : _ref2$depth;
113
+
84
114
  return [this.layer.buildLayerModel({
85
115
  moduleName: 'pointExtrude2',
86
116
  vertexShader: pointExtrudeVert,
87
117
  fragmentShader: pointExtrudeFrag,
88
118
  triangulation: PointExtrudeTriangulation,
89
- blend: this.getBlend()
119
+ blend: this.getBlend(),
120
+ cull: {
121
+ enable: true,
122
+ face: gl.BACK
123
+ },
124
+ depth: {
125
+ enable: depth
126
+ }
90
127
  })];
91
128
  }
92
129
  }, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/point/models/extrude.ts"],"names":["AttributeType","gl","BaseModel","PointExtrudeTriangulation","lglt2xyz","calculateCentroid","ExtrudeModel","layer","getLayerConfig","opacity","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","LUMINANCE","type","FLOAT","u_globel","mapService","version","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","buildModels","buildLayerModel","moduleName","vertexShader","pointExtrudeVert","fragmentShader","pointExtrudeFrag","triangulation","blend","getBlend","destroy","isGlobel","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","buffersize","Array","isArray","STATIC_DRAW","normal","coordinates"],"mappings":";;;;;;;;;;;AAAA,SAASA,aAAT,EAAwBC,EAAxB,QAA0D,eAA1D;AAEA,OAAOC,SAAP,MAAoD,sBAApD;AACA,SAASC,yBAAT,QAA0C,0BAA1C;AACA,SAASC,QAAT,QAAyB,mBAAzB;AACA,SAASC,iBAAT,QAAkC,iBAAlC;;;;IAOqBC,Y;;;;;;;;;;;;;WACnB,wBAAsB;AACpB,iBAEI,KAAKC,KAAL,CAAWC,cAAX,EAFJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;;AAGA,UACE,KAAKC,eAAL,IACA,KAAKC,qBAAL,CAA2B;AACzBF,QAAAA,OAAO,EAAPA;AADyB,OAA3B,CAFF,EAKE;AACA,aAAKG,oBAAL,CAA0B;AACxBH,UAAAA,OAAO,EAAPA;AADwB,SAA1B;AAGA,YAAMI,UAAU,GAAG,KAAKN,KAAL,CAAWO,cAAX,EAAnB;;AACA,iCAAgC,KAAKC,YAAL,CAC9B,KAAKC,UADyB,EAE9BH,UAF8B,EAG9B,KAAKI,cAHyB,CAAhC;AAAA,YAAQC,IAAR,sBAAQA,IAAR;AAAA,YAAcC,KAAd,sBAAcA,KAAd;AAAA,YAAqBC,MAArB,sBAAqBA,MAArB;;AAKA,aAAKC,QAAL,GAAgBD,MAAhB;AAEA,aAAKE,WAAL,GACE,KAAKN,UAAL,GAAkB,CAAlB,IAAuBE,IAAI,CAACK,MAAL,GAAc,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,EAAiC,CAAjC,CAAP;AACD;AACF;AArBS;AAHoC,OAAlD;AA2BD;;;;EAlKuClE,S;;SAArBI,Y","sourcesContent":["import { AttributeType, gl, IEncodeFeature, IModel } from '@antv/l7-core';\nimport { isNumber } from 'lodash';\nimport BaseModel, { styleOffset, styleSingle } from '../../core/BaseModel';\nimport { PointExtrudeTriangulation } from '../../core/triangulation';\nimport { lglt2xyz } from '../../earth/utils';\nimport { calculateCentroid } from '../../utils/geo';\nimport pointExtrudeFrag from '../shaders/extrude_frag.glsl';\nimport pointExtrudeVert from '../shaders/extrude_vert.glsl';\ninterface IPointLayerStyleOptions {\n opacity: styleSingle;\n offsets: styleOffset;\n}\nexport default class ExtrudeModel extends BaseModel {\n public getUninforms() {\n const {\n opacity = 1,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n })\n ) {\n this.judgeStyleAttributes({\n opacity,\n });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n u_globel: this.mapService.version === 'GLOBEL' ? 1 : 0,\n\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity || 1.0,\n // u_offsets: offsets || [0, 0],\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n };\n }\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointExtrude2',\n vertexShader: pointExtrudeVert,\n fragmentShader: pointExtrudeFrag,\n triangulation: PointExtrudeTriangulation,\n blend: this.getBlend(),\n // primitive: gl.POINTS,\n }),\n ];\n }\n public clearModels() {\n this.dataTexture?.destroy();\n }\n protected registerBuiltinAttributes() {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size } = feature;\n if (size) {\n let buffersize: number[] = [];\n if (Array.isArray(size)) {\n buffersize =\n size.length === 2 ? [size[0], size[0], size[1]] : size;\n }\n if (!Array.isArray(size)) {\n buffersize = [size, size, size];\n }\n return buffersize;\n } else {\n return [2, 2, 2];\n }\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'pos',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Pos',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (feature: IEncodeFeature, featureIdx: number) => {\n const coordinates = calculateCentroid(feature.coordinates);\n if (isGlobel) {\n // TODO: 在地球模式下需要将传入 shader 的经纬度转化成对应的 xyz 坐标\n return lglt2xyz([coordinates[0], coordinates[1]]) as [\n number,\n number,\n number,\n ];\n } else {\n return [coordinates[0], coordinates[1], 0];\n }\n },\n },\n });\n }\n}\n"],"file":"extrude.js"}
1
+ {"version":3,"sources":["../../../src/point/models/extrude.ts"],"names":["AttributeType","gl","rgb2arr","BaseModel","PointExtrudeTriangulation","lglt2xyz","calculateCentroid","ExtrudeModel","layer","getLayerConfig","opacity","sourceColor","targetColor","opacityLinear","enable","dir","lightEnable","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","LUMINANCE","type","FLOAT","useLinearColor","sourceColorArr","targetColorArr","u_globel","mapService","version","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_linearColor","u_sourceColor","u_targetColor","u_opacitylinear","Number","u_opacitylinear_dir","u_lightEnable","buildModels","depth","buildLayerModel","moduleName","vertexShader","pointExtrudeVert","fragmentShader","pointExtrudeFrag","triangulation","blend","getBlend","cull","face","BACK","destroy","isGlobel","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","buffersize","Array","isArray","STATIC_DRAW","normal","coordinates"],"mappings":";;;;;;;;;;;AAAA,SAASA,aAAT,EAAwBC,EAAxB,QAA0D,eAA1D;AACA,SAASC,OAAT,QAAwB,gBAAxB;AAEA,OAAOC,SAAP,MAAoD,sBAApD;AACA,SAASC,yBAAT,QAA0C,0BAA1C;AACA,SAASC,QAAT,QAAyB,mBAAzB;AACA,SAASC,iBAAT,QAAkC,iBAAlC;;;;IAiBqBC,Y;;;;;;;;;;;;;WACnB,wBAAsB;AACpB,iBAYI,KAAKC,KAAL,CAAWC,cAAX,EAZJ;AAAA,8BACEC,OADF;AAAA,UACEA,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AAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAE3E,EAAE,CAAC4E,YAFJ;AAGNpD,YAAAA,IAAI,EAAE,EAHA;AAINU,YAAAA,IAAI,EAAElC,EAAE,CAACmC;AAJH,WAFE;AAQV0C,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBAACC,OAAD,EAA0BC,UAA1B,EAAiD;AACvD,gBAAMQ,WAAW,GAAGnF,iBAAiB,CAAC0E,OAAO,CAACS,WAAT,CAArC;;AACA,gBAAIpB,QAAJ,EAAc;AAEZ,qBAAOhE,QAAQ,CAAC,CAACoF,WAAW,CAAC,CAAD,CAAZ,EAAiBA,WAAW,CAAC,CAAD,CAA5B,CAAD,CAAf;AAKD,aAPD,MAOO;AACL,qBAAO,CAACA,WAAW,CAAC,CAAD,CAAZ,EAAiBA,WAAW,CAAC,CAAD,CAA5B,EAAiC,CAAjC,CAAP;AACD;AACF;AArBS;AAHoC,OAAlD;AA2BD;;;;EA7MuCtF,S;;SAArBI,Y","sourcesContent":["import { AttributeType, gl, IEncodeFeature, IModel } from '@antv/l7-core';\nimport { rgb2arr } from '@antv/l7-utils';\nimport { isNumber } from 'lodash';\nimport BaseModel, { styleOffset, styleSingle } from '../../core/BaseModel';\nimport { PointExtrudeTriangulation } from '../../core/triangulation';\nimport { lglt2xyz } from '../../earth/utils';\nimport { calculateCentroid } from '../../utils/geo';\nimport pointExtrudeFrag from '../shaders/extrude_frag.glsl';\nimport pointExtrudeVert from '../shaders/extrude_vert.glsl';\ninterface IPointLayerStyleOptions {\n depth: boolean;\n opacity: styleSingle;\n offsets: styleOffset;\n\n sourceColor?: string; // 可选参数、设置渐变色的起始颜色(all)\n targetColor?: string; // 可选参数、设置渐变色的终点颜色(all)\n opacityLinear?: {\n enable: boolean;\n dir: string;\n };\n\n lightEnable: boolean;\n}\nexport default class ExtrudeModel extends BaseModel {\n public getUninforms() {\n const {\n opacity = 1,\n\n sourceColor,\n targetColor,\n\n opacityLinear = {\n enable: false,\n dir: 'up',\n },\n\n lightEnable = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n })\n ) {\n this.judgeStyleAttributes({\n opacity,\n });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n\n // 转化渐变色\n let useLinearColor = 0; // 默认不生效\n let sourceColorArr = [0, 0, 0, 0];\n let targetColorArr = [0, 0, 0, 0];\n if (sourceColor && targetColor) {\n sourceColorArr = rgb2arr(sourceColor);\n targetColorArr = rgb2arr(targetColor);\n useLinearColor = 1;\n }\n\n return {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n u_globel: this.mapService.version === 'GLOBEL' ? 1 : 0,\n\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity || 1.0,\n // u_offsets: offsets || [0, 0],\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n\n // 渐变色支持参数\n u_linearColor: useLinearColor,\n u_sourceColor: sourceColorArr,\n u_targetColor: targetColorArr,\n\n // 透明度渐变\n u_opacitylinear: Number(opacityLinear.enable),\n u_opacitylinear_dir: opacityLinear.dir === 'up' ? 1.0 : 0.0,\n\n // 光照计算开关\n u_lightEnable: Number(lightEnable),\n };\n }\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n const {\n depth = true,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointExtrude2',\n vertexShader: pointExtrudeVert,\n fragmentShader: pointExtrudeFrag,\n triangulation: PointExtrudeTriangulation,\n blend: this.getBlend(),\n cull: {\n enable: true,\n face: gl.BACK,\n },\n depth: {\n enable: depth,\n },\n // primitive: gl.POINTS,\n }),\n ];\n }\n public clearModels() {\n this.dataTexture?.destroy();\n }\n protected registerBuiltinAttributes() {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size } = feature;\n if (size) {\n let buffersize: number[] = [];\n if (Array.isArray(size)) {\n buffersize =\n size.length === 2 ? [size[0], size[0], size[1]] : size;\n }\n if (!Array.isArray(size)) {\n buffersize = [size, size, size];\n }\n return buffersize;\n } else {\n return [2, 2, 2];\n }\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'normal',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Normal',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n return normal;\n },\n },\n });\n this.styleAttributeService.registerStyleAttribute({\n name: 'pos',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Pos',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (feature: IEncodeFeature, featureIdx: number) => {\n const coordinates = calculateCentroid(feature.coordinates);\n if (isGlobel) {\n // TODO: 在地球模式下需要将传入 shader 的经纬度转化成对应的 xyz 坐标\n return lglt2xyz([coordinates[0], coordinates[1]]) as [\n number,\n number,\n number,\n ];\n } else {\n return [coordinates[0], coordinates[1], 0];\n }\n },\n },\n });\n }\n}\n"],"file":"extrude.js"}
@@ -14,7 +14,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
14
14
  import { AttributeType, gl } from '@antv/l7-core';
15
15
  import BaseModel from '../../core/BaseModel';
16
16
  import { GlobelPointFillTriangulation, PointFillTriangulation } from '../../core/triangulation';
17
- var pointFillFrag = "#define Animate 0.0\n\nuniform float u_globel;\nuniform float u_blur : 0;\n// uniform float u_stroke_width : 1;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\n\nvoid main() {\n int shape = int(floor(v_data.w + 0.5));\n\n \n vec4 textrueStroke = vec4(\n styleMappingMat[1][0],\n styleMappingMat[1][1],\n styleMappingMat[1][2],\n styleMappingMat[1][3]\n );\n\n float opacity = styleMappingMat[0][0];\n float stroke_opacity = styleMappingMat[0][1];\n float strokeWidth = styleMappingMat[0][2];\n vec4 strokeColor = textrueStroke == vec4(0) ? v_color : textrueStroke;\n\n lowp float antialiasblur = v_data.z;\n float antialiased_blur = -max(u_blur, antialiasblur);\n // float r = v_radius / (v_radius + u_stroke_width);\n float r = v_radius / (v_radius + strokeWidth);\n\n float outer_df;\n float inner_df;\n // 'circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'\n if (shape == 0) {\n outer_df = sdCircle(v_data.xy, 1.0);\n inner_df = sdCircle(v_data.xy, r);\n } else if (shape == 1) {\n outer_df = sdEquilateralTriangle(1.1 * v_data.xy);\n inner_df = sdEquilateralTriangle(1.1 / r * v_data.xy);\n } else if (shape == 2) {\n outer_df = sdBox(v_data.xy, vec2(1.));\n inner_df = sdBox(v_data.xy, vec2(r));\n } else if (shape == 3) {\n outer_df = sdPentagon(v_data.xy, 0.8);\n inner_df = sdPentagon(v_data.xy, r * 0.8);\n } else if (shape == 4) {\n outer_df = sdHexagon(v_data.xy, 0.8);\n inner_df = sdHexagon(v_data.xy, r * 0.8);\n } else if (shape == 5) {\n outer_df = sdOctogon(v_data.xy, 1.0);\n inner_df = sdOctogon(v_data.xy, r);\n } else if (shape == 6) {\n outer_df = sdHexagram(v_data.xy, 0.52);\n inner_df = sdHexagram(v_data.xy, r * 0.52);\n } else if (shape == 7) {\n outer_df = sdRhombus(v_data.xy, vec2(1.0));\n inner_df = sdRhombus(v_data.xy, vec2(r));\n } else if (shape == 8) {\n outer_df = sdVesica(v_data.xy, 1.1, 0.8);\n inner_df = sdVesica(v_data.xy, r * 1.1, r * 0.8);\n }\n\n if(u_globel > 0.0) {\n // TODO: \u5730\u7403\u6A21\u5F0F\u4E0B\u907F\u514D\u591A\u4F59\u7247\u5143\u7ED8\u5236\uFF0C\u540C\u65F6\u4E5F\u80FD\u907F\u514D\u6709\u7528\u7247\u5143\u5728\u900F\u660E\u4E14\u91CD\u53E0\u7684\u60C5\u51B5\u4E0B\u65E0\u6CD5\u5199\u5165\n // \u4ED8\u51FA\u7684\u4EE3\u4EF7\u662F\u8FB9\u7F18\u4F1A\u6709\u4E00\u4E9B\u952F\u9F7F\n if(outer_df > antialiased_blur + 0.018) discard;\n }\n float opacity_t = smoothstep(0.0, antialiased_blur, outer_df);\n \n \n // float color_t = u_stroke_width < 0.01 ? 0.0 : smoothstep(\n // antialiased_blur,\n // 0.0,\n // inner_df\n // );\n float color_t = strokeWidth < 0.01 ? 0.0 : smoothstep(\n antialiased_blur,\n 0.0,\n inner_df\n );\n float PI = 3.14159;\n float N_RINGS = 3.0;\n float FREQ = 1.0;\n\n gl_FragColor = mix(vec4(v_color.rgb, v_color.a * opacity), strokeColor * stroke_opacity, color_t);\n\n gl_FragColor.a = gl_FragColor.a * opacity_t;\n if(u_aimate.x == Animate) {\n float d = length(v_data.xy);\n float intensity = clamp(cos(d * PI), 0.0, 1.0) * clamp(cos(2.0 * PI * (d * 2.0 * u_aimate.z - u_aimate.y * u_time)), 0.0, 1.0);\n gl_FragColor = vec4(gl_FragColor.xyz, intensity);\n // TODO: \u4F18\u5316\u5728\u6C34\u6CE2\u7EB9\u60C5\u51B5\u4E0B\u7684\u62FE\u53D6\uFF08a == 0 \u65F6\u65E0\u6CD5\u62FE\u53D6\uFF09\n if(d < 0.7) {\n gl_FragColor.a = max(gl_FragColor.a, 0.001);\n }\n }\n \n gl_FragColor = filterColor(gl_FragColor);\n \n}\n";
17
+ var pointFillFrag = "#define Animate 0.0\n\nuniform float u_globel;\nuniform float u_blur : 0;\n// uniform float u_stroke_width : 1;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\n\nvoid main() {\n int shape = int(floor(v_data.w + 0.5));\n\n \n vec4 textrueStroke = vec4(\n styleMappingMat[1][0],\n styleMappingMat[1][1],\n styleMappingMat[1][2],\n styleMappingMat[1][3]\n );\n\n float opacity = styleMappingMat[0][0];\n float stroke_opacity = styleMappingMat[0][1];\n float strokeWidth = styleMappingMat[0][2];\n vec4 strokeColor = textrueStroke == vec4(0) ? v_color : textrueStroke;\n\n lowp float antialiasblur = v_data.z;\n float antialiased_blur = -max(u_blur, antialiasblur);\n // float r = v_radius / (v_radius + u_stroke_width);\n float r = v_radius / (v_radius + strokeWidth);\n\n float outer_df;\n float inner_df;\n // 'circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'\n if (shape == 0) {\n outer_df = sdCircle(v_data.xy, 1.0);\n inner_df = sdCircle(v_data.xy, r);\n } else if (shape == 1) {\n outer_df = sdEquilateralTriangle(1.1 * v_data.xy);\n inner_df = sdEquilateralTriangle(1.1 / r * v_data.xy);\n } else if (shape == 2) {\n outer_df = sdBox(v_data.xy, vec2(1.));\n inner_df = sdBox(v_data.xy, vec2(r));\n } else if (shape == 3) {\n outer_df = sdPentagon(v_data.xy, 0.8);\n inner_df = sdPentagon(v_data.xy, r * 0.8);\n } else if (shape == 4) {\n outer_df = sdHexagon(v_data.xy, 0.8);\n inner_df = sdHexagon(v_data.xy, r * 0.8);\n } else if (shape == 5) {\n outer_df = sdOctogon(v_data.xy, 1.0);\n inner_df = sdOctogon(v_data.xy, r);\n } else if (shape == 6) {\n outer_df = sdHexagram(v_data.xy, 0.52);\n inner_df = sdHexagram(v_data.xy, r * 0.52);\n } else if (shape == 7) {\n outer_df = sdRhombus(v_data.xy, vec2(1.0));\n inner_df = sdRhombus(v_data.xy, vec2(r));\n } else if (shape == 8) {\n outer_df = sdVesica(v_data.xy, 1.1, 0.8);\n inner_df = sdVesica(v_data.xy, r * 1.1, r * 0.8);\n }\n\n if(u_globel > 0.0) {\n // TODO: \u5730\u7403\u6A21\u5F0F\u4E0B\u907F\u514D\u591A\u4F59\u7247\u5143\u7ED8\u5236\uFF0C\u540C\u65F6\u4E5F\u80FD\u907F\u514D\u6709\u7528\u7247\u5143\u5728\u900F\u660E\u4E14\u91CD\u53E0\u7684\u60C5\u51B5\u4E0B\u65E0\u6CD5\u5199\u5165\n // \u4ED8\u51FA\u7684\u4EE3\u4EF7\u662F\u8FB9\u7F18\u4F1A\u6709\u4E00\u4E9B\u952F\u9F7F\n if(outer_df > antialiased_blur + 0.018) discard;\n }\n float opacity_t = smoothstep(0.0, antialiased_blur, outer_df);\n \n \n // float color_t = u_stroke_width < 0.01 ? 0.0 : smoothstep(\n // antialiased_blur,\n // 0.0,\n // inner_df\n // );\n float color_t = strokeWidth < 0.01 ? 0.0 : smoothstep(\n antialiased_blur,\n 0.0,\n inner_df\n );\n float PI = 3.14159;\n float N_RINGS = 3.0;\n float FREQ = 1.0;\n\n gl_FragColor = mix(vec4(v_color.rgb, v_color.a * opacity), strokeColor * stroke_opacity, color_t);\n\n gl_FragColor.a = gl_FragColor.a * opacity_t;\n if(u_aimate.x == Animate) {\n float d = length(v_data.xy);\n float intensity = clamp(cos(d * PI), 0.0, 1.0) * clamp(cos(2.0 * PI * (d * 2.0 * u_aimate.z - u_aimate.y * u_time)), 0.0, 1.0);\n gl_FragColor = vec4(gl_FragColor.xyz, intensity);\n // TODO: \u4F18\u5316\u5728\u6C34\u6CE2\u7EB9\u60C5\u51B5\u4E0B\u7684\u62FE\u53D6\uFF08a == 0 \u65F6\u65E0\u6CD5\u62FE\u53D6\uFF09\n if(d < 0.7) {\n gl_FragColor.a = max(gl_FragColor.a, 0.001);\n }\n }\n \n gl_FragColor = filterColor(gl_FragColor);\n gl_FragColor.rgb *= gl_FragColor.a;\n \n}\n";
18
18
  var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute float a_Shape;\n\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\nuniform float u_globel;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\n\nuniform float u_opacity : 1;\nuniform float u_stroke_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\nuniform vec2 u_offsets;\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalStrokeOpacity\"\n#pragma include \"styleMappingCalStrokeWidth\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\n\nvoid main() {\n vec3 extrude = a_Extrude;\n float shape_type = a_Shape;\n float newSize = setPickingSize(a_Size);\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n\n vec2 strokeOpacityAndOffset = calStrokeOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][1] = strokeOpacityAndOffset.r;\n textureOffset = strokeOpacityAndOffset.g;\n\n vec2 strokeWidthAndOffset = calStrokeWidthAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][2] = strokeWidthAndOffset.r;\n textureOffset = strokeWidthAndOffset.g;\n\n vec4 textrueStroke = vec4(-1.0, -1.0, -1.0, -1.0);\n if(hasStroke()) {\n vec2 valueRPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][0] = pos2value(valueRPos, columnWidth, rowHeight); // R\n textureOffset += 1.0;\n\n vec2 valueGPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][1] = pos2value(valueGPos, columnWidth, rowHeight); // G\n textureOffset += 1.0;\n\n vec2 valueBPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][2] = pos2value(valueBPos, columnWidth, rowHeight); // B\n textureOffset += 1.0;\n\n vec2 valueAPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][3] = pos2value(valueAPos, columnWidth, rowHeight); // A\n textureOffset += 1.0;\n } else {\n if(u_stroke_color == vec4(0.0)) {\n styleMappingMat[1][0] = v_color.r;\n styleMappingMat[1][1] = v_color.g;\n styleMappingMat[1][2] = v_color.b;\n styleMappingMat[1][3] = v_color.a;\n } else {\n styleMappingMat[1][0] = u_stroke_color.r;\n styleMappingMat[1][1] = u_stroke_color.g;\n styleMappingMat[1][2] = u_stroke_color.b;\n styleMappingMat[1][3] = u_stroke_color.a;\n }\n }\n\n vec2 textrueOffsets = vec2(0.0, 0.0);\n if(hasOffsets()) {\n vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n\n vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n } else {\n textrueOffsets = u_offsets;\n }\n\n // cal style mapping\n\n // unpack color(vec2)\n v_color = a_Color;\n\n // radius(16-bit)\n v_radius = newSize;\n\n // TODO: billboard\n // anti-alias\n float antialiasblur = 1.0 / u_DevicePixelRatio / (newSize + u_stroke_width);\n\n // construct point coords\n // TODP: /abs(extrude.x) \u662F\u4E3A\u4E86\u517C\u5BB9\u5730\u7403\u6A21\u5F0F\n v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);\n\n // vec2 offset = project_pixel(extrude * (newSize + u_stroke_width) + u_offsets);\n vec2 offset = project_pixel(extrude.xy * (newSize + u_stroke_width) + textrueOffsets);\n vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, 0.0, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n }\n\n if(u_globel > 0.0) {\n gl_Position = u_ViewProjectionMatrix * vec4(a_Position + extrude * newSize * 0.1, 1.0);\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
19
19
  import { mat4, vec3 } from 'gl-matrix';
20
20
 
@@ -5,6 +5,8 @@ export default class FillModel extends BaseModel {
5
5
  u_dataTexture: import("@antv/l7-core").ITexture2D;
6
6
  u_cellTypeLayout: number[];
7
7
  u_opacity: number;
8
+ u_opacitylinear: number;
9
+ u_dir: number;
8
10
  };
9
11
  initModels(): IModel[];
10
12
  buildModels(): IModel[];
@@ -9,11 +9,13 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
9
9
 
10
10
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
11
11
 
12
- import { gl } from '@antv/l7-core';
12
+ import { AttributeType, gl } from '@antv/l7-core';
13
13
  import BaseModel from '../../core/BaseModel';
14
- import { polygonTriangulation } from '../../core/triangulation';
15
- var polygon_frag = "uniform float u_opacity: 1.0;\nvarying vec4 v_Color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n gl_FragColor = v_Color;\n // gl_FragColor.a *= u_opacity;\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
16
- var polygon_vert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Normal;\nattribute float a_Size;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec4 v_Color;\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\nstyleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_Color = a_Color;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n\n";
14
+ import { polygonTriangulation, polygonTriangulationWithCenter } from '../../core/triangulation';
15
+ var polygon_frag = "uniform float u_opacity: 1.0;\nvarying vec4 v_Color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"picking\"\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n gl_FragColor = v_Color;\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
16
+ var polygon_linear_frag = "uniform float u_opacity: 1.0;\nvarying vec4 v_Color;\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\n#pragma include \"picking\"\nuniform float u_opacitylinear: 0.0;\nuniform float u_dir: 1.0;\nvarying vec3 v_linear;\nvarying vec2 v_pos;\n\n\nvoid main() {\n float opacity = styleMappingMat[0][0];\n gl_FragColor = v_Color;\n \n if(u_opacitylinear > 0.0) {\n gl_FragColor.a *= u_dir == 1.0 ? 1.0 - length(v_pos - v_linear.xy)/v_linear.z : length(v_pos - v_linear.xy)/v_linear.z;\n }\n\n gl_FragColor.a *= opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
17
+ var polygon_linear_vert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\n\n\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec4 v_Color;\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nuniform float u_opacitylinear: 0.0;\n\nattribute vec3 a_linear;\nvarying vec3 v_linear;\nvarying vec2 v_pos;\n\nvoid main() {\n if(u_opacitylinear > 0.0) {\n v_linear = a_linear;\n v_pos = a_Position.xy;\n }\n \n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\nstyleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_Color = a_Color;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}";
18
+ var polygon_vert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec4 v_Color;\nuniform float u_opacity: 1.0;\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\nvoid main() {\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\nstyleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n\n v_Color = a_Color;\n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xyz, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xyz, 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n\n";
17
19
 
18
20
  var FillModel = function (_BaseModel) {
19
21
  _inherits(FillModel, _BaseModel);
@@ -31,7 +33,12 @@ var FillModel = function (_BaseModel) {
31
33
  value: function getUninforms() {
32
34
  var _ref = this.layer.getLayerConfig(),
33
35
  _ref$opacity = _ref.opacity,
34
- opacity = _ref$opacity === void 0 ? 1 : _ref$opacity;
36
+ opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
37
+ _ref$opacityLinear = _ref.opacityLinear,
38
+ opacityLinear = _ref$opacityLinear === void 0 ? {
39
+ enable: false,
40
+ dir: 'in'
41
+ } : _ref$opacityLinear;
35
42
 
36
43
  if (this.dataTextureTest && this.dataTextureNeedUpdate({
37
44
  opacity: opacity
@@ -67,7 +74,9 @@ var FillModel = function (_BaseModel) {
67
74
  return {
68
75
  u_dataTexture: this.dataTexture,
69
76
  u_cellTypeLayout: this.getCellTypeLayout(),
70
- u_opacity: _isNumber(opacity) ? opacity : 1.0
77
+ u_opacity: _isNumber(opacity) ? opacity : 1.0,
78
+ u_opacitylinear: Number(opacityLinear.enable),
79
+ u_dir: opacityLinear.dir === 'in' ? 1.0 : 0.0
71
80
  };
72
81
  }
73
82
  }, {
@@ -78,11 +87,18 @@ var FillModel = function (_BaseModel) {
78
87
  }, {
79
88
  key: "buildModels",
80
89
  value: function buildModels() {
90
+ var _ref2 = this.layer.getLayerConfig(),
91
+ _ref2$opacityLinear = _ref2.opacityLinear,
92
+ opacityLinear = _ref2$opacityLinear === void 0 ? {
93
+ enable: false,
94
+ dir: 'in'
95
+ } : _ref2$opacityLinear;
96
+
81
97
  return [this.layer.buildLayerModel({
82
98
  moduleName: 'polygon',
83
- vertexShader: polygon_vert,
84
- fragmentShader: polygon_frag,
85
- triangulation: polygonTriangulation,
99
+ vertexShader: opacityLinear.enable ? polygon_linear_vert : polygon_vert,
100
+ fragmentShader: opacityLinear.enable ? polygon_linear_frag : polygon_frag,
101
+ triangulation: opacityLinear.enable ? polygonTriangulationWithCenter : polygonTriangulation,
86
102
  blend: this.getBlend(),
87
103
  depth: {
88
104
  enable: false
@@ -98,7 +114,33 @@ var FillModel = function (_BaseModel) {
98
114
  }
99
115
  }, {
100
116
  key: "registerBuiltinAttributes",
101
- value: function registerBuiltinAttributes() {}
117
+ value: function registerBuiltinAttributes() {
118
+ var _ref3 = this.layer.getLayerConfig(),
119
+ _ref3$opacityLinear = _ref3.opacityLinear,
120
+ opacityLinear = _ref3$opacityLinear === void 0 ? {
121
+ enable: false,
122
+ dir: 'in'
123
+ } : _ref3$opacityLinear;
124
+
125
+ if (opacityLinear.enable) {
126
+ this.styleAttributeService.registerStyleAttribute({
127
+ name: 'linear',
128
+ type: AttributeType.Attribute,
129
+ descriptor: {
130
+ name: 'a_linear',
131
+ buffer: {
132
+ usage: gl.STATIC_DRAW,
133
+ data: [],
134
+ type: gl.FLOAT
135
+ },
136
+ size: 3,
137
+ update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
138
+ return [vertex[3], vertex[4], vertex[5]];
139
+ }
140
+ }
141
+ });
142
+ }
143
+ }
102
144
  }]);
103
145
 
104
146
  return FillModel;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/polygon/models/fill.ts"],"names":["gl","BaseModel","polygonTriangulation","FillModel","layer","getLayerConfig","opacity","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","buildModels","buildLayerModel","moduleName","vertexShader","polygon_vert","fragmentShader","polygon_frag","triangulation","blend","getBlend","depth","enable","destroy"],"mappings":";;;;;;;;;;;AAAA,SAEEA,EAFF,QAWO,eAXP;AAaA,OAAOC,SAAP,MAAuC,sBAAvC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E,CALY;AAMnBC,UAAAA,MAAM,EAAE;AANW,SAArB,CAVN;AAkBD;;AACD,aAAO;AACLU,QAAAA,aAAa,EAAE,KAAKR,WADf;AAELS,QAAAA,gBAAgB,EAAE,KAAKC,iBAAL,EAFb;AAILC,QAAAA,SAAS,EAAE,UAASxB,OAAT,IAAoBA,OAApB,GAA8B;AAJpC,OAAP;AAMD;;;WAED,sBAA8B;AAC5B,aAAO,KAAKyB,WAAL,EAAP;AACD;;;WAED,uBAA+B;AAC7B,aAAO,CACL,KAAK3B,KAAL,CAAW4B,eAAX,CAA2B;AACzBC,QAAAA,UAAU,EAAE,SADa;AAEzBC,QAAAA,YAAY,EAAEC,YAFW;AAGzBC,QAAAA,cAAc,EAAEC,YAHS;AAIzBC,QAAAA,aAAa,EAAEpC,oBAJU;AAKzBqC,QAAAA,KAAK,EAAE,KAAKC,QAAL,EALkB;AAMzBC,QAAAA,KAAK,EAAE;AAAEC,UAAAA,MAAM,EAAE;AAAV;AANkB,OAA3B,CADK,CAAP;AAUD;;;WAED,uBAAqB;AAAA;;AACnB,gCAAKvB,WAAL,wEAAkBwB,OAAlB;AACD;;;WAED,qCAAsC,CAErC;;;;EAjEoC1C,S;;SAAlBE,S","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n ILayer,\n ILayerModel,\n ILayerPlugin,\n IModel,\n IStyleAttributeService,\n lazyInject,\n TYPES,\n} from '@antv/l7-core';\nimport { isNumber } from 'lodash';\nimport BaseModel, { styleSingle } from '../../core/BaseModel';\nimport { polygonTriangulation } from '../../core/triangulation';\nimport polygon_frag from '../shaders/polygon_frag.glsl';\nimport polygon_vert from '../shaders/polygon_vert.glsl';\n\ninterface IPolygonLayerStyleOptions {\n opacity: styleSingle;\n}\nexport default class FillModel extends BaseModel {\n public getUninforms() {\n const {\n opacity = 1,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {\n this.judgeStyleAttributes({ opacity });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity,\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n };\n }\n\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n return [\n this.layer.buildLayerModel({\n moduleName: 'polygon',\n vertexShader: polygon_vert,\n fragmentShader: polygon_frag,\n triangulation: polygonTriangulation,\n blend: this.getBlend(),\n depth: { enable: false },\n }),\n ];\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n protected registerBuiltinAttributes() {\n // point layer size;\n }\n}\n"],"file":"fill.js"}
1
+ {"version":3,"sources":["../../../src/polygon/models/fill.ts"],"names":["AttributeType","gl","BaseModel","polygonTriangulation","polygonTriangulationWithCenter","FillModel","layer","getLayerConfig","opacity","opacityLinear","enable","dir","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_opacitylinear","Number","u_dir","buildModels","buildLayerModel","moduleName","vertexShader","polygon_linear_vert","polygon_vert","fragmentShader","polygon_linear_frag","polygon_frag","triangulation","blend","getBlend","depth","destroy","styleAttributeService","registerStyleAttribute","name","Attribute","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B8C,QAAAA,KAAK,EAAE,KAAKC,QAAL,EAVkB;AAWzBC,QAAAA,KAAK,EAAE;AAAEzC,UAAAA,MAAM,EAAE;AAAV;AAXkB,OAA3B,CADK,CAAP;AAeD;;;WAED,uBAAqB;AAAA;;AACnB,gCAAKc,WAAL,wEAAkB4B,OAAlB;AACD;;;WAED,qCAAsC;AACpC,kBAKI,KAAK9C,KAAL,CAAWC,cAAX,EALJ;AAAA,sCACEE,aADF;AAAA,UACEA,aADF,oCACkB;AACdC,QAAAA,MAAM,EAAE,KADM;AAEdC,QAAAA,GAAG,EAAE;AAFS,OADlB;;AAMA,UAAIF,aAAa,CAACC,MAAlB,EAA0B;AACxB,aAAK2C,qBAAL,CAA2BC,sBAA3B,CAAkD;AAChDC,UAAAA,IAAI,EAAE,QAD0C;AAEhDzB,UAAAA,IAAI,EAAE9B,aAAa,CAACwD,SAF4B;AAGhDC,UAAAA,UAAU,EAAE;AACVF,YAAAA,IAAI,EAAE,UADI;AAEVG,YAAAA,MAAM,EAAE;AAENC,cAAAA,KAAK,EAAE1D,EAAE,CAAC2D,WAFJ;AAGNxC,cAAAA,IAAI,EAAE,EAHA;AAINU,cAAAA,IAAI,EAAE7B,EAAE,CAAC8B;AAJH,aAFE;AAQV8B,YAAAA,IAAI,EAAE,CARI;AASVC,YAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKNC,MALM,EAMH;AAEH,qBAAO,CAACF,MAAM,CAAC,CAAD,CAAP,EAAYA,MAAM,CAAC,CAAD,CAAlB,EAAuBA,MAAM,CAAC,CAAD,CAA7B,CAAP;AACD;AAlBS;AAHoC,SAAlD;AAwBD;AACF;;;;EAlHoC/D,S;;SAAlBG,S","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n ILayer,\n ILayerModel,\n ILayerPlugin,\n IModel,\n IStyleAttributeService,\n lazyInject,\n TYPES,\n} from '@antv/l7-core';\nimport { isNumber } from 'lodash';\nimport BaseModel, { styleSingle } from '../../core/BaseModel';\nimport {\n polygonTriangulation,\n polygonTriangulationWithCenter,\n} from '../../core/triangulation';\nimport polygon_frag from '../shaders/polygon_frag.glsl';\nimport polygon_linear_frag from '../shaders/polygon_linear_frag.glsl';\nimport polygon_linear_vert from '../shaders/polygon_linear_vert.glsl';\nimport polygon_vert from '../shaders/polygon_vert.glsl';\n\ninterface IPolygonLayerStyleOptions {\n opacity: styleSingle;\n\n opacityLinear: {\n enable: boolean;\n dir: string;\n };\n}\nexport default class FillModel extends BaseModel {\n public getUninforms() {\n const {\n opacity = 1,\n opacityLinear = {\n enable: false,\n dir: 'in',\n },\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n if (this.dataTextureTest && this.dataTextureNeedUpdate({ opacity })) {\n this.judgeStyleAttributes({ opacity });\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n // u_opacity: opacity,\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n\n u_opacitylinear: Number(opacityLinear.enable),\n u_dir: opacityLinear.dir === 'in' ? 1.0 : 0.0,\n };\n }\n\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n const {\n opacityLinear = {\n enable: false,\n dir: 'in',\n },\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n return [\n this.layer.buildLayerModel({\n moduleName: 'polygon',\n vertexShader: opacityLinear.enable ? polygon_linear_vert : polygon_vert,\n fragmentShader: opacityLinear.enable\n ? polygon_linear_frag\n : polygon_frag,\n // triangulation: polygonTriangulation,\n triangulation: opacityLinear.enable\n ? polygonTriangulationWithCenter\n : polygonTriangulation,\n blend: this.getBlend(),\n depth: { enable: false },\n }),\n ];\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n protected registerBuiltinAttributes() {\n const {\n opacityLinear = {\n enable: false,\n dir: 'in',\n },\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n if (opacityLinear.enable) {\n this.styleAttributeService.registerStyleAttribute({\n name: 'linear',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_linear',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.STATIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n normal: number[],\n ) => {\n // center[0] center[1] radius\n return [vertex[3], vertex[4], vertex[5]];\n },\n },\n });\n }\n }\n}\n"],"file":"fill.js"}
package/es/utils/geo.d.ts CHANGED
@@ -1,3 +1,12 @@
1
1
  declare type Position = number[];
2
2
  export declare function calculateCentroid(coord: Position | Position[] | Position[][]): Position;
3
+ /**
4
+ * 计算
5
+ * @param points
6
+ * @returns
7
+ */
8
+ export declare function calculatePointsCenterAndRadius(points: number[]): {
9
+ center: number[];
10
+ radius: number;
11
+ };
3
12
  export {};
package/es/utils/geo.js CHANGED
@@ -21,4 +21,33 @@ export function calculateCentroid(coord) {
21
21
  throw new Error('当前数据不支持标注');
22
22
  }
23
23
  }
24
+ export function calculatePointsCenterAndRadius(points) {
25
+ var maxX = points[0];
26
+ var maxY = points[1];
27
+ var minX = points[0];
28
+ var minY = points[1];
29
+ var xCount = 0;
30
+ var yCount = 0;
31
+ var pCount = 0;
32
+
33
+ for (var i = 0; i < points.length; i += 2) {
34
+ var x = points[i];
35
+ var y = points[i + 1];
36
+
37
+ if (x && y) {
38
+ maxX = Math.max(x, maxX);
39
+ maxY = Math.max(y, maxY);
40
+ minX = Math.min(x, minX);
41
+ minY = Math.min(y, minY);
42
+ xCount += x;
43
+ yCount += y;
44
+ pCount++;
45
+ }
46
+ }
47
+
48
+ return {
49
+ center: [xCount / pCount, yCount / pCount],
50
+ radius: Math.sqrt(Math.pow(maxX - minX, 2) + Math.pow(maxY - minY, 2)) / 2
51
+ };
52
+ }
24
53
  //# sourceMappingURL=geo.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/geo.ts"],"names":["calculateCentroid","coord","Error","coords","xSum","ySum","len","forEach","coor","pos"],"mappings":";AAEA,OAAO,SAASA,iBAAT,CACLC,KADK,EAEK;AAEV,MAAI,UAASA,KAAK,CAAC,CAAD,CAAd,CAAJ,EAAwB;AACtB,WAAOA,KAAP;AACD,GAFD,MAEO,IAAI,UAASA,KAAK,CAAC,CAAD,CAAL,CAAS,CAAT,CAAT,CAAJ,EAA2B;AAChC,UAAM,IAAIC,KAAJ,CAAU,WAAV,CAAN;AACD,GAFM,MAEA,IAAI,UAASD,KAAK,CAAC,CAAD,CAAL,CAAS,CAAT,EAAY,CAAZ,CAAT,CAAJ,EAA8B;AACnC,QAAME,MAAM,GAAGF,KAAf;AACA,QAAIG,IAAI,GAAG,CAAX;AACA,QAAIC,IAAI,GAAG,CAAX;AACA,QAAIC,GAAG,GAAG,CAAV;AACAH,IAAAA,MAAM,CAACI,OAAP,CAAe,UAACC,IAAD,EAAsB;AACnCA,MAAAA,IAAI,CAACD,OAAL,CAAa,UAACE,GAAD,EAAS;AACpBL,QAAAA,IAAI,IAAIK,GAAG,CAAC,CAAD,CAAX;AACAJ,QAAAA,IAAI,IAAII,GAAG,CAAC,CAAD,CAAX;AACAH,QAAAA,GAAG;AACJ,OAJD;AAKD,KAND;AAOA,WAAO,CAACF,IAAI,GAAGE,GAAR,EAAaD,IAAI,GAAGC,GAApB,EAAyB,CAAzB,CAAP;AACD,GAbM,MAaA;AACL,UAAM,IAAIJ,KAAJ,CAAU,WAAV,CAAN;AACD;AACF","sourcesContent":["type Position = number[];\nimport { isNumber } from 'lodash';\nexport function calculateCentroid(\n coord: Position | Position[] | Position[][],\n): Position {\n // let pos = coord as Position;\n if (isNumber(coord[0])) {\n return coord as Position;\n } else if (isNumber(coord[0][0])) {\n throw new Error('当前数据不支持标注');\n } else if (isNumber(coord[0][0][0])) {\n const coords = coord as Position[][];\n let xSum = 0;\n let ySum = 0;\n let len = 0;\n coords.forEach((coor: Position[]) => {\n coor.forEach((pos) => {\n xSum += pos[0];\n ySum += pos[1];\n len++;\n });\n });\n return [xSum / len, ySum / len, 0];\n } else {\n throw new Error('当前数据不支持标注');\n }\n}\n"],"file":"geo.js"}
1
+ {"version":3,"sources":["../../src/utils/geo.ts"],"names":["calculateCentroid","coord","Error","coords","xSum","ySum","len","forEach","coor","pos","calculatePointsCenterAndRadius","points","maxX","maxY","minX","minY","xCount","yCount","pCount","i","length","x","y","Math","max","min","center","radius","sqrt","pow"],"mappings":";AAEA,OAAO,SAASA,iBAAT,CACLC,KADK,EAEK;AAEV,MAAI,UAASA,KAAK,CAAC,CAAD,CAAd,CAAJ,EAAwB;AACtB,WAAOA,KAAP;AACD,GAFD,MAEO,IAAI,UAASA,KAAK,CAAC,CAAD,CAAL,CAAS,CAAT,CAAT,CAAJ,EAA2B;AAChC,UAAM,IAAIC,KAAJ,CAAU,WAAV,CAAN;AACD,GAFM,MAEA,IAAI,UAASD,KAAK,CAAC,CAAD,CAAL,CAAS,CAAT,EAAY,CAAZ,CAAT,CAAJ,EAA8B;AACnC,QAAME,MAAM,GAAGF,KAAf;AACA,QAAIG,IAAI,GAAG,CAAX;AACA,QAAIC,IAAI,GAAG,CAAX;AACA,QAAIC,GAAG,GAAG,CAAV;AACAH,IAAAA,MAAM,CAACI,OAAP,CAAe,UAACC,IAAD,EAAsB;AACnCA,MAAAA,IAAI,CAACD,OAAL,CAAa,UAACE,G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;AACAC,MAAAA,MAAM,IAAIK,CAAV;AACAJ,MAAAA,MAAM,IAAIK,CAAV;AACAJ,MAAAA,MAAM;AACP;AACF;;AACD,SAAO;AACLQ,IAAAA,MAAM,EAAE,CAACV,MAAM,GAAGE,MAAV,EAAkBD,MAAM,GAAGC,MAA3B,CADH;AAELS,IAAAA,MAAM,EAAEJ,IAAI,CAACK,IAAL,CAAUL,IAAI,CAACM,GAAL,CAASjB,IAAI,GAAGE,IAAhB,EAAsB,CAAtB,IAA2BS,IAAI,CAACM,GAAL,CAAShB,IAAI,GAAGE,IAAhB,EAAsB,CAAtB,CAArC,IAAiE;AAFpE,GAAP;AAID","sourcesContent":["type Position = number[];\nimport { isNumber } from 'lodash';\nexport function calculateCentroid(\n coord: Position | Position[] | Position[][],\n): Position {\n // let pos = coord as Position;\n if (isNumber(coord[0])) {\n return coord as Position;\n } else if (isNumber(coord[0][0])) {\n throw new Error('当前数据不支持标注');\n } else if (isNumber(coord[0][0][0])) {\n const coords = coord as Position[][];\n let xSum = 0;\n let ySum = 0;\n let len = 0;\n coords.forEach((coor: Position[]) => {\n coor.forEach((pos) => {\n xSum += pos[0];\n ySum += pos[1];\n len++;\n });\n });\n return [xSum / len, ySum / len, 0];\n } else {\n throw new Error('当前数据不支持标注');\n }\n}\n\n/**\n * 计算\n * @param points\n * @returns\n */\nexport function calculatePointsCenterAndRadius(points: number[]) {\n let maxX = points[0];\n let maxY = points[1];\n let minX = points[0];\n let minY = points[1];\n let xCount = 0;\n let yCount = 0;\n let pCount = 0;\n\n for (let i = 0; i < points.length; i += 2) {\n const x = points[i];\n const y = points[i + 1];\n if (x && y) {\n maxX = Math.max(x, maxX);\n maxY = Math.max(y, maxY);\n minX = Math.min(x, minX);\n minY = Math.min(y, minY);\n xCount += x;\n yCount += y;\n pCount++;\n }\n }\n return {\n center: [xCount / pCount, yCount / pCount],\n radius: Math.sqrt(Math.pow(maxX - minX, 2) + Math.pow(maxY - minY, 2)) / 2,\n };\n}\n"],"file":"geo.js"}
@@ -912,6 +912,11 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
912
912
  }, updateOptions);
913
913
  }
914
914
  }
915
+ }, {
916
+ key: "getShaderPickStat",
917
+ value: function getShaderPickStat() {
918
+ return this.layerService.getShaderPickStat();
919
+ }
915
920
  }, {
916
921
  key: "setEarthTime",
917
922
  value: function setEarthTime(time) {