@antv/l7-layers 2.25.9 → 2.28.10

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 (113) hide show
  1. package/es/citybuilding/models/build.d.ts +3 -2
  2. package/es/core/BaseModel.js +32 -6
  3. package/es/core/CommonStyleAttribute.d.ts +2 -1
  4. package/es/core/CommonStyleAttribute.js +23 -1
  5. package/es/core/constant.js +4 -2
  6. package/es/core/interface.d.ts +1 -0
  7. package/es/earth/models/atmosphere.d.ts +3 -2
  8. package/es/earth/models/base.d.ts +3 -2
  9. package/es/earth/models/bloomsphere.d.ts +3 -2
  10. package/es/geometry/models/billboard.d.ts +3 -2
  11. package/es/geometry/models/plane.d.ts +3 -2
  12. package/es/heatmap/models/grid.d.ts +3 -2
  13. package/es/heatmap/models/grid3d.d.ts +3 -2
  14. package/es/heatmap/models/heatmap.d.ts +3 -2
  15. package/es/heatmap/models/hexagon.d.ts +3 -2
  16. package/es/image/models/image.d.ts +3 -2
  17. package/es/line/models/arc.d.ts +3 -2
  18. package/es/line/models/arc_3d.d.ts +3 -2
  19. package/es/line/models/flow.d.ts +3 -2
  20. package/es/line/models/great_circle.d.ts +3 -2
  21. package/es/line/models/line.d.ts +3 -2
  22. package/es/line/models/simple_line.d.ts +3 -2
  23. package/es/line/models/wall.d.ts +3 -2
  24. package/es/plugins/index.d.ts +1 -1
  25. package/es/point/index.js +2 -2
  26. package/es/point/models/billboard_point.d.ts +3 -2
  27. package/es/point/models/earthExtrude.d.ts +3 -2
  28. package/es/point/models/earthFill.d.ts +3 -2
  29. package/es/point/models/extrude.d.ts +3 -2
  30. package/es/point/models/fill.d.ts +3 -2
  31. package/es/point/models/fillImage.d.ts +3 -2
  32. package/es/point/models/image.d.ts +3 -2
  33. package/es/point/models/normal.d.ts +3 -2
  34. package/es/point/models/radar.d.ts +3 -2
  35. package/es/point/models/text.d.ts +3 -2
  36. package/es/point/shaders/billboard/billboard_point_vert.glsl +33 -1
  37. package/es/point/shaders/earthFill/earthFill_vert.glsl +37 -3
  38. package/es/point/shaders/fill/fill_vert.glsl +38 -3
  39. package/es/point/shaders/fillImage/fillImage_vert.glsl +34 -1
  40. package/es/point/shaders/image/image_vert.glsl +31 -0
  41. package/es/point/shaders/normal/normal_vert.glsl +30 -0
  42. package/es/point/shaders/radar/radar_vert.glsl +34 -3
  43. package/es/polygon/models/extrude.d.ts +3 -2
  44. package/es/polygon/models/extrusion.d.ts +3 -2
  45. package/es/polygon/models/fill.d.ts +3 -2
  46. package/es/polygon/models/ocean.d.ts +3 -2
  47. package/es/polygon/models/water.d.ts +3 -2
  48. package/es/raster/models/raster.d.ts +3 -2
  49. package/es/raster/models/rasterRgb.d.ts +3 -2
  50. package/es/raster/models/rasterTerrainRgb.d.ts +3 -2
  51. package/es/tile/tile/Tile.d.ts +2 -2
  52. package/es/tile/tile/index.d.ts +1 -1
  53. package/es/tile/tile/util.d.ts +1 -1
  54. package/es/utils/symbol-layout.d.ts +1 -1
  55. package/es/utils/symbol-layout.js +19 -9
  56. package/es/wind/models/wind.d.ts +3 -2
  57. package/lib/citybuilding/models/build.d.ts +3 -2
  58. package/lib/core/BaseModel.js +32 -6
  59. package/lib/core/CommonStyleAttribute.d.ts +2 -1
  60. package/lib/core/CommonStyleAttribute.js +23 -1
  61. package/lib/core/constant.js +4 -2
  62. package/lib/core/interface.d.ts +1 -0
  63. package/lib/earth/models/atmosphere.d.ts +3 -2
  64. package/lib/earth/models/base.d.ts +3 -2
  65. package/lib/earth/models/bloomsphere.d.ts +3 -2
  66. package/lib/geometry/models/billboard.d.ts +3 -2
  67. package/lib/geometry/models/plane.d.ts +3 -2
  68. package/lib/heatmap/models/grid.d.ts +3 -2
  69. package/lib/heatmap/models/grid3d.d.ts +3 -2
  70. package/lib/heatmap/models/heatmap.d.ts +3 -2
  71. package/lib/heatmap/models/hexagon.d.ts +3 -2
  72. package/lib/image/models/image.d.ts +3 -2
  73. package/lib/line/models/arc.d.ts +3 -2
  74. package/lib/line/models/arc_3d.d.ts +3 -2
  75. package/lib/line/models/flow.d.ts +3 -2
  76. package/lib/line/models/great_circle.d.ts +3 -2
  77. package/lib/line/models/line.d.ts +3 -2
  78. package/lib/line/models/simple_line.d.ts +3 -2
  79. package/lib/line/models/wall.d.ts +3 -2
  80. package/lib/plugins/index.d.ts +1 -1
  81. package/lib/point/index.js +2 -2
  82. package/lib/point/models/billboard_point.d.ts +3 -2
  83. package/lib/point/models/earthExtrude.d.ts +3 -2
  84. package/lib/point/models/earthFill.d.ts +3 -2
  85. package/lib/point/models/extrude.d.ts +3 -2
  86. package/lib/point/models/fill.d.ts +3 -2
  87. package/lib/point/models/fillImage.d.ts +3 -2
  88. package/lib/point/models/image.d.ts +3 -2
  89. package/lib/point/models/normal.d.ts +3 -2
  90. package/lib/point/models/radar.d.ts +3 -2
  91. package/lib/point/models/text.d.ts +3 -2
  92. package/lib/point/shaders/billboard/billboard_point_vert.glsl +33 -1
  93. package/lib/point/shaders/earthFill/earthFill_vert.glsl +37 -3
  94. package/lib/point/shaders/fill/fill_vert.glsl +38 -3
  95. package/lib/point/shaders/fillImage/fillImage_vert.glsl +34 -1
  96. package/lib/point/shaders/image/image_vert.glsl +31 -0
  97. package/lib/point/shaders/normal/normal_vert.glsl +30 -0
  98. package/lib/point/shaders/radar/radar_vert.glsl +34 -3
  99. package/lib/polygon/models/extrude.d.ts +3 -2
  100. package/lib/polygon/models/extrusion.d.ts +3 -2
  101. package/lib/polygon/models/fill.d.ts +3 -2
  102. package/lib/polygon/models/ocean.d.ts +3 -2
  103. package/lib/polygon/models/water.d.ts +3 -2
  104. package/lib/raster/models/raster.d.ts +3 -2
  105. package/lib/raster/models/rasterRgb.d.ts +3 -2
  106. package/lib/raster/models/rasterTerrainRgb.d.ts +3 -2
  107. package/lib/tile/tile/Tile.d.ts +2 -2
  108. package/lib/tile/tile/index.d.ts +1 -1
  109. package/lib/tile/tile/util.d.ts +1 -1
  110. package/lib/utils/symbol-layout.d.ts +1 -1
  111. package/lib/utils/symbol-layout.js +19 -9
  112. package/lib/wind/models/wind.d.ts +3 -2
  113. package/package.json +6 -6
@@ -10,9 +10,10 @@ export default class CityBuildModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  SIZE: number;
17
18
  NORMAL: number;
18
19
  UV: number;
@@ -8,10 +8,37 @@ import { getStencil, getStencilMask } from "../utils/stencil";
8
8
  import { COMMON_ATTRIBUTE_LOCATION, getCommonStyleAttributeOptions } from "./CommonStyleAttribute";
9
9
  import { DefaultUniformStyleType, DefaultUniformStyleValue } from "./constant";
10
10
  import { MultipleOfFourNumber } from "./utils";
11
+ function anchorToNumber(anchor) {
12
+ if (typeof anchor === 'number') {
13
+ return anchor;
14
+ }
15
+ switch (anchor) {
16
+ case 'center':
17
+ return 0;
18
+ case 'top':
19
+ return 1;
20
+ case 'top-right':
21
+ return 2;
22
+ case 'right':
23
+ return 3;
24
+ case 'bottom-right':
25
+ return 4;
26
+ case 'bottom':
27
+ return 5;
28
+ case 'bottom-left':
29
+ return 6;
30
+ case 'left':
31
+ return 7;
32
+ case 'top-left':
33
+ return 8;
34
+ case 'bottom-center':
35
+ return 9;
36
+ default:
37
+ return 0;
38
+ }
39
+ }
11
40
  // 属性索引宏定义前缀,使用命名空间避免 define 名称重复情况
12
41
  const DEFINE_ATTRIBUTE_LOCATION_PREFIX = 'ATTRIBUTE_LOCATION_';
13
-
14
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
15
42
  export default class BaseModel {
16
43
  /**
17
44
  * Attribute Layout Location in Shader
@@ -142,19 +169,16 @@ export default class BaseModel {
142
169
  return false;
143
170
  })();
144
171
  }
145
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
146
172
  buildModels() {
147
173
  return _asyncToGenerator(function* () {
148
174
  throw new Error('Method not implemented.');
149
175
  })();
150
176
  }
151
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
152
177
  initModels() {
153
178
  return _asyncToGenerator(function* () {
154
179
  throw new Error('Method not implemented.');
155
180
  })();
156
181
  }
157
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
158
182
  clearModels(refresh = true) {
159
183
  return;
160
184
  }
@@ -162,7 +186,6 @@ export default class BaseModel {
162
186
  throw new Error('Method not implemented.');
163
187
  }
164
188
  prerender() {}
165
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
166
189
  render(renderOptions) {
167
190
  throw new Error('Method not implemented.');
168
191
  }
@@ -207,6 +230,9 @@ export default class BaseModel {
207
230
  if (key === 'stroke') {
208
231
  value = rgb2arr(value);
209
232
  }
233
+ if (key === 'anchor') {
234
+ value = anchorToNumber(value);
235
+ }
210
236
  options['u_' + key] = value;
211
237
  }
212
238
  });
@@ -11,6 +11,7 @@ export declare const COMMON_ATTRIBUTE_LOCATION: {
11
11
  readonly OPACITY: 5;
12
12
  readonly OFFSETS: 6;
13
13
  readonly ROTATION: 7;
14
- readonly MAX: 8;
14
+ readonly ANCHOR: 8;
15
+ readonly MAX: 9;
15
16
  };
16
17
  export declare function getCommonStyleAttributeOptions(name: string): Partial<IStyleAttribute> | undefined;
@@ -15,8 +15,9 @@ export const COMMON_ATTRIBUTE_LOCATION = {
15
15
  OPACITY: 5,
16
16
  OFFSETS: 6,
17
17
  ROTATION: 7,
18
+ ANCHOR: 8,
18
19
  // last index
19
- MAX: 8
20
+ MAX: 9
20
21
  };
21
22
  export function getCommonStyleAttributeOptions(name) {
22
23
  switch (name) {
@@ -108,6 +109,27 @@ export function getCommonStyleAttributeOptions(name) {
108
109
  }
109
110
  }
110
111
  };
112
+ case 'anchor':
113
+ return {
114
+ name: 'anchor',
115
+ type: AttributeType.Attribute,
116
+ descriptor: {
117
+ name: 'a_Anchor',
118
+ shaderLocation: COMMON_ATTRIBUTE_LOCATION.ANCHOR,
119
+ buffer: {
120
+ usage: gl.STATIC_DRAW,
121
+ data: [],
122
+ type: gl.FLOAT
123
+ },
124
+ size: 1,
125
+ update: feature => {
126
+ const {
127
+ anchor = 0
128
+ } = feature;
129
+ return [anchor];
130
+ }
131
+ }
132
+ };
111
133
  default:
112
134
  return undefined;
113
135
  }
@@ -5,7 +5,8 @@ export const DefaultUniformStyleValue = {
5
5
  rotation: 0,
6
6
  extrusionBase: 0,
7
7
  strokeOpacity: 1,
8
- thetaOffset: 0.314
8
+ thetaOffset: 0.314,
9
+ anchor: 0
9
10
  };
10
11
  export const DefaultUniformStyleType = {
11
12
  opacity: 'float',
@@ -15,5 +16,6 @@ export const DefaultUniformStyleType = {
15
16
  rotation: 'float',
16
17
  extrusionBase: 'float',
17
18
  strokeOpacity: 'float',
18
- thetaOffset: 'float'
19
+ thetaOffset: 'float',
20
+ anchor: 'float'
19
21
  };
@@ -71,6 +71,7 @@ export interface IPointLayerStyleOptions extends IBaseLayerStyleOptions {
71
71
  stroke: string;
72
72
  blur?: number;
73
73
  billboard?: boolean;
74
+ anchor?: anchorType;
74
75
  textOffset?: [number, number];
75
76
  textAnchor?: anchorType;
76
77
  spacing?: number;
@@ -10,9 +10,10 @@ export default class EarthAtomSphereModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  NORMAL: number;
17
18
  UV: number;
18
19
  };
@@ -10,9 +10,10 @@ export default class BaseEarthModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  NORMAL: number;
17
18
  UV: number;
18
19
  };
@@ -10,9 +10,10 @@ export default class EarthBloomSphereModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  NORMAL: number;
17
18
  UV: number;
18
19
  };
@@ -10,9 +10,10 @@ export default class BillBoardModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  EXTRUDE: number;
17
18
  UV: number;
18
19
  };
@@ -10,9 +10,10 @@ export default class PlaneModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  UV: number;
17
18
  };
18
19
  protected texture: ITexture2D;
@@ -10,9 +10,10 @@ export default class GridModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  POS: number;
17
18
  };
18
19
  getUninforms(): IModelUniform;
@@ -10,9 +10,10 @@ export default class Grid3DModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  SIZE: number;
17
18
  POS: number;
18
19
  NORMAL: number;
@@ -10,9 +10,10 @@ export default class HeatMapModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  SIZE: number;
17
18
  UV: number;
18
19
  DIR: number;
@@ -10,9 +10,10 @@ export default class HexagonModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  POS: number;
17
18
  };
18
19
  getUninforms(): IModelUniform;
@@ -11,9 +11,10 @@ export default class ImageModel extends BaseModel {
11
11
  readonly OPACITY: 5;
12
12
  readonly OFFSETS: 6;
13
13
  readonly ROTATION: 7;
14
- readonly MAX: 8;
14
+ readonly ANCHOR: 8;
15
+ readonly MAX: 9;
15
16
  } & Record<string, number> & {
16
- MAX: 8;
17
+ MAX: 9;
17
18
  UV: number;
18
19
  };
19
20
  protected getCommonUniformsInfo(): {
@@ -10,9 +10,10 @@ export default class ArcModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  SIZE: number;
17
18
  INSTANCE: number;
18
19
  INSTANCE_64LOW: number;
@@ -10,9 +10,10 @@ export default class Arc3DModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  SIZE: number;
17
18
  INSTANCE: number;
18
19
  INSTANCE_64LOW: number;
@@ -10,9 +10,10 @@ export default class FlowLineModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  SIZE: number;
17
18
  INSTANCE: number;
18
19
  INSTANCE_64LOW: number;
@@ -10,9 +10,10 @@ export default class GreatCircleModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  SIZE: number;
17
18
  INSTANCE: number;
18
19
  INSTANCE_64LOW: number;
@@ -10,9 +10,10 @@ export default class LineModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  SIZE: number;
17
18
  DISTANCE_INDEX: number;
18
19
  NORMAL: number;
@@ -10,9 +10,10 @@ export default class SimpleLineModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  SIZE: number;
17
18
  };
18
19
  protected getCommonUniformsInfo(): {
@@ -10,9 +10,10 @@ export default class LineWallModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  SIZE: number;
17
18
  NORMAL: number;
18
19
  UV: number;
@@ -12,4 +12,4 @@ import RegisterStyleAttributePlugin from './RegisterStyleAttributePlugin';
12
12
  import ShaderUniformPlugin from './ShaderUniformPlugin';
13
13
  import UpdateModelPlugin from './UpdateModelPlugin';
14
14
  import UpdateStyleAttributePlugin from './UpdateStyleAttributePlugin';
15
- export declare function createPlugins(): (DataMappingPlugin | DataSourcePlugin | FeatureScalePlugin | LayerAnimateStylePlugin | LayerMaskPlugin | LayerModelPlugin | LayerStylePlugin | LightingPlugin | MultiPassRendererPlugin | PixelPickingPlugin | RegisterStyleAttributePlugin | ShaderUniformPlugin | UpdateModelPlugin | UpdateStyleAttributePlugin)[];
15
+ export declare function createPlugins(): (DataSourcePlugin | RegisterStyleAttributePlugin | FeatureScalePlugin | DataMappingPlugin | LayerStylePlugin | LayerMaskPlugin | UpdateStyleAttributePlugin | UpdateModelPlugin | MultiPassRendererPlugin | ShaderUniformPlugin | LayerAnimateStylePlugin | LightingPlugin | PixelPickingPlugin | LayerModelPlugin)[];
package/es/point/index.js CHANGED
@@ -6,8 +6,8 @@ export default class PointLayer extends BaseLayer {
6
6
  constructor(...args) {
7
7
  super(...args);
8
8
  _defineProperty(this, "type", 'PointLayer');
9
- _defineProperty(this, "enableShaderEncodeStyles", ['stroke', 'offsets', 'opacity', 'rotation']);
10
- //4+2+1+1
9
+ _defineProperty(this, "enableShaderEncodeStyles", ['stroke', 'offsets', 'opacity', 'rotation', 'anchor']);
10
+ //4+2+1+1+1
11
11
  _defineProperty(this, "enableDataEncodeStyles", ['textOffset', 'textAnchor']);
12
12
  _defineProperty(this, "defaultSourceConfig", {
13
13
  data: [],
@@ -16,9 +16,10 @@ export default class SimplePointModel extends BaseModel {
16
16
  readonly OPACITY: 5;
17
17
  readonly OFFSETS: 6;
18
18
  readonly ROTATION: 7;
19
- readonly MAX: 8;
19
+ readonly ANCHOR: 8;
20
+ readonly MAX: 9;
20
21
  } & Record<string, number> & {
21
- MAX: 8;
22
+ MAX: 9;
22
23
  SIZE: number;
23
24
  };
24
25
  getDefaultStyle(): Partial<IPointLayerStyleOptions>;
@@ -10,9 +10,10 @@ export default class ExtrudeModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  SIZE: number;
17
18
  POS: number;
18
19
  NORMAL: number;
@@ -10,9 +10,10 @@ export default class FillModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  SIZE: number;
17
18
  SHAPE: number;
18
19
  EXTRUDE: number;
@@ -10,9 +10,10 @@ export default class ExtrudeModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  SIZE: number;
17
18
  EXTRUDE: number;
18
19
  NORMAL: number;
@@ -10,9 +10,10 @@ export default class FillModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  SIZE: number;
17
18
  SHAPE: number;
18
19
  EXTRUDE: number;
@@ -10,9 +10,10 @@ export default class FillImageModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  SIZE: number;
17
18
  EXTRUDE: number;
18
19
  UV: number;
@@ -10,9 +10,10 @@ export default class ImageModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  SIZE: number;
17
18
  UV: number;
18
19
  };
@@ -16,9 +16,10 @@ export default class NormalModel extends BaseModel {
16
16
  readonly OPACITY: 5;
17
17
  readonly OFFSETS: 6;
18
18
  readonly ROTATION: 7;
19
- readonly MAX: 8;
19
+ readonly ANCHOR: 8;
20
+ readonly MAX: 9;
20
21
  } & Record<string, number> & {
21
- MAX: 8;
22
+ MAX: 9;
22
23
  SIZE: number;
23
24
  };
24
25
  getDefaultStyle(): Partial<IPointLayerStyleOptions>;
@@ -10,9 +10,10 @@ export default class RadarModel extends BaseModel {
10
10
  readonly OPACITY: 5;
11
11
  readonly OFFSETS: 6;
12
12
  readonly ROTATION: 7;
13
- readonly MAX: 8;
13
+ readonly ANCHOR: 8;
14
+ readonly MAX: 9;
14
15
  } & Record<string, number> & {
15
- MAX: 8;
16
+ MAX: 9;
16
17
  SIZE: number;
17
18
  EXTRUDE: number;
18
19
  };
@@ -16,9 +16,10 @@ export default class TextModel extends BaseModel {
16
16
  readonly OPACITY: 5;
17
17
  readonly OFFSETS: 6;
18
18
  readonly ROTATION: 7;
19
- readonly MAX: 8;
19
+ readonly ANCHOR: 8;
20
+ readonly MAX: 9;
20
21
  } & Record<string, number> & {
21
- MAX: 8;
22
+ MAX: 9;
22
23
  SIZE: number;
23
24
  TEXT_OFFSETS: number;
24
25
  UV: number;
@@ -18,16 +18,48 @@ out float v_innerRadius;
18
18
  #pragma include "projection"
19
19
  #pragma include "picking"
20
20
  #pragma include "project"
21
+
22
+ // 根据 anchor 值计算点精灵的像素偏移
23
+ // anchor: 0=center, 1=top, 2=top-right, 3=right, 4=bottom-right, 5=bottom, 6=bottom-left, 7=left, 8=top-left, 9=bottom-center
24
+ vec2 applyAnchorPoint(float anchor, float pointSize) {
25
+ if (anchor < 0.5) {
26
+ return vec2(0.0);
27
+ }
28
+
29
+ vec2 offset = vec2(0.0);
30
+
31
+ // horizontal alignment: 左边缘对准坐标 -> 向右移; 右边缘对准坐标 -> 向左移
32
+ if (anchor == 2.0 || anchor == 3.0 || anchor == 4.0) {
33
+ offset.x = -pointSize * 0.5;
34
+ } else if (anchor == 6.0 || anchor == 7.0 || anchor == 8.0) {
35
+ offset.x = pointSize * 0.5;
36
+ }
37
+
38
+ // vertical alignment: 上边缘对准坐标 -> 向下移(图形在坐标下方); 下边缘对准坐标 -> 向上移(图形在坐标上方)
39
+ if (anchor == 1.0 || anchor == 2.0 || anchor == 8.0) {
40
+ offset.y = -pointSize * 0.5;
41
+ } else if (anchor == 4.0 || anchor == 5.0 || anchor == 6.0 || anchor == 9.0) {
42
+ offset.y = pointSize * 0.5;
43
+ }
44
+
45
+ return offset;
46
+ }
47
+
21
48
  void main() {
22
49
  v_color = vec4(a_Color.xyz, a_Color.w * opacity);
23
50
  v_blur = 1.0 - max(2.0 / a_Size, 0.05);
24
51
  v_innerRadius = max((a_Size - u_stroke_width) / a_Size, 0.0);
25
52
 
26
- vec2 offset = project_pixel(u_offsets);
53
+ vec2 offset = project_pixel(offsets);
27
54
 
28
55
  vec4 project_pos = project_position(vec4(a_Position, 1.0), a_Position64Low);
29
56
  gl_Position = project_common_position_to_clipspace(vec4(vec2(project_pos.xy+offset),project_pos.z,project_pos.w));
30
57
 
31
58
  gl_PointSize = a_Size * 2.0 * u_DevicePixelRatio;
59
+
60
+ // apply anchor offset in screen space
61
+ vec2 anchorOffset = applyAnchorPoint(anchor, gl_PointSize);
62
+ gl_Position.xy += anchorOffset / u_ViewportSize * 2.0 * gl_Position.w;
63
+
32
64
  setPickingColor(a_PickingColor);
33
65
  }