@antv/l7-layers 2.22.7 → 2.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,7 +18,7 @@ export declare function primitiveSphere(radius: number, opt: {
18
18
  segments: number;
19
19
  }): {
20
20
  cells: number[][];
21
- positions: (number[] | Float32Array)[];
21
+ positions: number[][];
22
22
  uvs: number[][];
23
23
  positionsArr: number[];
24
24
  indicesArr: number[];
@@ -7,7 +7,7 @@ import { PointFillTriangulation } from "../../core/triangulation";
7
7
  /* babel-plugin-inline-import '../shaders/fillImage/fillImage_frag.glsl' */
8
8
  const pointFillFrag = "in vec2 v_uv;// \u672C\u8EAB\u7684 uv \u5750\u6807\nin vec2 v_Iconuv;\nin float v_opacity;\nout vec4 outputColor;\n\nuniform sampler2D u_texture;\nlayout(std140) uniform commonUniform {\n vec2 u_textSize;\n float u_heightfixed: 0.0;\n float u_raisingHeight: 0.0;\n float u_size_unit;\n};\n\n#pragma include \"scene_uniforms\"\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nvoid main() {\n vec2 pos = v_Iconuv / u_textSize + v_uv / u_textSize * 64.;\n outputColor = texture(SAMPLER_2D(u_texture), pos);\n outputColor.a *= v_opacity;\n outputColor = filterColor(outputColor);\n}\n";
9
9
  /* babel-plugin-inline-import '../shaders/fillImage/fillImage_vert.glsl' */
10
- const pointFillVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_EXTRUDE) in vec3 a_Extrude;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniform {\n vec2 u_textSize;\n float u_heightfixed;\n float u_raisingHeight;\n float u_size_unit;\n};\n\nout vec2 v_uv;\nout vec2 v_Iconuv;\nout float v_opacity;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\n\nvoid main() {\n vec3 extrude = a_Extrude;\n v_uv = (a_Extrude.xy + 1.0) / 2.0;\n v_uv.y = 1.0 - v_uv.y;\n v_Iconuv = a_Uv;\n v_opacity = opacity;\n float newSize = a_Size;\n if (u_size_unit == 1.0) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n\n // vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);\n vec2 offset = extrude.xy * newSize + offsets;\n\n offset = rotate_matrix(offset, rotation);\n\n offset = project_pixel(offset);\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0), a_Position64Low);\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
10
+ const pointFillVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_EXTRUDE) in vec3 a_Extrude;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniform {\n vec2 u_textSize;\n float u_heightfixed;\n float u_raisingHeight;\n float u_size_unit;\n};\n\nout vec2 v_uv;\nout vec2 v_Iconuv;\nout float v_opacity;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\n\nvoid main() {\n vec3 extrude = a_Extrude;\n v_uv = (a_Extrude.xy + 1.0) / 2.0;\n v_uv.x = 1.0 - v_uv.x;\n v_uv.y = 1.0 - v_uv.y;\n v_Iconuv = a_Uv;\n v_opacity = opacity;\n float newSize = a_Size;\n if (u_size_unit == 1.0) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n\n // vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);\n vec2 offset = extrude.xy * newSize + offsets;\n\n offset = rotate_matrix(offset, rotation);\n\n offset = project_pixel(offset);\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0), a_Position64Low);\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
11
11
  export default class FillImageModel extends BaseModel {
12
12
  constructor(...args) {
13
13
  super(...args);
@@ -23,6 +23,7 @@ out float v_opacity;
23
23
  void main() {
24
24
  vec3 extrude = a_Extrude;
25
25
  v_uv = (a_Extrude.xy + 1.0) / 2.0;
26
+ v_uv.x = 1.0 - v_uv.x;
26
27
  v_uv.y = 1.0 - v_uv.y;
27
28
  v_Iconuv = a_Uv;
28
29
  v_opacity = opacity;
@@ -91,7 +91,16 @@ export function createDataTexture(gl, filter, data) {
91
91
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
92
92
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filter);
93
93
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter);
94
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, data);
94
+
95
+ // 对于 HTMLImageElement,使用正确的 texImage2D 重载
96
+ if (data instanceof HTMLImageElement) {
97
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, data);
98
+ } else {
99
+ // 对于 ArrayBuffer 或其他数据类型,需要提供宽度和高度
100
+ const width = Math.sqrt(data.length / 4); // 假设是RGBA格式,每个像素4个值
101
+ const height = width;
102
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, data);
103
+ }
95
104
  gl.bindTexture(gl.TEXTURE_2D, null);
96
105
  return texture;
97
106
  }
@@ -18,7 +18,7 @@ export declare function primitiveSphere(radius: number, opt: {
18
18
  segments: number;
19
19
  }): {
20
20
  cells: number[][];
21
- positions: (number[] | Float32Array)[];
21
+ positions: number[][];
22
22
  uvs: number[][];
23
23
  positionsArr: number[];
24
24
  indicesArr: number[];
@@ -14,7 +14,7 @@ var _triangulation = require("../../core/triangulation");
14
14
  /* babel-plugin-inline-import '../shaders/fillImage/fillImage_frag.glsl' */
15
15
  const pointFillFrag = "in vec2 v_uv;// \u672C\u8EAB\u7684 uv \u5750\u6807\nin vec2 v_Iconuv;\nin float v_opacity;\nout vec4 outputColor;\n\nuniform sampler2D u_texture;\nlayout(std140) uniform commonUniform {\n vec2 u_textSize;\n float u_heightfixed: 0.0;\n float u_raisingHeight: 0.0;\n float u_size_unit;\n};\n\n#pragma include \"scene_uniforms\"\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\nvoid main() {\n vec2 pos = v_Iconuv / u_textSize + v_uv / u_textSize * 64.;\n outputColor = texture(SAMPLER_2D(u_texture), pos);\n outputColor.a *= v_opacity;\n outputColor = filterColor(outputColor);\n}\n";
16
16
  /* babel-plugin-inline-import '../shaders/fillImage/fillImage_vert.glsl' */
17
- const pointFillVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_EXTRUDE) in vec3 a_Extrude;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniform {\n vec2 u_textSize;\n float u_heightfixed;\n float u_raisingHeight;\n float u_size_unit;\n};\n\nout vec2 v_uv;\nout vec2 v_Iconuv;\nout float v_opacity;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\n\nvoid main() {\n vec3 extrude = a_Extrude;\n v_uv = (a_Extrude.xy + 1.0) / 2.0;\n v_uv.y = 1.0 - v_uv.y;\n v_Iconuv = a_Uv;\n v_opacity = opacity;\n float newSize = a_Size;\n if (u_size_unit == 1.0) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n\n // vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);\n vec2 offset = extrude.xy * newSize + offsets;\n\n offset = rotate_matrix(offset, rotation);\n\n offset = project_pixel(offset);\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0), a_Position64Low);\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
17
+ const pointFillVert = "layout(location = ATTRIBUTE_LOCATION_POSITION) in vec3 a_Position;\nlayout(location = ATTRIBUTE_LOCATION_POSITION_64LOW) in vec2 a_Position64Low;\nlayout(location = ATTRIBUTE_LOCATION_COLOR) in vec4 a_Color;\nlayout(location = ATTRIBUTE_LOCATION_SIZE) in float a_Size;\nlayout(location = ATTRIBUTE_LOCATION_EXTRUDE) in vec3 a_Extrude;\nlayout(location = ATTRIBUTE_LOCATION_UV) in vec2 a_Uv;\n\nlayout(std140) uniform commonUniform {\n vec2 u_textSize;\n float u_heightfixed;\n float u_raisingHeight;\n float u_size_unit;\n};\n\nout vec2 v_uv;\nout vec2 v_Iconuv;\nout float v_opacity;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n#pragma include \"rotation_2d\"\n\nvoid main() {\n vec3 extrude = a_Extrude;\n v_uv = (a_Extrude.xy + 1.0) / 2.0;\n v_uv.x = 1.0 - v_uv.x;\n v_uv.y = 1.0 - v_uv.y;\n v_Iconuv = a_Uv;\n v_opacity = opacity;\n float newSize = a_Size;\n if (u_size_unit == 1.0) {\n newSize = newSize * u_PixelsPerMeter.z;\n }\n\n // vec2 offset = (u_RotateMatrix * extrude.xy * (a_Size) + textrueOffsets);\n vec2 offset = extrude.xy * newSize + offsets;\n\n offset = rotate_matrix(offset, rotation);\n\n offset = project_pixel(offset);\n\n vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0), a_Position64Low);\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
18
18
  class FillImageModel extends _BaseModel.default {
19
19
  constructor(...args) {
20
20
  super(...args);
@@ -23,6 +23,7 @@ out float v_opacity;
23
23
  void main() {
24
24
  vec3 extrude = a_Extrude;
25
25
  v_uv = (a_Extrude.xy + 1.0) / 2.0;
26
+ v_uv.x = 1.0 - v_uv.x;
26
27
  v_uv.y = 1.0 - v_uv.y;
27
28
  v_Iconuv = a_Uv;
28
29
  v_opacity = opacity;
@@ -107,7 +107,16 @@ function createDataTexture(gl, filter, data) {
107
107
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
108
108
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filter);
109
109
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filter);
110
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, data);
110
+
111
+ // 对于 HTMLImageElement,使用正确的 texImage2D 重载
112
+ if (data instanceof HTMLImageElement) {
113
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, data);
114
+ } else {
115
+ // 对于 ArrayBuffer 或其他数据类型,需要提供宽度和高度
116
+ const width = Math.sqrt(data.length / 4); // 假设是RGBA格式,每个像素4个值
117
+ const height = width;
118
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, data);
119
+ }
111
120
  gl.bindTexture(gl.TEXTURE_2D, null);
112
121
  return texture;
113
122
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-layers",
3
- "version": "2.22.7",
3
+ "version": "2.23.1",
4
4
  "description": "L7's collection of built-in layers",
5
5
  "license": "MIT",
6
6
  "author": "https://github.com/orgs/antvis/people",
@@ -33,10 +33,10 @@
33
33
  "gl-matrix": "^3.1.0",
34
34
  "gl-vec2": "^1.3.0",
35
35
  "polyline-miter-util": "^1.0.1",
36
- "@antv/l7-core": "2.22.7",
37
- "@antv/l7-maps": "2.22.7",
38
- "@antv/l7-utils": "2.22.7",
39
- "@antv/l7-source": "2.22.7"
36
+ "@antv/l7-core": "2.23.1",
37
+ "@antv/l7-maps": "2.23.1",
38
+ "@antv/l7-source": "2.23.1",
39
+ "@antv/l7-utils": "2.23.1"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/d3-array": "^2",
@@ -45,7 +45,7 @@
45
45
  "@types/d3-scale": "^2.1.1",
46
46
  "@types/earcut": "^2.1.0",
47
47
  "@types/gl-matrix": "^2.4.5",
48
- "@antv/l7-test-utils": "^2.22.7"
48
+ "@antv/l7-test-utils": "^2.23.1"
49
49
  },
50
50
  "publishConfig": {
51
51
  "access": "public",