@antv/l7-layers 2.9.23 → 2.9.25

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 (166) hide show
  1. package/es/Geometry/models/plane.d.ts +1 -0
  2. package/es/citybuliding/building.js +1 -1
  3. package/es/core/BaseLayer.js +10 -3
  4. package/es/core/interface.d.ts +26 -48
  5. package/es/core/interface.js +3 -0
  6. package/es/core/schema.d.ts +3 -3
  7. package/es/core/triangulation.d.ts +4 -3
  8. package/es/core/triangulation.js +54 -39
  9. package/es/heatmap/models/heatmap.js +1 -1
  10. package/es/image/models/image.js +7 -1
  11. package/es/line/index.js +4 -1
  12. package/es/line/models/arc.js +1 -1
  13. package/es/line/models/simpleLine.js +1 -1
  14. package/es/line/shaders/line_arc_vert.glsl +5 -3
  15. package/es/line/shaders/simple/simpleline_vert.glsl +1 -0
  16. package/es/plugins/FeatureScalePlugin.js +0 -1
  17. package/es/point/index.js +3 -1
  18. package/es/point/models/fill.js +5 -2
  19. package/es/point/models/fillmage.js +9 -3
  20. package/es/point/models/image.js +8 -2
  21. package/es/point/models/radar.js +2 -3
  22. package/es/point/models/tile.js +1 -1
  23. package/es/point/shaders/fill_vert.glsl +13 -6
  24. package/es/point/shaders/image/fillImage_vert.glsl +13 -5
  25. package/es/point/shaders/image_vert.glsl +17 -8
  26. package/es/polygon/index.js +4 -1
  27. package/es/raster/index.js +3 -1
  28. package/es/tile/manager/tileLayerManager.d.ts +3 -2
  29. package/es/tile/manager/tileLayerManager.js +5 -2
  30. package/es/tile/models/tileModel.js +4 -3
  31. package/es/tile/tileFactory/base.d.ts +1 -1
  32. package/es/tile/tileFactory/base.js +32 -5
  33. package/es/tile/tileFactory/vectorLayer.d.ts +3 -1
  34. package/es/tile/tileFactory/vectorLayer.js +22 -1
  35. package/es/tile/tileLayer/baseTileLayer.d.ts +1 -1
  36. package/es/tile/tileLayer/baseTileLayer.js +3 -2
  37. package/es/tile/utils.d.ts +2 -0
  38. package/es/tile/utils.js +5 -1
  39. package/lib/Geometry/index.js +114 -77
  40. package/lib/Geometry/models/billboard.js +232 -181
  41. package/lib/Geometry/models/index.js +18 -34
  42. package/lib/Geometry/models/plane.js +407 -278
  43. package/lib/Geometry/models/sprite.js +291 -189
  44. package/lib/canvas/index.js +101 -66
  45. package/lib/canvas/models/canvas.js +207 -140
  46. package/lib/canvas/models/index.js +12 -30
  47. package/lib/citybuliding/building.js +98 -63
  48. package/lib/citybuliding/models/build.js +192 -146
  49. package/lib/core/BaseLayer.js +1331 -809
  50. package/lib/core/BaseModel.js +457 -279
  51. package/lib/core/interface.js +40 -53
  52. package/lib/core/schema.js +21 -39
  53. package/lib/core/shape/Path.js +67 -79
  54. package/lib/core/shape/extrude.js +132 -91
  55. package/lib/core/triangulation.js +412 -213
  56. package/lib/earth/index.js +100 -62
  57. package/lib/earth/models/atmosphere.js +146 -112
  58. package/lib/earth/models/base.js +210 -150
  59. package/lib/earth/models/bloomsphere.js +146 -112
  60. package/lib/earth/utils.js +111 -91
  61. package/lib/heatmap/index.js +149 -92
  62. package/lib/heatmap/models/grid.js +118 -91
  63. package/lib/heatmap/models/grid3d.js +155 -123
  64. package/lib/heatmap/models/heatmap.js +475 -338
  65. package/lib/heatmap/models/hexagon.js +121 -92
  66. package/lib/heatmap/models/index.js +22 -37
  67. package/lib/heatmap/triangulation.js +31 -47
  68. package/lib/image/index.js +111 -74
  69. package/lib/image/models/dataImage.js +232 -174
  70. package/lib/image/models/image.js +175 -123
  71. package/lib/image/models/index.js +15 -32
  72. package/lib/index.js +263 -97
  73. package/lib/line/index.js +131 -83
  74. package/lib/line/models/arc.js +352 -237
  75. package/lib/line/models/arc_3d.js +334 -228
  76. package/lib/line/models/earthArc_3d.js +336 -228
  77. package/lib/line/models/great_circle.js +291 -200
  78. package/lib/line/models/half.js +286 -201
  79. package/lib/line/models/index.js +42 -50
  80. package/lib/line/models/line.js +428 -299
  81. package/lib/line/models/linearline.js +277 -203
  82. package/lib/line/models/simpleLine.js +239 -175
  83. package/lib/line/models/tile.js +348 -237
  84. package/lib/line/models/wall.js +327 -235
  85. package/lib/line/shaders/line_arc_vert.glsl +5 -3
  86. package/lib/line/shaders/simple/simpleline_vert.glsl +1 -0
  87. package/lib/mask/index.js +92 -59
  88. package/lib/mask/models/fill.js +134 -82
  89. package/lib/mask/models/index.js +12 -30
  90. package/lib/plugins/DataMappingPlugin.js +342 -224
  91. package/lib/plugins/DataSourcePlugin.js +102 -87
  92. package/lib/plugins/FeatureScalePlugin.js +330 -241
  93. package/lib/plugins/LayerAnimateStylePlugin.js +61 -55
  94. package/lib/plugins/LayerModelPlugin.js +80 -73
  95. package/lib/plugins/LayerStylePlugin.js +48 -51
  96. package/lib/plugins/LightingPlugin.js +80 -68
  97. package/lib/plugins/MultiPassRendererPlugin.js +91 -65
  98. package/lib/plugins/PixelPickingPlugin.js +150 -109
  99. package/lib/plugins/RegisterStyleAttributePlugin.js +110 -110
  100. package/lib/plugins/ShaderUniformPlugin.js +118 -99
  101. package/lib/plugins/UpdateModelPlugin.js +40 -47
  102. package/lib/plugins/UpdateStyleAttributePlugin.js +93 -75
  103. package/lib/point/index.js +226 -148
  104. package/lib/point/models/earthExtrude.js +279 -201
  105. package/lib/point/models/earthFill.js +287 -202
  106. package/lib/point/models/extrude.js +299 -203
  107. package/lib/point/models/fill.js +406 -273
  108. package/lib/point/models/fillmage.js +365 -252
  109. package/lib/point/models/image.js +241 -164
  110. package/lib/point/models/index.js +46 -52
  111. package/lib/point/models/normal.js +183 -134
  112. package/lib/point/models/radar.js +304 -212
  113. package/lib/point/models/simplePoint.js +194 -142
  114. package/lib/point/models/text.js +608 -385
  115. package/lib/point/models/tile.js +314 -223
  116. package/lib/point/shaders/fill_vert.glsl +13 -6
  117. package/lib/point/shaders/image/fillImage_vert.glsl +13 -5
  118. package/lib/point/shaders/image_vert.glsl +17 -8
  119. package/lib/point/shape/extrude.js +56 -52
  120. package/lib/polygon/index.js +154 -100
  121. package/lib/polygon/models/extrude.js +311 -223
  122. package/lib/polygon/models/fill.js +215 -153
  123. package/lib/polygon/models/index.js +46 -52
  124. package/lib/polygon/models/ocean.js +244 -173
  125. package/lib/polygon/models/tile.js +144 -100
  126. package/lib/polygon/models/water.js +222 -153
  127. package/lib/raster/buffers/triangulation.js +27 -40
  128. package/lib/raster/index.js +115 -74
  129. package/lib/raster/models/index.js +16 -33
  130. package/lib/raster/models/raster.js +178 -135
  131. package/lib/raster/raster.js +187 -132
  132. package/lib/tile/interface.js +4 -16
  133. package/lib/tile/manager/tileConfigManager.js +125 -86
  134. package/lib/tile/manager/tileLayerManager.js +314 -227
  135. package/lib/tile/manager/tilePickerManager.js +192 -123
  136. package/lib/tile/models/tileModel.js +71 -51
  137. package/lib/tile/tileFactory/base.js +433 -292
  138. package/lib/tile/tileFactory/index.js +51 -49
  139. package/lib/tile/tileFactory/line.js +65 -50
  140. package/lib/tile/tileFactory/point.js +65 -50
  141. package/lib/tile/tileFactory/polygon.js +65 -50
  142. package/lib/tile/tileFactory/raster.js +66 -54
  143. package/lib/tile/tileFactory/rasterData.js +88 -76
  144. package/lib/tile/tileFactory/rasterDataLayer.js +97 -62
  145. package/lib/tile/tileFactory/vectorLayer.js +169 -95
  146. package/lib/tile/tileLayer/baseTileLayer.js +420 -220
  147. package/lib/tile/tmsTileLayer.js +110 -67
  148. package/lib/tile/utils.js +113 -87
  149. package/lib/utils/blend.js +59 -79
  150. package/lib/utils/collision-index.js +107 -64
  151. package/lib/utils/dataMappingStyle.js +105 -60
  152. package/lib/utils/extrude_polyline.js +600 -398
  153. package/lib/utils/grid-index.js +163 -111
  154. package/lib/utils/layerData.js +130 -99
  155. package/lib/utils/multiPassRender.js +49 -41
  156. package/lib/utils/polylineNormal.js +148 -96
  157. package/lib/utils/simpleLine.js +100 -85
  158. package/lib/utils/symbol-layout.js +219 -116
  159. package/lib/utils/updateShape.js +15 -41
  160. package/lib/wind/index.js +109 -71
  161. package/lib/wind/models/index.js +12 -30
  162. package/lib/wind/models/utils.js +144 -105
  163. package/lib/wind/models/wind.js +333 -224
  164. package/lib/wind/models/windRender.js +329 -218
  165. package/lib/wind/models/windShader.js +23 -181
  166. package/package.json +7 -6
@@ -1,205 +1,308 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/utils/symbol-layout.ts
20
- var symbol_layout_exports = {};
21
- __export(symbol_layout_exports, {
22
- getGlyphQuads: () => getGlyphQuads,
23
- shapeText: () => shapeText
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
24
5
  });
25
- module.exports = __toCommonJS(symbol_layout_exports);
6
+ exports.getGlyphQuads = getGlyphQuads;
7
+ exports.shapeText = shapeText;
8
+
9
+ 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; } } }; }
10
+
11
+ 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); }
12
+
13
+ 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; }
14
+
15
+ /**
16
+ * 返回文本相对锚点位置
17
+ * @param {string} anchor 锚点位置
18
+ * @return {alignment} alignment
19
+ */
26
20
  function getAnchorAlignment(anchor) {
27
- let horizontalAlign = 0.5;
28
- let verticalAlign = 0.5;
21
+ var horizontalAlign = 0.5;
22
+ var verticalAlign = 0.5;
23
+
29
24
  switch (anchor) {
30
- case "right":
31
- case "top-right":
32
- case "bottom-right":
25
+ case 'right':
26
+ case 'top-right':
27
+ case 'bottom-right':
33
28
  horizontalAlign = 1;
34
29
  break;
35
- case "left":
36
- case "top-left":
37
- case "bottom-left":
30
+
31
+ case 'left':
32
+ case 'top-left':
33
+ case 'bottom-left':
38
34
  horizontalAlign = 0;
39
35
  break;
36
+
40
37
  default:
41
38
  horizontalAlign = 0.5;
42
39
  }
40
+
43
41
  switch (anchor) {
44
- case "bottom":
45
- case "bottom-right":
46
- case "bottom-left":
42
+ case 'bottom':
43
+ case 'bottom-right':
44
+ case 'bottom-left':
47
45
  verticalAlign = 1;
48
46
  break;
49
- case "top":
50
- case "top-right":
51
- case "top-left":
47
+
48
+ case 'top':
49
+ case 'top-right':
50
+ case 'top-left':
52
51
  verticalAlign = 0;
53
52
  break;
53
+
54
54
  default:
55
55
  verticalAlign = 0.5;
56
56
  }
57
- return { horizontalAlign, verticalAlign };
58
- }
57
+
58
+ return {
59
+ horizontalAlign: horizontalAlign,
60
+ verticalAlign: verticalAlign
61
+ };
62
+ } // justify right = 1, left = 0, center = 0.5
63
+
64
+
59
65
  function justifyLine(positionedGlyphs, glyphMap, start, end, justify) {
60
66
  if (!justify) {
61
67
  return;
62
68
  }
63
- const lastPositionedGlyph = positionedGlyphs[end];
64
- const glyph = lastPositionedGlyph.glyph;
69
+
70
+ var lastPositionedGlyph = positionedGlyphs[end];
71
+ var glyph = lastPositionedGlyph.glyph;
72
+
65
73
  if (glyph) {
66
- const lastAdvance = glyphMap[glyph].advance * lastPositionedGlyph.scale;
67
- const lineIndent = (positionedGlyphs[end].x + lastAdvance) * justify;
68
- for (let j = start; j <= end; j++) {
74
+ var lastAdvance = glyphMap[glyph].advance * lastPositionedGlyph.scale;
75
+ var lineIndent = (positionedGlyphs[end].x + lastAdvance) * justify;
76
+
77
+ for (var j = start; j <= end; j++) {
69
78
  positionedGlyphs[j].x -= lineIndent;
70
79
  }
71
80
  }
72
- }
81
+ } // justify right=1 left=0 center=0.5
82
+ // horizontalAlign right=1 left=0 center=0.5
83
+ // verticalAlign right=1 left=0 center=0.5
84
+
85
+
73
86
  function align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, lineCount) {
74
- const shiftX = (justify - horizontalAlign) * maxLineLength;
75
- const shiftY = (-verticalAlign * lineCount + 0.5) * lineHeight;
76
- for (const glyphs of positionedGlyphs) {
77
- glyphs.x += shiftX;
78
- glyphs.y += shiftY;
87
+ var shiftX = (justify - horizontalAlign) * maxLineLength;
88
+ var shiftY = (-verticalAlign * lineCount + 0.5) * lineHeight;
89
+
90
+ var _iterator = _createForOfIteratorHelper(positionedGlyphs),
91
+ _step;
92
+
93
+ try {
94
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
95
+ var glyphs = _step.value;
96
+ glyphs.x += shiftX;
97
+ glyphs.y += shiftY;
98
+ }
99
+ } catch (err) {
100
+ _iterator.e(err);
101
+ } finally {
102
+ _iterator.f();
79
103
  }
80
104
  }
105
+
81
106
  function shapeLines(shaping, glyphMap, lines, lineHeight, textAnchor, textJustify, spacing) {
82
- const yOffset = -8;
83
- let x = 0;
84
- let y = yOffset;
85
- let maxLineLength = 0;
86
- const positionedGlyphs = shaping.positionedGlyphs;
87
- const justify = textJustify === "right" ? 1 : textJustify === "left" ? 0 : 0.5;
88
- const lineStartIndex = positionedGlyphs.length;
89
- lines.forEach((line) => {
90
- line.split("").forEach((char) => {
91
- const glyph = glyphMap[char];
92
- const baselineOffset = 0;
107
+ // buffer 4
108
+ var yOffset = -8;
109
+ var x = 0;
110
+ var y = yOffset;
111
+ var maxLineLength = 0;
112
+ var positionedGlyphs = shaping.positionedGlyphs;
113
+ var justify = textJustify === 'right' ? 1 : textJustify === 'left' ? 0 : 0.5;
114
+ var lineStartIndex = positionedGlyphs.length;
115
+ lines.forEach(function (line) {
116
+ line.split('').forEach(function (char) {
117
+ var glyph = glyphMap[char];
118
+ var baselineOffset = 0;
119
+
93
120
  if (glyph) {
94
121
  positionedGlyphs.push({
95
122
  glyph: char,
96
- x,
123
+ x: x,
97
124
  y: y + baselineOffset,
98
125
  vertical: false,
126
+ // TODO:目前只支持水平方向
99
127
  scale: 1,
100
128
  metrics: glyph
101
129
  });
102
130
  x += glyph.advance + spacing;
103
131
  }
104
- });
132
+ }); // 左右对齐
133
+
105
134
  if (positionedGlyphs.length !== lineStartIndex) {
106
- const lineLength = x - spacing;
135
+ var lineLength = x - spacing;
107
136
  maxLineLength = Math.max(lineLength, maxLineLength);
108
137
  justifyLine(positionedGlyphs, glyphMap, lineStartIndex, positionedGlyphs.length - 1, justify);
109
138
  }
139
+
110
140
  x = 0;
111
141
  y -= lineHeight + 5;
112
142
  });
113
- const { horizontalAlign, verticalAlign } = getAnchorAlignment(textAnchor);
114
- align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, lines.length);
115
- const height = y - yOffset;
143
+
144
+ var _getAnchorAlignment = getAnchorAlignment(textAnchor),
145
+ horizontalAlign = _getAnchorAlignment.horizontalAlign,
146
+ verticalAlign = _getAnchorAlignment.verticalAlign;
147
+
148
+ align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, lines.length); // 计算包围盒
149
+
150
+ var height = y - yOffset;
116
151
  shaping.top += -verticalAlign * height;
117
152
  shaping.bottom = shaping.top - height;
118
153
  shaping.left += -horizontalAlign * maxLineLength;
119
154
  shaping.right = shaping.left + maxLineLength;
120
155
  }
156
+
121
157
  function shapeIconFont(shaping, glyphMap, iconfonts, lineHeight, textAnchor, textJustify, spacing) {
122
- const yOffset = -8;
123
- let x = 0;
124
- let y = yOffset;
125
- let maxLineLength = 0;
126
- const positionedGlyphs = shaping.positionedGlyphs;
127
- const justify = textJustify === "right" ? 1 : textJustify === "left" ? 0 : 0.5;
128
- const lineStartIndex = positionedGlyphs.length;
129
- iconfonts.forEach((iconfont) => {
130
- const glyph = glyphMap[iconfont];
131
- const baselineOffset = 0;
158
+ // buffer 4
159
+ var yOffset = -8;
160
+ var x = 0;
161
+ var y = yOffset;
162
+ var maxLineLength = 0;
163
+ var positionedGlyphs = shaping.positionedGlyphs;
164
+ var justify = textJustify === 'right' ? 1 : textJustify === 'left' ? 0 : 0.5;
165
+ var lineStartIndex = positionedGlyphs.length;
166
+ iconfonts.forEach(function (iconfont) {
167
+ var glyph = glyphMap[iconfont];
168
+ var baselineOffset = 0;
169
+
132
170
  if (glyph) {
133
171
  positionedGlyphs.push({
134
172
  glyph: iconfont,
173
+ // x,
174
+
175
+ /**
176
+ * iconfont
177
+ * 在计算大小的时候计算的是 unicode 字符 如 &#xe6d4;
178
+ * 在布局计算 icon 位置的时候应该始终保持居中(且 icon 只占一个字符的位置)
179
+ */
135
180
  x: glyph.advance / 2,
136
181
  y: y + baselineOffset,
137
182
  vertical: false,
183
+ // TODO:目前只支持水平方向
138
184
  scale: 1,
139
185
  metrics: glyph
140
186
  });
141
187
  x += glyph.advance + spacing;
142
- }
188
+ } // 左右对齐
189
+
190
+
143
191
  if (positionedGlyphs.length !== lineStartIndex) {
144
- const lineLength = x - spacing;
192
+ var lineLength = x - spacing;
145
193
  maxLineLength = Math.max(lineLength, maxLineLength);
146
194
  justifyLine(positionedGlyphs, glyphMap, lineStartIndex, positionedGlyphs.length - 1, justify);
147
195
  }
196
+
148
197
  x = 0;
149
198
  y -= lineHeight + 5;
150
199
  });
151
- const { horizontalAlign, verticalAlign } = getAnchorAlignment(textAnchor);
152
- align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, iconfonts.length);
153
- const height = y - yOffset;
200
+
201
+ var _getAnchorAlignment2 = getAnchorAlignment(textAnchor),
202
+ horizontalAlign = _getAnchorAlignment2.horizontalAlign,
203
+ verticalAlign = _getAnchorAlignment2.verticalAlign;
204
+
205
+ align(positionedGlyphs, justify, horizontalAlign, verticalAlign, maxLineLength, lineHeight, iconfonts.length); // 计算包围盒
206
+
207
+ var height = y - yOffset;
154
208
  shaping.top += -verticalAlign * height;
155
209
  shaping.bottom = shaping.top - height;
156
210
  shaping.left += -horizontalAlign * maxLineLength;
157
211
  shaping.right = shaping.left + maxLineLength;
158
212
  }
159
- function shapeText(text, glyphs, lineHeight, textAnchor, textJustify, spacing, translate = [0, 0], isIconFont) {
160
- const lines = text.split("\n");
161
- const positionedGlyphs = [];
162
- const shaping = {
163
- positionedGlyphs,
213
+ /**
214
+ * 计算文本中每个独立字符相对锚点的位置
215
+ *
216
+ * @param {string} text 原始文本
217
+ * @param {*} glyphs mapping
218
+ * @param {number} lineHeight 行高
219
+ * @param {string} textAnchor 文本相对于锚点的位置
220
+ * @param {string} textJustify 左右对齐
221
+ * @param {number} spacing 字符间距
222
+ * @param {[number, number]} translate 文本水平 & 垂直偏移量
223
+ * @param {[boolean]} isIconFont 是否是 iconfont
224
+ * @return {boolean|shaping} 每个字符相对于锚点的位置
225
+ */
226
+
227
+
228
+ function shapeText(text, glyphs, lineHeight, textAnchor, textJustify, spacing) {
229
+ var translate = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : [0, 0];
230
+ var isIconFont = arguments.length > 7 ? arguments[7] : undefined;
231
+ // TODO:处理换行
232
+ var lines = text.split('\n');
233
+ var positionedGlyphs = [];
234
+ var shaping = {
235
+ positionedGlyphs: positionedGlyphs,
164
236
  top: translate[1],
165
237
  bottom: translate[1],
166
238
  left: translate[0],
167
239
  right: translate[0],
168
240
  lineCount: lines.length,
169
- text
241
+ text: text
170
242
  };
171
243
  isIconFont ? shapeIconFont(shaping, glyphs, lines, lineHeight, textAnchor, textJustify, spacing) : shapeLines(shaping, glyphs, lines, lineHeight, textAnchor, textJustify, spacing);
244
+
172
245
  if (!positionedGlyphs.length) {
173
246
  return false;
174
247
  }
248
+
175
249
  return shaping;
176
250
  }
177
- function getGlyphQuads(shaping, textOffset = [0, 0], alongLine) {
178
- const { positionedGlyphs = [] } = shaping;
179
- const quads = [];
180
- for (const positionedGlyph of positionedGlyphs) {
181
- const rect = positionedGlyph.metrics;
182
- const rectBuffer = 4;
183
- const halfAdvance = rect.advance * positionedGlyph.scale / 2;
184
- const glyphOffset = alongLine ? [positionedGlyph.x + halfAdvance, positionedGlyph.y] : [0, 0];
185
- const builtInOffset = alongLine ? [0, 0] : [
186
- positionedGlyph.x + halfAdvance + textOffset[0],
187
- positionedGlyph.y + textOffset[1]
188
- ];
189
- const x1 = (0 - rectBuffer) * positionedGlyph.scale - halfAdvance + builtInOffset[0];
190
- const y1 = (0 - rectBuffer) * positionedGlyph.scale + builtInOffset[1];
191
- const x2 = x1 + rect.width * positionedGlyph.scale;
192
- const y2 = y1 + rect.height * positionedGlyph.scale;
193
- const tl = { x: x1, y: y1 };
194
- const tr = { x: x2, y: y1 };
195
- const bl = { x: x1, y: y2 };
196
- const br = { x: x2, y: y2 };
197
- quads.push({ tl, tr, bl, br, tex: rect, glyphOffset });
251
+
252
+ function getGlyphQuads(shaping) {
253
+ var textOffset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [0, 0];
254
+ var alongLine = arguments.length > 2 ? arguments[2] : undefined;
255
+ var _shaping$positionedGl = shaping.positionedGlyphs,
256
+ positionedGlyphs = _shaping$positionedGl === void 0 ? [] : _shaping$positionedGl;
257
+ var quads = [];
258
+
259
+ var _iterator2 = _createForOfIteratorHelper(positionedGlyphs),
260
+ _step2;
261
+
262
+ try {
263
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
264
+ var positionedGlyph = _step2.value;
265
+ var rect = positionedGlyph.metrics; // The rects have an addditional buffer that is not included in their size.
266
+
267
+ var rectBuffer = 4;
268
+ var halfAdvance = rect.advance * positionedGlyph.scale / 2;
269
+ var glyphOffset = alongLine ? [positionedGlyph.x + halfAdvance, positionedGlyph.y] : [0, 0];
270
+ var builtInOffset = alongLine ? [0, 0] : [positionedGlyph.x + halfAdvance + textOffset[0], positionedGlyph.y + textOffset[1]];
271
+ var x1 = (0 - rectBuffer) * positionedGlyph.scale - halfAdvance + builtInOffset[0];
272
+ var y1 = (0 - rectBuffer) * positionedGlyph.scale + builtInOffset[1];
273
+ var x2 = x1 + rect.width * positionedGlyph.scale;
274
+ var y2 = y1 + rect.height * positionedGlyph.scale;
275
+ var tl = {
276
+ x: x1,
277
+ y: y1
278
+ };
279
+ var tr = {
280
+ x: x2,
281
+ y: y1
282
+ };
283
+ var bl = {
284
+ x: x1,
285
+ y: y2
286
+ };
287
+ var br = {
288
+ x: x2,
289
+ y: y2
290
+ }; // TODO:处理字符旋转的情况
291
+
292
+ quads.push({
293
+ tl: tl,
294
+ tr: tr,
295
+ bl: bl,
296
+ br: br,
297
+ tex: rect,
298
+ glyphOffset: glyphOffset
299
+ });
300
+ }
301
+ } catch (err) {
302
+ _iterator2.e(err);
303
+ } finally {
304
+ _iterator2.f();
198
305
  }
306
+
199
307
  return quads;
200
- }
201
- // Annotate the CommonJS export names for ESM import in node:
202
- 0 && (module.exports = {
203
- getGlyphQuads,
204
- shapeText
205
- });
308
+ }
@@ -1,53 +1,27 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";
18
2
 
19
- // src/utils/updateShape.ts
20
- var updateShape_exports = {};
21
- __export(updateShape_exports, {
22
- updateShape: () => updateShape
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
23
5
  });
24
- module.exports = __toCommonJS(updateShape_exports);
25
- var shapeUpdateList = [
26
- ["circle", "cylinder"],
27
- ["square", "cylinder"],
28
- ["triangle", "cylinder"],
29
- ["pentagon", "cylinder"],
30
- ["hexagon", "cylinder"],
31
- ["octogon", "cylinder"],
32
- ["hexagram", "cylinder"],
33
- ["rhombus", "cylinder"],
34
- ["vesica", "cylinder"]
35
- ];
6
+ exports.updateShape = updateShape;
7
+ // TODO: shapeUpdateList 存储一系列的 shape 类型
8
+ // 当这一系列的 shape 相互切换的时候需要重构 layer 的 model (顶点数据集)
9
+ var shapeUpdateList = [// PointLayer
10
+ ['circle', 'cylinder'], ['square', 'cylinder'], ['triangle', 'cylinder'], ['pentagon', 'cylinder'], ['hexagon', 'cylinder'], ['octogon', 'cylinder'], ['hexagram', 'cylinder'], ['rhombus', 'cylinder'], ['vesica', 'cylinder']];
11
+
36
12
  function updateShape(layer, lastShape, currentShape) {
37
- if (typeof lastShape === "string" && typeof currentShape === "string" && lastShape !== currentShape) {
38
- if (layer.type === "PointLayer") {
13
+ if (typeof lastShape === 'string' && typeof currentShape === 'string' && lastShape !== currentShape) {
14
+ if (layer.type === 'PointLayer') {
39
15
  layer.dataState.dataSourceNeedUpdate = true;
40
16
  return;
41
17
  }
42
- shapeUpdateList.map((shapes) => {
18
+
19
+ shapeUpdateList.map(function (shapes) {
43
20
  if (shapes.includes(lastShape) && shapes.includes(currentShape)) {
21
+ // TODO: dataSourceNeedUpdate 借用数据更新时更新 layer model 的工作流
44
22
  layer.dataState.dataSourceNeedUpdate = true;
45
23
  return;
46
24
  }
47
25
  });
48
26
  }
49
- }
50
- // Annotate the CommonJS export names for ESM import in node:
51
- 0 && (module.exports = {
52
- updateShape
53
- });
27
+ }