@antv/l7-layers 2.17.4 → 2.17.6

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 (250) hide show
  1. package/es/Geometry/index.js +9 -31
  2. package/es/Geometry/models/billboard.js +51 -89
  3. package/es/Geometry/models/plane.js +81 -143
  4. package/es/Geometry/models/sprite.js +60 -118
  5. package/es/canvas/index.js +10 -33
  6. package/es/canvas/models/canvas.js +41 -97
  7. package/es/citybuliding/building.js +8 -27
  8. package/es/citybuliding/models/build.js +57 -82
  9. package/es/core/BaseLayer.js +325 -483
  10. package/es/core/BaseModel.js +51 -80
  11. package/es/core/CommonStyleAttribute.js +2 -5
  12. package/es/core/LayerPickService.js +21 -32
  13. package/es/core/TextureService.js +0 -13
  14. package/es/core/interface.js +17 -24
  15. package/es/core/shape/Path.js +13 -20
  16. package/es/core/shape/extrude.js +27 -39
  17. package/es/core/triangulation.js +99 -136
  18. package/es/earth/index.js +9 -33
  19. package/es/earth/models/atmosphere.js +30 -54
  20. package/es/earth/models/base.js +47 -85
  21. package/es/earth/models/bloomsphere.js +30 -54
  22. package/es/earth/utils.js +9 -13
  23. package/es/heatmap/index.js +10 -40
  24. package/es/heatmap/models/grid.js +28 -52
  25. package/es/heatmap/models/grid3d.js +28 -52
  26. package/es/heatmap/models/heatmap.js +92 -149
  27. package/es/heatmap/models/hexagon.js +28 -52
  28. package/es/heatmap/triangulation.js +0 -4
  29. package/es/image/index.js +9 -28
  30. package/es/image/models/image.js +66 -100
  31. package/es/index.js +9 -17
  32. package/es/line/index.js +9 -35
  33. package/es/line/models/arc.js +63 -112
  34. package/es/line/models/arc_3d.js +58 -102
  35. package/es/line/models/earthArc_3d.js +60 -105
  36. package/es/line/models/flow.js +36 -60
  37. package/es/line/models/great_circle.js +53 -94
  38. package/es/line/models/line.js +92 -144
  39. package/es/line/models/linearline.js +42 -74
  40. package/es/line/models/simpleLine.js +38 -67
  41. package/es/line/models/wall.js +52 -92
  42. package/es/line/shaders/dash/line_dash_vert.glsl +1 -2
  43. package/es/line/shaders/line_frag.glsl +1 -3
  44. package/es/line/shaders/line_vert.glsl +2 -0
  45. package/es/line/shaders/linear/line_linear_frag.glsl +1 -1
  46. package/es/mask/index.js +9 -28
  47. package/es/mask/models/fill.js +29 -54
  48. package/es/plugins/DataMappingPlugin.js +78 -114
  49. package/es/plugins/DataSourcePlugin.js +45 -68
  50. package/es/plugins/FeatureScalePlugin.js +67 -122
  51. package/es/plugins/LayerAnimateStylePlugin.js +0 -5
  52. package/es/plugins/LayerMaskPlugin.js +3 -11
  53. package/es/plugins/LayerModelPlugin.js +69 -118
  54. package/es/plugins/LayerStylePlugin.js +4 -9
  55. package/es/plugins/LightingPlugin.js +12 -18
  56. package/es/plugins/MultiPassRendererPlugin.js +11 -16
  57. package/es/plugins/PixelPickingPlugin.js +12 -21
  58. package/es/plugins/RegisterStyleAttributePlugin.js +5 -12
  59. package/es/plugins/ShaderUniformPlugin.js +13 -27
  60. package/es/plugins/UpdateModelPlugin.js +0 -5
  61. package/es/plugins/UpdateStyleAttributePlugin.js +5 -11
  62. package/es/point/index.js +26 -78
  63. package/es/point/models/earthExtrude.js +58 -95
  64. package/es/point/models/earthFill.js +52 -80
  65. package/es/point/models/extrude.js +57 -94
  66. package/es/point/models/fill.js +56 -81
  67. package/es/point/models/fillmage.js +60 -100
  68. package/es/point/models/image.js +47 -83
  69. package/es/point/models/index.js +2 -2
  70. package/es/point/models/normal.js +30 -54
  71. package/es/point/models/radar.js +38 -63
  72. package/es/point/models/simplePoint.js +38 -62
  73. package/es/point/models/text.js +199 -296
  74. package/es/point/shape/extrude.js +4 -13
  75. package/es/polygon/index.js +11 -41
  76. package/es/polygon/models/extrude.js +87 -135
  77. package/es/polygon/models/fill.js +50 -79
  78. package/es/polygon/models/index.js +3 -2
  79. package/es/polygon/models/ocean.js +42 -76
  80. package/es/polygon/models/water.js +37 -71
  81. package/es/raster/buffers/triangulation.js +2 -4
  82. package/es/raster/index.js +9 -32
  83. package/es/raster/models/raster.js +80 -116
  84. package/es/raster/models/rasterRgb.js +84 -127
  85. package/es/raster/models/rasterTerrainRgb.js +56 -84
  86. package/es/tile/interaction/getRasterData.js +14 -20
  87. package/es/tile/interaction/utils.js +7 -9
  88. package/es/tile/manager/base.js +63 -96
  89. package/es/tile/service/TileLayerService.js +33 -55
  90. package/es/tile/service/TilePickService.js +26 -40
  91. package/es/tile/service/TileSourceService.js +3 -7
  92. package/es/tile/tileFactory/DebugTile.js +29 -46
  93. package/es/tile/tileFactory/ImageTile.js +20 -38
  94. package/es/tile/tileFactory/MaskTile.js +22 -43
  95. package/es/tile/tileFactory/RasterRGBTile.js +22 -42
  96. package/es/tile/tileFactory/RasterTerrainRGBTile.js +20 -38
  97. package/es/tile/tileFactory/RasterTile.js +30 -53
  98. package/es/tile/tileFactory/Tile.js +63 -97
  99. package/es/tile/tileFactory/VectorTile.js +41 -68
  100. package/es/tile/tileFactory/index.js +0 -11
  101. package/es/tile/tileFactory/layers/TileDebugLayer.js +6 -27
  102. package/es/tile/tileFactory/util.js +0 -3
  103. package/es/tile/tileLayer/BaseLayer.js +105 -146
  104. package/es/tile/utils.js +1 -1
  105. package/es/utils/blend.js +0 -2
  106. package/es/utils/collision-index.js +9 -16
  107. package/es/utils/extrude_polyline.js +101 -149
  108. package/es/utils/grid-index.js +2 -27
  109. package/es/utils/identityScale.js +0 -8
  110. package/es/utils/layerData.js +30 -44
  111. package/es/utils/multiPassRender.js +11 -13
  112. package/es/utils/polylineNormal.js +31 -37
  113. package/es/utils/simpleLine.js +2 -16
  114. package/es/utils/stencil.js +2 -3
  115. package/es/utils/symbol-layout.js +27 -53
  116. package/es/wind/index.js +9 -29
  117. package/es/wind/models/utils.js +26 -51
  118. package/es/wind/models/wind.js +101 -147
  119. package/es/wind/models/windRender.js +53 -66
  120. package/lib/Geometry/index.js +9 -38
  121. package/lib/Geometry/models/billboard.js +51 -97
  122. package/lib/Geometry/models/index.js +0 -5
  123. package/lib/Geometry/models/plane.js +79 -151
  124. package/lib/Geometry/models/sprite.js +60 -127
  125. package/lib/canvas/index.js +10 -40
  126. package/lib/canvas/models/canvas.js +41 -101
  127. package/lib/canvas/models/index.js +0 -3
  128. package/lib/citybuliding/building.js +8 -35
  129. package/lib/citybuliding/models/build.js +57 -92
  130. package/lib/core/BaseLayer.js +325 -474
  131. package/lib/core/BaseModel.js +51 -90
  132. package/lib/core/CommonStyleAttribute.js +2 -7
  133. package/lib/core/LayerPickService.js +21 -37
  134. package/lib/core/TextureService.js +0 -16
  135. package/lib/core/interface.js +21 -31
  136. package/lib/core/schema.js +0 -1
  137. package/lib/core/shape/Path.js +14 -31
  138. package/lib/core/shape/extrude.js +27 -62
  139. package/lib/core/triangulation.js +98 -177
  140. package/lib/earth/index.js +9 -43
  141. package/lib/earth/models/atmosphere.js +30 -63
  142. package/lib/earth/models/base.js +47 -90
  143. package/lib/earth/models/bloomsphere.js +30 -63
  144. package/lib/earth/utils.js +7 -31
  145. package/lib/heatmap/index.js +10 -48
  146. package/lib/heatmap/models/grid.js +28 -60
  147. package/lib/heatmap/models/grid3d.js +28 -60
  148. package/lib/heatmap/models/heatmap.js +92 -166
  149. package/lib/heatmap/models/hexagon.js +28 -60
  150. package/lib/heatmap/models/index.js +0 -6
  151. package/lib/heatmap/triangulation.js +0 -5
  152. package/lib/image/index.js +9 -36
  153. package/lib/image/models/image.js +66 -109
  154. package/lib/image/models/index.js +0 -3
  155. package/lib/index.js +7 -61
  156. package/lib/line/index.js +9 -40
  157. package/lib/line/models/arc.js +61 -122
  158. package/lib/line/models/arc_3d.js +56 -113
  159. package/lib/line/models/earthArc_3d.js +58 -115
  160. package/lib/line/models/flow.js +36 -70
  161. package/lib/line/models/great_circle.js +53 -104
  162. package/lib/line/models/index.js +0 -11
  163. package/lib/line/models/line.js +90 -152
  164. package/lib/line/models/linearline.js +42 -86
  165. package/lib/line/models/simpleLine.js +38 -77
  166. package/lib/line/models/wall.js +52 -103
  167. package/lib/line/shaders/dash/line_dash_vert.glsl +1 -2
  168. package/lib/line/shaders/line_frag.glsl +1 -3
  169. package/lib/line/shaders/line_vert.glsl +2 -0
  170. package/lib/line/shaders/linear/line_linear_frag.glsl +1 -1
  171. package/lib/mask/index.js +9 -36
  172. package/lib/mask/models/fill.js +29 -63
  173. package/lib/mask/models/index.js +0 -3
  174. package/lib/plugins/DataMappingPlugin.js +78 -125
  175. package/lib/plugins/DataSourcePlugin.js +45 -76
  176. package/lib/plugins/FeatureScalePlugin.js +67 -138
  177. package/lib/plugins/LayerAnimateStylePlugin.js +0 -10
  178. package/lib/plugins/LayerMaskPlugin.js +4 -17
  179. package/lib/plugins/LayerModelPlugin.js +70 -127
  180. package/lib/plugins/LayerStylePlugin.js +5 -14
  181. package/lib/plugins/LightingPlugin.js +12 -25
  182. package/lib/plugins/MultiPassRendererPlugin.js +11 -22
  183. package/lib/plugins/PixelPickingPlugin.js +12 -27
  184. package/lib/plugins/RegisterStyleAttributePlugin.js +5 -19
  185. package/lib/plugins/ShaderUniformPlugin.js +13 -34
  186. package/lib/plugins/UpdateModelPlugin.js +1 -10
  187. package/lib/plugins/UpdateStyleAttributePlugin.js +5 -16
  188. package/lib/point/index.js +26 -83
  189. package/lib/point/models/earthExtrude.js +58 -106
  190. package/lib/point/models/earthFill.js +52 -110
  191. package/lib/point/models/extrude.js +57 -103
  192. package/lib/point/models/fill.js +54 -90
  193. package/lib/point/models/fillmage.js +58 -107
  194. package/lib/point/models/image.js +47 -92
  195. package/lib/point/models/index.js +1 -12
  196. package/lib/point/models/normal.js +30 -64
  197. package/lib/point/models/radar.js +38 -72
  198. package/lib/point/models/simplePoint.js +38 -72
  199. package/lib/point/models/text.js +199 -305
  200. package/lib/point/shape/extrude.js +4 -20
  201. package/lib/polygon/index.js +11 -48
  202. package/lib/polygon/models/extrude.js +87 -146
  203. package/lib/polygon/models/fill.js +50 -89
  204. package/lib/polygon/models/index.js +2 -14
  205. package/lib/polygon/models/ocean.js +42 -88
  206. package/lib/polygon/models/water.js +37 -82
  207. package/lib/raster/buffers/triangulation.js +3 -7
  208. package/lib/raster/index.js +9 -40
  209. package/lib/raster/models/index.js +0 -5
  210. package/lib/raster/models/raster.js +80 -125
  211. package/lib/raster/models/rasterRgb.js +84 -139
  212. package/lib/raster/models/rasterTerrainRgb.js +56 -93
  213. package/lib/tile/interaction/getRasterData.js +14 -25
  214. package/lib/tile/interaction/utils.js +7 -19
  215. package/lib/tile/manager/base.js +63 -104
  216. package/lib/tile/service/TileLayerService.js +33 -60
  217. package/lib/tile/service/TilePickService.js +26 -48
  218. package/lib/tile/service/TileSourceService.js +2 -16
  219. package/lib/tile/style/utils.js +0 -3
  220. package/lib/tile/tileFactory/DebugTile.js +29 -54
  221. package/lib/tile/tileFactory/ImageTile.js +20 -46
  222. package/lib/tile/tileFactory/MaskTile.js +22 -51
  223. package/lib/tile/tileFactory/RasterRGBTile.js +22 -50
  224. package/lib/tile/tileFactory/RasterTerrainRGBTile.js +20 -46
  225. package/lib/tile/tileFactory/RasterTile.js +30 -63
  226. package/lib/tile/tileFactory/Tile.js +63 -102
  227. package/lib/tile/tileFactory/VectorTile.js +41 -76
  228. package/lib/tile/tileFactory/index.js +0 -25
  229. package/lib/tile/tileFactory/layers/TileDebugLayer.js +6 -32
  230. package/lib/tile/tileFactory/util.js +0 -9
  231. package/lib/tile/tileLayer/BaseLayer.js +105 -153
  232. package/lib/tile/utils.js +1 -5
  233. package/lib/utils/blend.js +0 -5
  234. package/lib/utils/collision-index.js +9 -25
  235. package/lib/utils/extrude_polyline.js +101 -181
  236. package/lib/utils/grid-index.js +2 -28
  237. package/lib/utils/identityScale.js +0 -9
  238. package/lib/utils/layerData.js +30 -49
  239. package/lib/utils/multiPassRender.js +11 -16
  240. package/lib/utils/polylineNormal.js +31 -66
  241. package/lib/utils/simpleLine.js +2 -21
  242. package/lib/utils/stencil.js +0 -4
  243. package/lib/utils/symbol-layout.js +27 -55
  244. package/lib/wind/index.js +9 -37
  245. package/lib/wind/models/index.js +0 -3
  246. package/lib/wind/models/utils.js +26 -62
  247. package/lib/wind/models/wind.js +101 -157
  248. package/lib/wind/models/windRender.js +53 -71
  249. package/lib/wind/models/windShader.js +0 -1
  250. package/package.json +7 -7
@@ -1,5 +1,5 @@
1
- import { gl, MaskOperation, StencilType } from '@antv/l7-core'; // 掩膜配置
2
-
1
+ import { gl, MaskOperation, StencilType } from '@antv/l7-core';
2
+ // 掩膜配置
3
3
  export function getStencil(mask, maskInside) {
4
4
  return {
5
5
  enable: mask,
@@ -30,7 +30,6 @@ export function getStencilMask(option) {
30
30
  }
31
31
  };
32
32
  }
33
-
34
33
  return {
35
34
  enable: true,
36
35
  mask: 0xff,
@@ -1,9 +1,6 @@
1
1
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
-
3
2
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
-
5
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
6
-
3
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
7
4
  /**
8
5
  * 返回文本相对锚点位置
9
6
  * @param {string} anchor 锚点位置
@@ -12,76 +9,64 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
12
9
  function getAnchorAlignment(anchor) {
13
10
  var horizontalAlign = 0.5;
14
11
  var verticalAlign = 0.5;
15
-
16
12
  switch (anchor) {
17
13
  case 'right':
18
14
  case 'top-right':
19
15
  case 'bottom-right':
20
16
  horizontalAlign = 1;
21
17
  break;
22
-
23
18
  case 'left':
24
19
  case 'top-left':
25
20
  case 'bottom-left':
26
21
  horizontalAlign = 0;
27
22
  break;
28
-
29
23
  default:
30
24
  horizontalAlign = 0.5;
31
25
  }
32
-
33
26
  switch (anchor) {
34
27
  case 'bottom':
35
28
  case 'bottom-right':
36
29
  case 'bottom-left':
37
30
  verticalAlign = 1;
38
31
  break;
39
-
40
32
  case 'top':
41
33
  case 'top-right':
42
34
  case 'top-left':
43
35
  verticalAlign = 0;
44
36
  break;
45
-
46
37
  default:
47
38
  verticalAlign = 0.5;
48
39
  }
49
-
50
40
  return {
51
41
  horizontalAlign: horizontalAlign,
52
42
  verticalAlign: verticalAlign
53
43
  };
54
- } // justify right = 1, left = 0, center = 0.5
55
-
44
+ }
56
45
 
46
+ // justify right = 1, left = 0, center = 0.5
57
47
  function justifyLine(positionedGlyphs, glyphMap, start, end, justify) {
58
48
  if (!justify) {
59
49
  return;
60
50
  }
61
-
62
51
  var lastPositionedGlyph = positionedGlyphs[end];
63
52
  var glyph = lastPositionedGlyph.glyph;
64
-
65
53
  if (glyph) {
66
54
  var lastAdvance = glyphMap[glyph].advance * lastPositionedGlyph.scale;
67
55
  var lineIndent = (positionedGlyphs[end].x + lastAdvance) * justify;
68
-
69
56
  for (var j = start; j <= end; j++) {
70
57
  positionedGlyphs[j].x -= lineIndent;
71
58
  }
72
59
  }
73
- } // justify right=1 left=0 center=0.5
60
+ }
61
+
62
+ // justify right=1 left=0 center=0.5
74
63
  // horizontalAlign right=1 left=0 center=0.5
75
64
  // verticalAlign right=1 left=0 center=0.5
76
-
77
-
78
65
  function align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, lineCount) {
79
66
  var shiftX = (justify - horizontalAlign) * maxLineLength;
80
67
  var shiftY = (-verticalAlign * lineCount + 0.5) * lineHeight;
81
-
82
68
  var _iterator = _createForOfIteratorHelper(positionedGlyphs),
83
- _step;
84
-
69
+ _step;
85
70
  try {
86
71
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
87
72
  var glyphs = _step.value;
@@ -94,7 +79,6 @@ function align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLin
94
79
  _iterator.f();
95
80
  }
96
81
  }
97
-
98
82
  function shapeLines(shaping, glyphMap, lines, lineHeight, textAnchor, textJustify, spacing) {
99
83
  // buffer 为 4
100
84
  var yOffset = -8;
@@ -108,7 +92,6 @@ function shapeLines(shaping, glyphMap, lines, lineHeight, textAnchor, textJustif
108
92
  line.split('').forEach(function (char) {
109
93
  var glyph = glyphMap[char];
110
94
  var baselineOffset = 0;
111
-
112
95
  if (glyph) {
113
96
  positionedGlyphs.push({
114
97
  glyph: char,
@@ -121,31 +104,29 @@ function shapeLines(shaping, glyphMap, lines, lineHeight, textAnchor, textJustif
121
104
  });
122
105
  x += glyph.advance + spacing;
123
106
  }
124
- }); // 左右对齐
107
+ });
125
108
 
109
+ // 左右对齐
126
110
  if (positionedGlyphs.length !== lineStartIndex) {
127
111
  var lineLength = x - spacing;
128
112
  maxLineLength = Math.max(lineLength, maxLineLength);
129
113
  justifyLine(positionedGlyphs, glyphMap, lineStartIndex, positionedGlyphs.length - 1, justify);
130
114
  }
131
-
132
115
  x = 0;
133
116
  y -= lineHeight + 5;
134
117
  });
135
-
136
118
  var _getAnchorAlignment = getAnchorAlignment(textAnchor),
137
- horizontalAlign = _getAnchorAlignment.horizontalAlign,
138
- verticalAlign = _getAnchorAlignment.verticalAlign;
139
-
140
- align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, lines.length); // 计算包围盒
119
+ horizontalAlign = _getAnchorAlignment.horizontalAlign,
120
+ verticalAlign = _getAnchorAlignment.verticalAlign;
121
+ align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, lines.length);
141
122
 
123
+ // 计算包围盒
142
124
  var height = y - yOffset;
143
125
  shaping.top += -verticalAlign * height;
144
126
  shaping.bottom = shaping.top - height;
145
127
  shaping.left += -horizontalAlign * maxLineLength;
146
128
  shaping.right = shaping.left + maxLineLength;
147
129
  }
148
-
149
130
  function shapeIconFont(shaping, glyphMap, iconfonts, lineHeight, textAnchor, textJustify, spacing) {
150
131
  // buffer 为 4
151
132
  var yOffset = -8;
@@ -158,12 +139,10 @@ function shapeIconFont(shaping, glyphMap, iconfonts, lineHeight, textAnchor, tex
158
139
  iconfonts.forEach(function (iconfont) {
159
140
  var glyph = glyphMap[iconfont];
160
141
  var baselineOffset = 0;
161
-
162
142
  if (glyph) {
163
143
  positionedGlyphs.push({
164
144
  glyph: iconfont,
165
145
  // x,
166
-
167
146
  /**
168
147
  * iconfont
169
148
  * 在计算大小的时候计算的是 unicode 字符 如 &#xe6d4;
@@ -177,31 +156,30 @@ function shapeIconFont(shaping, glyphMap, iconfonts, lineHeight, textAnchor, tex
177
156
  metrics: glyph
178
157
  });
179
158
  x += glyph.advance + spacing;
180
- } // 左右对齐
181
-
159
+ }
182
160
 
161
+ // 左右对齐
183
162
  if (positionedGlyphs.length !== lineStartIndex) {
184
163
  var lineLength = x - spacing;
185
164
  maxLineLength = Math.max(lineLength, maxLineLength);
186
165
  justifyLine(positionedGlyphs, glyphMap, lineStartIndex, positionedGlyphs.length - 1, justify);
187
166
  }
188
-
189
167
  x = 0;
190
168
  y -= lineHeight + 5;
191
169
  });
192
-
193
170
  var _getAnchorAlignment2 = getAnchorAlignment(textAnchor),
194
- horizontalAlign = _getAnchorAlignment2.horizontalAlign,
195
- verticalAlign = _getAnchorAlignment2.verticalAlign;
196
-
197
- align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, iconfonts.length); // 计算包围盒
171
+ horizontalAlign = _getAnchorAlignment2.horizontalAlign,
172
+ verticalAlign = _getAnchorAlignment2.verticalAlign;
173
+ align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, iconfonts.length);
198
174
 
175
+ // 计算包围盒
199
176
  var height = y - yOffset;
200
177
  shaping.top += -verticalAlign * height;
201
178
  shaping.bottom = shaping.top - height;
202
179
  shaping.left += -horizontalAlign * maxLineLength;
203
180
  shaping.right = shaping.left + maxLineLength;
204
181
  }
182
+
205
183
  /**
206
184
  * 计算文本中每个独立字符相对锚点的位置
207
185
  *
@@ -215,8 +193,6 @@ function shapeIconFont(shaping, glyphMap, iconfonts, lineHeight, textAnchor, tex
215
193
  * @param {[boolean]} isIconFont 是否是 iconfont
216
194
  * @return {boolean|shaping} 每个字符相对于锚点的位置
217
195
  */
218
-
219
-
220
196
  export function shapeText(text, glyphs, lineHeight, textAnchor, textJustify, spacing) {
221
197
  var translate = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : [0, 0];
222
198
  var isIconFont = arguments.length > 7 ? arguments[7] : undefined;
@@ -233,28 +209,25 @@ export function shapeText(text, glyphs, lineHeight, textAnchor, textJustify, spa
233
209
  text: text
234
210
  };
235
211
  isIconFont ? shapeIconFont(shaping, glyphs, lines, lineHeight, textAnchor, textJustify, spacing) : shapeLines(shaping, glyphs, lines, lineHeight, textAnchor, textJustify, spacing);
236
-
237
212
  if (!positionedGlyphs.length) {
238
213
  return false;
239
214
  }
240
-
241
215
  return shaping;
242
216
  }
243
217
  export function getGlyphQuads(shaping) {
244
218
  var textOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0];
245
219
  var alongLine = arguments.length > 2 ? arguments[2] : undefined;
246
220
  var _shaping$positionedGl = shaping.positionedGlyphs,
247
- positionedGlyphs = _shaping$positionedGl === void 0 ? [] : _shaping$positionedGl;
221
+ positionedGlyphs = _shaping$positionedGl === void 0 ? [] : _shaping$positionedGl;
248
222
  var quads = [];
249
-
250
223
  var _iterator2 = _createForOfIteratorHelper(positionedGlyphs),
251
- _step2;
252
-
224
+ _step2;
253
225
  try {
254
226
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
255
227
  var positionedGlyph = _step2.value;
256
- var rect = positionedGlyph.metrics; // The rects have an addditional buffer that is not included in their size.
228
+ var rect = positionedGlyph.metrics;
257
229
 
230
+ // The rects have an addditional buffer that is not included in their size.
258
231
  var rectBuffer = 4;
259
232
  var halfAdvance = rect.advance * positionedGlyph.scale / 2;
260
233
  var glyphOffset = alongLine ? [positionedGlyph.x + halfAdvance, positionedGlyph.y] : [0, 0];
@@ -278,7 +251,9 @@ export function getGlyphQuads(shaping) {
278
251
  var br = {
279
252
  x: x2,
280
253
  y: y2
281
- }; // TODO:处理字符旋转的情况
254
+ };
255
+
256
+ // TODO:处理字符旋转的情况
282
257
 
283
258
  quads.push({
284
259
  tl: tl,
@@ -294,6 +269,5 @@ export function getGlyphQuads(shaping) {
294
269
  } finally {
295
270
  _iterator2.f();
296
271
  }
297
-
298
272
  return quads;
299
273
  }
package/es/wind/index.js CHANGED
@@ -7,68 +7,50 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConst
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
8
8
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
9
9
  import _regeneratorRuntime from "@babel/runtime/regenerator";
10
-
11
10
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
12
-
13
11
  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; } }
14
-
15
12
  import BaseLayer from "../core/BaseLayer";
16
13
  import WindModels from "./models";
17
-
18
14
  var WindLayer = /*#__PURE__*/function (_BaseLayer) {
19
15
  _inherits(WindLayer, _BaseLayer);
20
-
21
16
  var _super = _createSuper(WindLayer);
22
-
23
17
  function WindLayer() {
24
18
  var _this;
25
-
26
19
  _classCallCheck(this, WindLayer);
27
-
28
20
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
29
21
  args[_key] = arguments[_key];
30
22
  }
31
-
32
23
  _this = _super.call.apply(_super, [this].concat(args));
33
-
34
24
  _defineProperty(_assertThisInitialized(_this), "type", 'WindLayer');
35
-
36
25
  return _this;
37
26
  }
38
-
39
27
  _createClass(WindLayer, [{
40
28
  key: "buildModels",
41
29
  value: function () {
42
30
  var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
43
31
  var modelType;
44
32
  return _regeneratorRuntime.wrap(function _callee$(_context) {
45
- while (1) {
46
- switch (_context.prev = _context.next) {
47
- case 0:
48
- modelType = this.getModelType();
49
- this.layerModel = new WindModels[modelType](this);
50
- _context.next = 4;
51
- return this.initLayerModels();
52
-
53
- case 4:
54
- case "end":
55
- return _context.stop();
56
- }
33
+ while (1) switch (_context.prev = _context.next) {
34
+ case 0:
35
+ modelType = this.getModelType();
36
+ this.layerModel = new WindModels[modelType](this);
37
+ _context.next = 4;
38
+ return this.initLayerModels();
39
+ case 4:
40
+ case "end":
41
+ return _context.stop();
57
42
  }
58
43
  }, _callee, this);
59
44
  }));
60
-
61
45
  function buildModels() {
62
46
  return _buildModels.apply(this, arguments);
63
47
  }
64
-
65
48
  return buildModels;
66
49
  }()
67
50
  }, {
68
51
  key: "renderModels",
69
52
  value: function renderModels() {
70
53
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
71
-
72
54
  if (this.layerModel) {
73
55
  this.layerModel.render(options); // 独立的渲染流程
74
56
  }
@@ -90,8 +72,6 @@ var WindLayer = /*#__PURE__*/function (_BaseLayer) {
90
72
  return 'wind';
91
73
  }
92
74
  }]);
93
-
94
75
  return WindLayer;
95
76
  }(BaseLayer);
96
-
97
77
  export { WindLayer as default };
@@ -1,30 +1,26 @@
1
1
  export function createProgram(gl, vshader, fshader) {
2
2
  // Create shader object
3
3
  var vertexShader = loadShader(gl, gl.VERTEX_SHADER, vshader); // 创建顶点着色器对象
4
-
5
4
  var fragmentShader = loadShader(gl, gl.FRAGMENT_SHADER, fshader); // 创建片元着色器对象
6
-
7
5
  if (!vertexShader || !fragmentShader) {
8
6
  return null;
9
- } // Create a program object
10
-
7
+ }
11
8
 
9
+ // Create a program object
12
10
  var program = gl.createProgram(); // 创建程序对象
13
-
14
11
  if (!program) {
15
12
  return null;
16
- } // Attach the shader objects
17
-
13
+ }
18
14
 
15
+ // Attach the shader objects
19
16
  gl.attachShader(program, vertexShader); // 绑定着色器对象
17
+ gl.attachShader(program, fragmentShader);
20
18
 
21
- gl.attachShader(program, fragmentShader); // Link the program object
22
-
19
+ // Link the program object
23
20
  gl.linkProgram(program); // 链接着色器对象
24
- // Check the result of linking
25
21
 
22
+ // Check the result of linking
26
23
  var linked = gl.getProgramParameter(program, gl.LINK_STATUS); // 判断着色器对象是否链接成功
27
-
28
24
  if (!linked) {
29
25
  var error = gl.getProgramInfoLog(program);
30
26
  console.warn('Failed to link program: ' + error);
@@ -33,55 +29,48 @@ export function createProgram(gl, vshader, fshader) {
33
29
  gl.deleteShader(vertexShader);
34
30
  return null;
35
31
  }
36
-
37
32
  var numAttributes = gl.getProgramParameter(program, gl.ACTIVE_ATTRIBUTES);
38
-
39
33
  for (var i = 0; i < numAttributes; i++) {
40
- var attribute = gl.getActiveAttrib(program, i); // @ts-ignore
41
-
34
+ var attribute = gl.getActiveAttrib(program, i);
35
+ // @ts-ignore
42
36
  program[attribute.name] = gl.getAttribLocation(program, attribute.name);
43
37
  }
44
-
45
38
  var numUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
46
-
47
39
  for (var i$1 = 0; i$1 < numUniforms; i$1++) {
48
- var uniform = gl.getActiveUniform(program, i$1); // @ts-ignore
49
-
40
+ var uniform = gl.getActiveUniform(program, i$1);
41
+ // @ts-ignore
50
42
  program[uniform.name] = gl.getUniformLocation(program, uniform.name);
51
- } // @ts-ignore
52
-
53
-
54
- program.vertexShader = vertexShader; // @ts-ignore
43
+ }
55
44
 
45
+ // @ts-ignore
46
+ program.vertexShader = vertexShader;
47
+ // @ts-ignore
56
48
  program.fragmentShader = fragmentShader;
57
49
  return program;
58
50
  }
59
51
  export function loadShader(gl, type, source) {
60
52
  // Create shader object
61
53
  var shader = gl.createShader(type); // 生成着色器对象
62
-
63
54
  if (shader == null) {
64
55
  console.warn('unable to create shader');
65
56
  return null;
66
- } // Set the shader program
67
-
57
+ }
68
58
 
59
+ // Set the shader program
69
60
  gl.shaderSource(shader, source); // 载入着色器
70
- // Compile the shader
71
61
 
62
+ // Compile the shader
72
63
  gl.compileShader(shader); // 编译着色器代码
73
- // Check the result of compilation
74
64
 
65
+ // Check the result of compilation
75
66
  var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS); // 判断着色器对象是否生成成功
76
67
  // gl.SHADER_TYPE、gl.DELETE_STATUS、gl.COMPILE_STATUS
77
-
78
68
  if (!compiled) {
79
69
  var error = gl.getShaderInfoLog(shader);
80
70
  console.warn('Failed to compile shader: ' + error);
81
71
  gl.deleteShader(shader);
82
72
  return null;
83
73
  }
84
-
85
74
  return shader;
86
75
  }
87
76
  export function createTexture(gl, filter, data, width, height) {
@@ -118,13 +107,10 @@ export function createBuffer(gl, data) {
118
107
  }
119
108
  export function bindAttriBuffer(gl, attrName, vertices, count, program) {
120
109
  var buffer = gl.createBuffer();
121
-
122
110
  if (!buffer) {
123
111
  console.warn('failed create vertex buffer');
124
112
  }
125
-
126
113
  gl.bindBuffer(gl.ARRAY_BUFFER, buffer); // 将缓冲区对象绑定到目标
127
-
128
114
  gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW); // 向缓冲区对象中写入数据
129
115
 
130
116
  var attr = gl.getAttribLocation(program, attrName);
@@ -139,25 +125,21 @@ export function bindAttriBuffer(gl, attrName, vertices, count, program) {
139
125
  }
140
126
  export function bindAttriIndicesBuffer(gl, indices) {
141
127
  var buffer = gl.createBuffer();
142
-
143
128
  if (!buffer) {
144
129
  console.warn('failed create vertex buffer');
145
130
  } else {
146
131
  gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buffer);
147
132
  gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
148
133
  }
149
-
150
134
  return buffer;
151
135
  }
152
136
  export function bindUnifrom(gl, unifromName, data, program, vec) {
153
137
  var uniform = gl.getUniformLocation(program, unifromName);
154
-
155
138
  if (uniform === null || uniform < 0) {
156
139
  console.warn('无法获取 uniform 变量的存储位置');
157
140
  } else {
158
141
  setUnifrom(gl, uniform, data, vec);
159
142
  }
160
-
161
143
  return uniform;
162
144
  }
163
145
  export function setUnifrom(gl, location, data, vec) {
@@ -165,27 +147,20 @@ export function setUnifrom(gl, location, data, vec) {
165
147
  case 'float':
166
148
  gl.uniform1f(location, data);
167
149
  break;
168
-
169
150
  case 'vec2':
170
151
  gl.uniform2fv(location, data);
171
152
  break;
172
-
173
153
  case 'vec3':
174
154
  gl.uniform3fv(location, data);
175
155
  break;
176
-
177
156
  case 'vec4':
178
157
  gl.uniform4fv(location, data);
179
158
  break;
180
-
181
159
  case 'bool':
182
160
  gl.uniform1i(location, data); // 1 - true 0 - false
183
-
184
161
  break;
185
-
186
162
  case 'sampler2d':
187
163
  break;
188
-
189
164
  case 'mat4':
190
165
  gl.uniformMatrix4fv(location, false, data);
191
166
  break;
@@ -193,7 +168,7 @@ export function setUnifrom(gl, location, data, vec) {
193
168
  }
194
169
  export function initFramebuffer(gl) {
195
170
  var drawingBufferWidth = gl.drawingBufferWidth,
196
- drawingBufferHeight = gl.drawingBufferHeight;
171
+ drawingBufferHeight = gl.drawingBufferHeight;
197
172
  var OFFER_SCREEN_WIDTH = drawingBufferWidth;
198
173
  var OFFER_SCREEN_HEIGHT = drawingBufferHeight;
199
174
  var FRAMEBUFFER = gl.createFramebuffer();
@@ -202,12 +177,12 @@ export function initFramebuffer(gl) {
202
177
  gl.bindRenderbuffer(gl.RENDERBUFFER, depthbuffer);
203
178
  gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, OFFER_SCREEN_WIDTH, OFFER_SCREEN_HEIGHT);
204
179
  gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthbuffer);
205
- var texture = gl.createTexture(); // @ts-ignore
206
-
207
- FRAMEBUFFER.texture = texture; // @ts-ignore
208
-
209
- FRAMEBUFFER.width = OFFER_SCREEN_WIDTH; // @ts-ignore
210
-
180
+ var texture = gl.createTexture();
181
+ // @ts-ignore
182
+ FRAMEBUFFER.texture = texture;
183
+ // @ts-ignore
184
+ FRAMEBUFFER.width = OFFER_SCREEN_WIDTH;
185
+ // @ts-ignore
211
186
  FRAMEBUFFER.height = OFFER_SCREEN_HEIGHT;
212
187
  gl.bindTexture(gl.TEXTURE_2D, texture);
213
188
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);