@antv/l7-layers 2.17.2 → 2.17.4

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