@antv/l7-layers 2.6.1 → 2.6.5

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 (40) 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/polygon/models/extrude.js +8 -2
  16. package/es/polygon/models/extrude.js.map +1 -1
  17. package/es/polygon/models/fill.d.ts +2 -0
  18. package/es/polygon/models/fill.js +52 -10
  19. package/es/polygon/models/fill.js.map +1 -1
  20. package/es/utils/geo.d.ts +9 -0
  21. package/es/utils/geo.js +29 -0
  22. package/es/utils/geo.js.map +1 -1
  23. package/lib/core/BaseLayer.js +5 -0
  24. package/lib/core/BaseLayer.js.map +1 -1
  25. package/lib/core/triangulation.js +32 -0
  26. package/lib/core/triangulation.js.map +1 -1
  27. package/lib/line/models/arc.js +1 -1
  28. package/lib/line/models/arc_3d.js +1 -1
  29. package/lib/line/models/arcmini.js +2 -2
  30. package/lib/plugins/ShaderUniformPlugin.js +1 -1
  31. package/lib/plugins/ShaderUniformPlugin.js.map +1 -1
  32. package/lib/point/models/extrude.js +43 -5
  33. package/lib/point/models/extrude.js.map +1 -1
  34. package/lib/polygon/models/extrude.js +8 -2
  35. package/lib/polygon/models/extrude.js.map +1 -1
  36. package/lib/polygon/models/fill.js +50 -8
  37. package/lib/polygon/models/fill.js.map +1 -1
  38. package/lib/utils/geo.js +31 -0
  39. package/lib/utils/geo.js.map +1 -1
  40. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugins/ShaderUniformPlugin.ts"],"names":["ShaderUniformPlugin","TYPES","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","CameraUniform","ProjectionMatrix","cameraService","getProjectionMatrix","ViewMatrix","getViewMatrix","ViewProjectionMatrix","getViewProjectionMatrix","Zoom","getZoom","ZoomScale","getZoomScale","FocalDistance","getFocalDistance","CameraPosition","getCameraPosition","CoordinateUniform","CoordinateSystem","getCoordinateSystem","ViewportCenter","getViewportCenter","ViewportCenterProjection","getViewportCenterProjection","PixelsPerDegree","getPixelsPerDegree","PixelsPerDegree2","getPixelsPerDegree2","PixelsPerMeter","getPixelsPerMeter","Mvp","getModelMatrix","$window","devicePixelRatio","getLayerConfig","pickingBuffer","Number","dragging"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AAWA;;AACA;;AACA;;;;IAUqBA,mB,WADpB,4B,UAEE,uBAAOC,cAAMC,cAAb,C,UAGA,uBAAOD,cAAME,wBAAb,C,UAGA,uBAAOF,cAAMG,gBAAb,C,UAGA,uBAAOH,cAAMI,WAAb,C;;;;;;;;;;;WAGD,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;A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qDAWGF,0BAAkBG,cAXrB,EAWsC,KAAI,CAACjC,uBAAL,CAA6BkC,iBAA7B,EAXtC,qDAYGJ,0BAAkBK,wBAZrB,EAYgD,KAAI,CAACnC,uBAAL,CAA6BoC,2BAA7B,EAZhD,qDAaGN,0BAAkBO,eAbrB,EAauC,KAAI,CAACrC,uBAAL,CAA6BsC,kBAA7B,EAbvC,qDAcGR,0BAAkBS,gBAdrB,EAcwC,KAAI,CAACvC,uBAAL,CAA6BwC,mBAA7B,EAdxC,qDAeGV,0BAAkBW,cAfrB,EAesC,KAAI,CAACzC,uBAAL,CAA6B0C,iBAA7B,EAftC,qDAiBGZ,0BAAkBa,GAjBrB,EAiB2BhD,GAjB3B,yEAkBoBC,cAlBpB,uEAoBkB,CAACY,KAAD,EAAQC,MAAR,CApBlB,sEAqBiB,KAAI,CAACO,aAAL,CAAmB4B,cAAnB,EArBjB,2EAsBsBC,iBAAQC,gBAtB9B,wEAwBmBtD,KAAK,CAACuD,cAAN,GAAuBC,aAAvB,IAAwC,CAxB3D,mEA0BcC,MAAM,CAAC,KAAI,CAACvD,UAAL,CAAgBwD,QAAjB,CA1BpB;AA4BD,SA7BD;AAgCD,OA7CD;AA8CD","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":["ShaderUniformPlugin","TYPES","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","CameraUniform","ProjectionMatrix","cameraService","getProjectionMatrix","ViewMatrix","getViewMatrix","ViewProjectionMatrix","getViewProjectionMatrix","Zoom","getZoom","ZoomScale","getZoomScale","FocalDistance","getFocalDistance","CameraPosition","getCameraPosition","CoordinateUniform","CoordinateSystem","getCoordinateSystem","ViewportCenter","getViewportCenter","ViewportCenterProjection","getViewportCenterProjection","PixelsPerDegree","getPixelsPerDegree","PixelsPerDegree2","getPixelsPerDegree2","PixelsPerMeter","getPixelsPerMeter","Mvp","getModelMatrix","$window","devicePixelRatio","getLayerConfig","pickingBuffer","Number","getShaderPickStat"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AAWA;;AACA;;AACA;;;;IAUqBA,mB,WADpB,4B,UAEE,uBAAOC,cAAMC,cAAb,C,UAGA,uBAAOD,cAAME,wBAAb,C,UAGA,uBAAOF,cAAMG,gBAAb,C,UAGA,uBAAOH,cAAM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GP,sBAAcQ,IALjB,EAKwB,KAAI,CAACN,aAAL,CAAmBO,OAAnB,EALxB,qDAMGT,sBAAcU,SANjB,EAM6B,KAAI,CAACR,aAAL,CAAmBS,YAAnB,EAN7B,qDAOGX,sBAAcY,aAPjB,EAOiC,KAAI,CAACV,aAAL,CAAmBW,gBAAnB,EAPjC,qDAQGb,sBAAcc,cARjB,EAQkC,KAAI,CAACZ,aAAL,CAAmBa,iBAAnB,EARlC,qDAUGC,0BAAkBC,gBAVrB,EAUwC,KAAI,CAAC/B,uBAAL,CAA6BgC,mBAA7B,EAVxC,qDAWGF,0BAAkBG,cAXrB,EAWsC,KAAI,CAACjC,uBAAL,CAA6BkC,iBAA7B,EAXtC,qDAYGJ,0BAAkBK,wBAZrB,EAYgD,KAAI,CAACnC,uBAAL,CAA6BoC,2BAA7B,EAZhD,qDAaGN,0BAAkBO,eAbrB,EAauC,KAAI,CAACrC,uBAAL,CAA6BsC,kBAA7B,EAbvC,qDAcGR,0BAAkBS,gBAdrB,EAcwC,KAAI,CAACvC,uBAAL,CAA6BwC,mBAA7B,EAdxC,qDAeGV,0BAAkBW,cAfrB,EAesC,KAAI,CAACzC,uBAAL,CAA6B0C,iBAA7B,EAftC,qDAiBGZ,0BAAkBa,GAjBrB,EAiB2BhD,GAjB3B,yEAkBoBC,cAlBpB,uEAoBkB,CAACY,KAAD,EAAQC,MAAR,CApBlB,sEAqBiB,KAAI,CAACO,aAAL,CAAmB4B,cAAnB,EArBjB,2EAsBsBC,iBAAQC,gBAtB9B,wEAwBmBtD,KAAK,CAACuD,cAAN,GAAuBC,aAAvB,IAAwC,CAxB3D,qEA0BgBC,MAAM,CAACzD,KAAK,CAAC0D,iBAAN,EAAD,CA1BtB;AA4BD,SA7BD;AAgCD,OA7CD;AA8CD","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"}
@@ -21,6 +21,8 @@ var _isNumber2 = _interopRequireDefault(require("lodash/isNumber"));
21
21
 
22
22
  var _l7Core = require("@antv/l7-core");
23
23
 
24
+ var _l7Utils = require("@antv/l7-utils");
25
+
24
26
  var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
25
27
 
26
28
  var _triangulation = require("../../core/triangulation");
@@ -33,8 +35,8 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
33
35
 
34
36
  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; } }
35
37
 
36
- 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";
37
- 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";
38
+ 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";
39
+ 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";
38
40
 
39
41
  var ExtrudeModel = function (_BaseModel) {
40
42
  (0, _inherits2.default)(ExtrudeModel, _BaseModel);
@@ -51,7 +53,16 @@ var ExtrudeModel = function (_BaseModel) {
51
53
  value: function getUninforms() {
52
54
  var _ref = this.layer.getLayerConfig(),
53
55
  _ref$opacity = _ref.opacity,
54
- opacity = _ref$opacity === void 0 ? 1 : _ref$opacity;
56
+ opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
57
+ sourceColor = _ref.sourceColor,
58
+ targetColor = _ref.targetColor,
59
+ _ref$opacityLinear = _ref.opacityLinear,
60
+ opacityLinear = _ref$opacityLinear === void 0 ? {
61
+ enable: false,
62
+ dir: 'up'
63
+ } : _ref$opacityLinear,
64
+ _ref$lightEnable = _ref.lightEnable,
65
+ lightEnable = _ref$lightEnable === void 0 ? true : _ref$lightEnable;
55
66
 
56
67
  if (this.dataTextureTest && this.dataTextureNeedUpdate({
57
68
  opacity: opacity
@@ -84,11 +95,27 @@ var ExtrudeModel = function (_BaseModel) {
84
95
  });
85
96
  }
86
97
 
98
+ var useLinearColor = 0;
99
+ var sourceColorArr = [0, 0, 0, 0];
100
+ var targetColorArr = [0, 0, 0, 0];
101
+
102
+ if (sourceColor && targetColor) {
103
+ sourceColorArr = (0, _l7Utils.rgb2arr)(sourceColor);
104
+ targetColorArr = (0, _l7Utils.rgb2arr)(targetColor);
105
+ useLinearColor = 1;
106
+ }
107
+
87
108
  return {
88
109
  u_globel: this.mapService.version === 'GLOBEL' ? 1 : 0,
89
110
  u_dataTexture: this.dataTexture,
90
111
  u_cellTypeLayout: this.getCellTypeLayout(),
91
- u_opacity: (0, _isNumber2.default)(opacity) ? opacity : 1.0
112
+ u_opacity: (0, _isNumber2.default)(opacity) ? opacity : 1.0,
113
+ u_linearColor: useLinearColor,
114
+ u_sourceColor: sourceColorArr,
115
+ u_targetColor: targetColorArr,
116
+ u_opacitylinear: Number(opacityLinear.enable),
117
+ u_opacitylinear_dir: opacityLinear.dir === 'up' ? 1.0 : 0.0,
118
+ u_lightEnable: Number(lightEnable)
92
119
  };
93
120
  }
94
121
  }, {
@@ -99,12 +126,23 @@ var ExtrudeModel = function (_BaseModel) {
99
126
  }, {
100
127
  key: "buildModels",
101
128
  value: function buildModels() {
129
+ var _ref2 = this.layer.getLayerConfig(),
130
+ _ref2$depth = _ref2.depth,
131
+ depth = _ref2$depth === void 0 ? true : _ref2$depth;
132
+
102
133
  return [this.layer.buildLayerModel({
103
134
  moduleName: 'pointExtrude2',
104
135
  vertexShader: pointExtrudeVert,
105
136
  fragmentShader: pointExtrudeFrag,
106
137
  triangulation: _triangulation.PointExtrudeTriangulation,
107
- blend: this.getBlend()
138
+ blend: this.getBlend(),
139
+ cull: {
140
+ enable: true,
141
+ face: _l7Core.gl.BACK
142
+ },
143
+ depth: {
144
+ enable: depth
145
+ }
108
146
  })];
109
147
  }
110
148
  }, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/point/models/extrude.ts"],"names":["ExtrudeModel","layer","getLayerConfig","opacity","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","u_globel","mapService","version","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","buildModels","buildLayerModel","moduleName","vertexShader","pointExtrudeVert","fragmentShader","pointExtrudeFrag","triangulation","PointExtrudeTriangulation","blend","getBlend","destroy","isGlobel","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","buffersize","Array","isArray","STATIC_DRAW","normal","coordinates","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;;IAOqBA,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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AiBA,WAAW,CAAC,CAAD,CAA5B,CAAT,CAAP;AAKD,aAPD,MAOO;AACL,qBAAO,CAACA,WAAW,CAAC,CAAD,CAAZ,EAAiBA,WAAW,CAAC,CAAD,CAA5B,EAAiC,CAAjC,CAAP;AACD;AACF;AArBS;AAHoC,OAAlD;AA2BD;;;EAlKuCC,mB","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":["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","gl","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","PointExtrudeTriangulation","blend","getBlend","cull","face","BACK","destroy","isGlobel","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","buffersize","Array","isArray","STATIC_DRAW","normal","coordinates","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;;IAiBqBA,Y;;;;;;;;;;;;WACnB,wBAAsB;AACpB,iBAYI,KAAKC,KAAL,CAAWC,cAAX,EAZJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,UAGEC,WAHF,QAGEA,WAHF;AAAA,UAIEC,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V4C,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBAACC,OAAD,EAA0BC,UAA1B,EAAiD;AACvD,gBAAMQ,WAAW,GAAG,4BAAkBT,OAAO,CAACS,WAA1B,CAApB;;AACA,gBAAIrB,QAAJ,EAAc;AAEZ,qBAAO,qBAAS,CAACqB,WAAW,CAAC,CAAD,CAAZ,EAAiBA,WAAW,CAAC,CAAD,CAA5B,CAAT,CAAP;AAKD,aAPD,MAOO;AACL,qBAAO,CAACA,WAAW,CAAC,CAAD,CAAZ,EAAiBA,WAAW,CAAC,CAAD,CAA5B,EAAiC,CAAjC,CAAP;AACD;AACF;AArBS;AAHoC,OAAlD;AA2BD;;;EA7MuCC,mB","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"}
@@ -30,6 +30,8 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
30
30
  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; } }
31
31
 
32
32
  var polygonExtrudeFrag = "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#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";
33
+ var polygonExtrudePickLightFrag = "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#pragma include \"picking\"\nvarying float v_lightWeight;\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 = filterColorWithLight(gl_FragColor, v_lightWeight);\n}\n";
34
+ var polygonExtrudePickLightVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute 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 \"light\"\n#pragma include \"picking\"\n\nvarying float v_lightWeight;\n\nvoid main() {\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 vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n vec4 project_pos = project_position(pos);\n\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 * vec3(1.0, 1.0, -1.0), 1.0));\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 float lightWeight = calc_lighting(pos);\n v_lightWeight = lightWeight;\n // v_Color = a_Color;\n v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w);\n\n setPickingColor(a_PickingColor);\n}\n";
33
35
  var polygonExtrudeVert = "precision highp float;\n\n#define ambientRatio 0.5\n#define diffuseRatio 0.3\n#define specularRatio 0.2\n\nattribute 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 \"light\"\n#pragma include \"picking\"\n\nvoid main() {\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 vec4 pos = vec4(a_Position.xy, a_Position.z * a_Size, 1.0);\n vec4 project_pos = project_position(pos);\n\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 * vec3(1.0, 1.0, -1.0), 1.0));\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 float lightWeight = calc_lighting(pos);\n // v_Color = a_Color;\n v_Color = vec4(a_Color.rgb * lightWeight, a_Color.w);\n\n setPickingColor(a_PickingColor);\n}\n";
34
36
 
35
37
  var ExtrudeModel = function (_BaseModel) {
@@ -94,10 +96,14 @@ var ExtrudeModel = function (_BaseModel) {
94
96
  }, {
95
97
  key: "buildModels",
96
98
  value: function buildModels() {
99
+ var _ref2 = this.layer.getLayerConfig(),
100
+ _ref2$pickLight = _ref2.pickLight,
101
+ pickLight = _ref2$pickLight === void 0 ? false : _ref2$pickLight;
102
+
97
103
  return [this.layer.buildLayerModel({
98
104
  moduleName: 'polygonExtrude',
99
- vertexShader: polygonExtrudeVert,
100
- fragmentShader: polygonExtrudeFrag,
105
+ vertexShader: pickLight ? polygonExtrudePickLightVert : polygonExtrudeVert,
106
+ fragmentShader: pickLight ? polygonExtrudePickLightFrag : polygonExtrudeFrag,
101
107
  triangulation: _triangulation.PolygonExtrudeTriangulation
102
108
  })];
103
109
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/polygon/models/extrude.ts"],"names":["ExtrudeModel","layer","getLayerConfig","opacity","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","buildModels","buildLayerModel","moduleName","vertexShader","polygonExtrudeVert","fragmentShader","polygonExtrudeFrag","triangulation","PolygonExtrudeTriangulation","destroy","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","normal","DYNAMIC_DRAW","Array","isArray","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;AACA;;;;;;;;;IAMqBA,Y;;;;;;;;;;;;WACnB,wBAAsB;AACpB,iBAEI,KAAKC,KAAL,CAAWC,cAAX,EAFJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;;AAIA,UAAI,KAAKC,eAAL,IAAwB,KAAKC,qBAAL,CAA2B;AAAEF,QAAAA,OAAO,EAAPA;AAAF,OAA3B,CAA5B,EAAqE;AACnE,aAAKG,oBAAL,CAA0B;AAAEH,UAAAA,OAAO,EAAPA;AAAF,SAA1B;AACA,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,CAArC,GACI,KAAKC,eAAL,CAAqB;AACnBC,UAAAA,KAAK,EAAE,IADY;AAEnBP,UAAAA,IAAI,EAAJA,IAFmB;AAGnBQ,UAAAA,MAAM,EAAEC,WAAGC,SAHQ;AAInBC,UAAAA,IAAI,EAAEF,WAAGG,KAJU;AAKnBX,UAAAA,KAAK,EAALA,KALmB;AAMnBC,UAAAA,MAAM,EAANA;AANmB,SAArB,CADJ,GASI,KAAKI,eAAL,CAAqB;AACnBC,UAAAA,KAAK,EAAE,IADY;AAEnBP,UAAAA,IAAI,EAAE,CAAC,CAAD,CAFa;AAGnBQ,UAAAA,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BC,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,MAD0C;AAEhDlB,QAAAA,IAAI,EAAEmB,sBAAcC,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVH,UAAAA,IAAI,EAAE,QADI;AAEVI,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAEzB,WAAGkC,YAFJ;AAGN3C,YAAAA,IAAI,EAAE,EAHA;AAINW,YAAAA,IAAI,EAAEF,WAAGG;AAJH,WAFE;AAQVwB,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gCAAsBH,OAAtB,CAAQF,IAAR;AAAA,gBAAQA,IAAR,8BAAe,EAAf;AACA,mBAAOQ,KAAK,CAACC,OAAN,CAAcT,IAAd,IAAsB,CAACA,IAAI,CAAC,CAAD,CAAL,CAAtB,GAAkC,CAACA,IAAD,CAAzC;AACD;AAjBS;AAHoC,OAAlD;AAuBD;;;EAhHuCU,mB","sourcesContent":["import { AttributeType, gl, IEncodeFeature, IModel } from '@antv/l7-core';\nimport { isNumber } from 'lodash';\nimport BaseModel, { styleSingle } from '../../core/BaseModel';\nimport { PolygonExtrudeTriangulation } from '../../core/triangulation';\nimport polygonExtrudeFrag from '../shaders/polygon_extrude_frag.glsl';\nimport polygonExtrudeVert from '../shaders/polygon_extrude_vert.glsl';\ninterface IPolygonLayerStyleOptions {\n opacity: styleSingle;\n}\nexport default class ExtrudeModel extends BaseModel {\n public getUninforms() {\n const {\n opacity = 1,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n\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\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\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: 'polygonExtrude',\n vertexShader: polygonExtrudeVert,\n fragmentShader: polygonExtrudeFrag,\n triangulation: PolygonExtrudeTriangulation,\n }),\n ];\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n protected registerBuiltinAttributes() {\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\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: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 10 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n }\n}\n"],"file":"extrude.js"}
1
+ {"version":3,"sources":["../../../src/polygon/models/extrude.ts"],"names":["ExtrudeModel","layer","getLayerConfig","opacity","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","buildModels","pickLight","buildLayerModel","moduleName","vertexShader","polygonExtrudePickLightVert","polygonExtrudeVert","fragmentShader","polygonExtrudePickLightFrag","polygonExtrudeFrag","triangulation","PolygonExtrudeTriangulation","destroy","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","normal","DYNAMIC_DRAW","Array","isArray","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;AACA;;;;;;;;;;;IAUqBA,Y;;;;;;;;;;;;WACnB,wBAAsB;AACpB,iBAEI,KAAKC,KAAL,CAAWC,cAAX,EAFJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;;AAIA,UAAI,KAAKC,eAAL,IAAwB,KAAKC,qBAAL,CAA2B;AAAEF,QAAAA,OAAO,EAAPA;AAAF,OAA3B,CAA5B,EAAqE;AACnE,aAAKG,oBAAL,CAA0B;AAAEH,UAAAA,OAAO,EAAPA;AAAF,SAA1B;AACA,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,CAArC,GACI,KAAKC,eAAL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 'lodash';\nimport BaseModel, { styleSingle } from '../../core/BaseModel';\nimport { PolygonExtrudeTriangulation } from '../../core/triangulation';\nimport polygonExtrudeFrag from '../shaders/polygon_extrude_frag.glsl';\nimport polygonExtrudePickLightFrag from '../shaders/polygon_extrude_picklight_frag.glsl';\nimport polygonExtrudePickLightVert from '../shaders/polygon_extrude_picklight_vert.glsl';\nimport polygonExtrudeVert from '../shaders/polygon_extrude_vert.glsl';\n\ninterface IPolygonLayerStyleOptions {\n opacity: styleSingle;\n pickLight: boolean;\n}\nexport default class ExtrudeModel extends BaseModel {\n public getUninforms() {\n const {\n opacity = 1,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n\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\n return {\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\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 const {\n pickLight = false,\n } = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;\n return [\n this.layer.buildLayerModel({\n moduleName: 'polygonExtrude',\n vertexShader: pickLight\n ? polygonExtrudePickLightVert\n : polygonExtrudeVert,\n fragmentShader: pickLight\n ? polygonExtrudePickLightFrag\n : polygonExtrudeFrag,\n triangulation: PolygonExtrudeTriangulation,\n }),\n ];\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n protected registerBuiltinAttributes() {\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\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: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 10 } = feature;\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n }\n}\n"],"file":"extrude.js"}
@@ -29,8 +29,10 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
29
29
 
30
30
  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; } }
31
31
 
32
- 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";
33
- 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";
32
+ 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";
33
+ 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";
34
+ 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}";
35
+ 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";
34
36
 
35
37
  var FillModel = function (_BaseModel) {
36
38
  (0, _inherits2.default)(FillModel, _BaseModel);
@@ -47,7 +49,12 @@ var FillModel = function (_BaseModel) {
47
49
  value: function getUninforms() {
48
50
  var _ref = this.layer.getLayerConfig(),
49
51
  _ref$opacity = _ref.opacity,
50
- opacity = _ref$opacity === void 0 ? 1 : _ref$opacity;
52
+ opacity = _ref$opacity === void 0 ? 1 : _ref$opacity,
53
+ _ref$opacityLinear = _ref.opacityLinear,
54
+ opacityLinear = _ref$opacityLinear === void 0 ? {
55
+ enable: false,
56
+ dir: 'in'
57
+ } : _ref$opacityLinear;
51
58
 
52
59
  if (this.dataTextureTest && this.dataTextureNeedUpdate({
53
60
  opacity: opacity
@@ -83,7 +90,9 @@ var FillModel = function (_BaseModel) {
83
90
  return {
84
91
  u_dataTexture: this.dataTexture,
85
92
  u_cellTypeLayout: this.getCellTypeLayout(),
86
- u_opacity: (0, _isNumber2.default)(opacity) ? opacity : 1.0
93
+ u_opacity: (0, _isNumber2.default)(opacity) ? opacity : 1.0,
94
+ u_opacitylinear: Number(opacityLinear.enable),
95
+ u_dir: opacityLinear.dir === 'in' ? 1.0 : 0.0
87
96
  };
88
97
  }
89
98
  }, {
@@ -94,11 +103,18 @@ var FillModel = function (_BaseModel) {
94
103
  }, {
95
104
  key: "buildModels",
96
105
  value: function buildModels() {
106
+ var _ref2 = this.layer.getLayerConfig(),
107
+ _ref2$opacityLinear = _ref2.opacityLinear,
108
+ opacityLinear = _ref2$opacityLinear === void 0 ? {
109
+ enable: false,
110
+ dir: 'in'
111
+ } : _ref2$opacityLinear;
112
+
97
113
  return [this.layer.buildLayerModel({
98
114
  moduleName: 'polygon',
99
- vertexShader: polygon_vert,
100
- fragmentShader: polygon_frag,
101
- triangulation: _triangulation.polygonTriangulation,
115
+ vertexShader: opacityLinear.enable ? polygon_linear_vert : polygon_vert,
116
+ fragmentShader: opacityLinear.enable ? polygon_linear_frag : polygon_frag,
117
+ triangulation: opacityLinear.enable ? _triangulation.polygonTriangulationWithCenter : _triangulation.polygonTriangulation,
102
118
  blend: this.getBlend(),
103
119
  depth: {
104
120
  enable: false
@@ -114,7 +130,33 @@ var FillModel = function (_BaseModel) {
114
130
  }
115
131
  }, {
116
132
  key: "registerBuiltinAttributes",
117
- value: function registerBuiltinAttributes() {}
133
+ value: function registerBuiltinAttributes() {
134
+ var _ref3 = this.layer.getLayerConfig(),
135
+ _ref3$opacityLinear = _ref3.opacityLinear,
136
+ opacityLinear = _ref3$opacityLinear === void 0 ? {
137
+ enable: false,
138
+ dir: 'in'
139
+ } : _ref3$opacityLinear;
140
+
141
+ if (opacityLinear.enable) {
142
+ this.styleAttributeService.registerStyleAttribute({
143
+ name: 'linear',
144
+ type: _l7Core.AttributeType.Attribute,
145
+ descriptor: {
146
+ name: 'a_linear',
147
+ buffer: {
148
+ usage: _l7Core.gl.STATIC_DRAW,
149
+ data: [],
150
+ type: _l7Core.gl.FLOAT
151
+ },
152
+ size: 3,
153
+ update: function update(feature, featureIdx, vertex, attributeIdx, normal) {
154
+ return [vertex[3], vertex[4], vertex[5]];
155
+ }
156
+ }
157
+ });
158
+ }
159
+ }
118
160
  }]);
119
161
  return FillModel;
120
162
  }(_BaseModel2.default);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/polygon/models/fill.ts"],"names":["FillModel","layer","getLayerConfig","opacity","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","buildModels","buildLayerModel","moduleName","vertexShader","polygon_vert","fragmentShader","polygon_frag","triangulation","polygonTriangulation","blend","getBlend","depth","enable","destroy","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AAaA;;AACA;;;;;;;;;IAOqBA,S;;;;;;;;;;;;WACnB,wBAAsB;AACpB,iBAEI,KAAKC,KAAL,CAAWC,cAAX,EAFJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;;AAGA,UAAI,KAAKC,eAAL,IAAwB,KAAKC,qBAAL,CAA2B;AAAEF,QAAAA,OAAO,EAAPA;AAAF,OAA3B,CAA5B,EAAqE;AACnE,aAAKG,oBAAL,CAA0B;AAAEH,UAAAA,OAAO,EAAPA;AAAF,SAA1B;AACA,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,CAArC,GACI,KAAKC,eAAL,CAAqB;AACnBC,UAAAA,KAAK,EAAE,IADY;AAEnBP,UAAAA,IAAI,EAAJA,IAFmB;AAGnBQ,UAAAA,MAAM,EAAEC,WAAGC,SAHQ;AAInBC,UAAAA,IAAI,EAAEF,WAAGG,KAJU;AAKnBX,UAAAA,KAAK,EAALA,KALmB;AAMnBC,UAAAA,MAAM,EAANA;AANmB,SAArB,CADJ,GASI,KAAKI,eAAL,CAAqB;AACnBC,UAAAA,KAAK,EAAE,IADY;AAEnBP,UAAAA,IAAI,EAAE,CAAC,CAAD,CAFa;AAGnBQ,UAAAA,MAAM,EAAEC,WAAGC,SAHQ;AAInBC,UAAAA,IAAI,EAAEF,WAAGG,KAJU;AAKnBX,UAAAA,KAAK,EAAE,CALY;AAMnBC,UAAAA,MAAM,EAAE;AANW,SAArB,CAVN;AAkBD;;AACD,aAAO;AACLW,QAAAA,aAAa,EAAE,KAAKT,WADf;AAELU,QAAAA,gBAAgB,EAAE,KAAKC,iBAAL,EAFb;AAILC,QAAAA,SAAS,EAAE,wBAASzB,OAAT,IAAoBA,OAApB,GAA8B;AAJpC,OAAP;AAMD;;;WAED,sBAA8B;AAC5B,aAAO,KAAK0B,WAAL,EAAP;AACD;;;WAED,uBAA+B;AAC7B,aAAO,CACL,KAAK5B,KAAL,CAAW6B,eAAX,CAA2B;AACzBC,QAAAA,UAAU,EAAE,SADa;AAEzBC,QAAAA,YAAY,EAAEC,YAFW;AAGzBC,QAAAA,cAAc,EAAEC,YAHS;AAIzBC,QAAAA,aAAa,EAAEC,mCAJU;AAKzBC,QAAAA,KAAK,EAAE,KAAKC,QAAL,EALkB;AAMzBC,QAAAA,KAAK,EAAE;AAAEC,UAAAA,MAAM,EAAE;AAAV;AANkB,OAA3B,CADK,CAAP;AAUD;;;WAED,uBAAqB;AAAA;;AACnB,gCAAKzB,WAAL,wEAAkB0B,OAAlB;AACD;;;WAED,qCAAsC,CAErC;;;EAjEoCC,mB","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":["FillModel","layer","getLayerConfig","opacity","opacityLinear","enable","dir","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","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","polygonTriangulationWithCenter","polygonTriangulation","blend","getBlend","depth","destroy","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","STATIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","normal","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AAaA;;AACA;;;;;;;;;;;IAiBqBA,S;;;;;;;;;;;;WACnB,wBAAsB;AACpB,iBAMI,KAAKC,KAAL,CAAWC,cAAX,EANJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,oCAEEC,aAFF;AAAA,UAEEA,aAFF,mCAEkB;AACdC,QAAAA,MAAM,EAAE,KADM;AAEdC,QAAAA,GAAG,EAAE;AAFS,OAFlB;;AAOA,UAAI,KAAKC,eAAL,IAAwB,KAAKC,qBAAL,CAA2B;AAAEL,QAAAA,OAAO,EAAPA;AAAF,OAA3B,CAA5B,EAAqE;AACnE,aAAKM,oBAAL,CAA0B;AAAEN,UAAAA,OAAO,EAAPA;AAAF,SAA1B;AACA,YAAMO,UAAU,GAAG,KAAKT,KAAL,CAAWU,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,CAArC,GACI,KAAKC,eAAL,CAAqB;AACnBC,UAAAA,KAAK,EAAE,IADY;AA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ugin,\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/lib/utils/geo.js CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.calculateCentroid = calculateCentroid;
9
+ exports.calculatePointsCenterAndRadius = calculatePointsCenterAndRadius;
9
10
 
10
11
  var _isNumber2 = _interopRequireDefault(require("lodash/isNumber"));
11
12
 
@@ -31,4 +32,34 @@ function calculateCentroid(coord) {
31
32
  throw new Error('当前数据不支持标注');
32
33
  }
33
34
  }
35
+
36
+ function calculatePointsCenterAndRadius(points) {
37
+ var maxX = points[0];
38
+ var maxY = points[1];
39
+ var minX = points[0];
40
+ var minY = points[1];
41
+ var xCount = 0;
42
+ var yCount = 0;
43
+ var pCount = 0;
44
+
45
+ for (var i = 0; i < points.length; i += 2) {
46
+ var x = points[i];
47
+ var y = points[i + 1];
48
+
49
+ if (x && y) {
50
+ maxX = Math.max(x, maxX);
51
+ maxY = Math.max(y, maxY);
52
+ minX = Math.min(x, minX);
53
+ minY = Math.min(y, minY);
54
+ xCount += x;
55
+ yCount += y;
56
+ pCount++;
57
+ }
58
+ }
59
+
60
+ return {
61
+ center: [xCount / pCount, yCount / pCount],
62
+ radius: Math.sqrt(Math.pow(maxX - minX, 2) + Math.pow(maxY - minY, 2)) / 2
63
+ };
64
+ }
34
65
  //# 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":";;;;;;;;;;;AAEO,SAASA,iBAAT,CACLC,KADK,EAEK;AAEV,MAAI,wBAASA,KAAK,CAAC,CAAD,CAAd,CAAJ,EAAwB;AACtB,WAAOA,KAAP;AACD,GAFD,MAEO,IAAI,wBAASA,KAAK,CAAC,CAAD,CAAL,CAAS,CAAT,CAAT,CAAJ,EAA2B;AAChC,UAAM,IAAIC,KAAJ,CAAU,WAAV,CAAN;AACD,GAFM,MAEA,IAAI,wBAASD,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":";;;;;;;;;;;;AAEO,SAASA,iBAAT,CACLC,KADK,EAEK;AAEV,MAAI,wBAASA,KAAK,CAAC,CAAD,CAAd,CAAJ,EAAwB;AACtB,WAAOA,KAAP;AACD,GAFD,MAEO,IAAI,wBAASA,KAAK,CAAC,CAAD,CAAL,CAAS,CAAT,CAAT,CAAJ,EAA2B;AAChC,UAAM,IAAIC,KAAJ,CAAU,WAAV,CAAN;AACD,GAFM,MAEA,IAAI,wBAASD,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,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A,IAAI,GAAGQ,IAAI,CAACE,GAAL,CAASH,CAAT,EAAYP,IAAZ,CAAP;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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-layers",
3
- "version": "2.6.1",
3
+ "version": "2.6.5",
4
4
  "description": "L7's collection of built-in layers",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -24,9 +24,9 @@
24
24
  "license": "ISC",
25
25
  "dependencies": {
26
26
  "@antv/geo-coord": "^1.0.8",
27
- "@antv/l7-core": "^2.6.1",
28
- "@antv/l7-source": "^2.6.1",
29
- "@antv/l7-utils": "^2.6.1",
27
+ "@antv/l7-core": "^2.6.5",
28
+ "@antv/l7-source": "^2.6.5",
29
+ "@antv/l7-utils": "^2.6.5",
30
30
  "@babel/runtime": "^7.7.7",
31
31
  "@mapbox/martini": "^0.2.0",
32
32
  "@turf/meta": "^6.0.2",
@@ -52,7 +52,7 @@
52
52
  "@types/gl-matrix": "^2.4.5",
53
53
  "@types/lodash": "^4.14.138"
54
54
  },
55
- "gitHead": "6d058a4d8bf3fbb74a461620efbcd6144bf5a8f3",
55
+ "gitHead": "c452ef87104ef805d8641e1ae7950cc2c9311bb4",
56
56
  "publishConfig": {
57
57
  "access": "public"
58
58
  }