@antv/g-webgpu 1.6.4 → 1.7.2

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.
package/dist/index.umd.js CHANGED
@@ -1952,6 +1952,10 @@
1952
1952
  callback();
1953
1953
  }
1954
1954
  });
1955
+ } else {
1956
+ if (callback) {
1957
+ callback();
1958
+ }
1955
1959
  }
1956
1960
 
1957
1961
  return this.imageCache[src];
@@ -10106,9 +10110,10 @@
10106
10110
  _proto.shouldMerge = function shouldMerge(object, index) {
10107
10111
  if (!this.instance) {
10108
10112
  return true;
10109
- }
10113
+ } // Path / Polyline could be rendered as Line
10110
10114
 
10111
- if (this.instance.nodeName !== object.nodeName) {
10115
+
10116
+ if (this.instance.nodeName !== object.nodeName && this.instance.nodeName !== object.renderable.proxyNodeName && this.instance.renderable.proxyNodeName !== object.nodeName && this.instance.renderable.proxyNodeName !== object.renderable.proxyNodeName) {
10112
10117
  return false;
10113
10118
  } // can't be merged when using clipPath
10114
10119
 
@@ -11129,20 +11134,123 @@
11129
11134
  var indices = [];
11130
11135
  var offset = 0;
11131
11136
  objects.forEach(function (object) {
11132
- var line = object;
11133
- var _line$parsedStyle = line.parsedStyle,
11134
- x1 = _line$parsedStyle.x1,
11135
- y1 = _line$parsedStyle.y1,
11136
- x2 = _line$parsedStyle.x2,
11137
- y2 = _line$parsedStyle.y2,
11138
- z1 = _line$parsedStyle.z1,
11139
- z2 = _line$parsedStyle.z2,
11140
- defX = _line$parsedStyle.defX,
11141
- defY = _line$parsedStyle.defY,
11142
- lineCap = _line$parsedStyle.lineCap,
11143
- isBillboard = _line$parsedStyle.isBillboard;
11144
-
11145
- var _this$calcDash = _this.calcDash(object),
11137
+ var parsedLineStyleProps;
11138
+ var totalLength;
11139
+
11140
+ if (object.nodeName === g.Shape.LINE) {
11141
+ parsedLineStyleProps = object.parsedStyle;
11142
+ totalLength = object.getTotalLength();
11143
+ } else if (object.nodeName === g.Shape.POLYLINE) {
11144
+ var _object$parsedStyle = object.parsedStyle,
11145
+ points = _object$parsedStyle.points.points,
11146
+ _defX = _object$parsedStyle.defX,
11147
+ _defY = _object$parsedStyle.defY,
11148
+ _lineCap = _object$parsedStyle.lineCap,
11149
+ markerStart = _object$parsedStyle.markerStart,
11150
+ markerEnd = _object$parsedStyle.markerEnd,
11151
+ markerStartOffset = _object$parsedStyle.markerStartOffset,
11152
+ markerEndOffset = _object$parsedStyle.markerEndOffset;
11153
+ parsedLineStyleProps = {
11154
+ // @ts-ignore
11155
+ x1: {
11156
+ value: points[0][0]
11157
+ },
11158
+ // @ts-ignore
11159
+ y1: {
11160
+ value: points[0][1]
11161
+ },
11162
+ // @ts-ignore
11163
+ x2: {
11164
+ value: points[points.length - 1][0]
11165
+ },
11166
+ // @ts-ignore
11167
+ y2: {
11168
+ value: points[points.length - 1][1]
11169
+ },
11170
+ // @ts-ignore
11171
+ z1: {
11172
+ value: 0
11173
+ },
11174
+ // @ts-ignore
11175
+ z2: {
11176
+ value: 0
11177
+ },
11178
+ defX: _defX,
11179
+ defY: _defY,
11180
+ lineCap: _lineCap,
11181
+ isBillboard: true,
11182
+ markerStart: markerStart,
11183
+ markerEnd: markerEnd,
11184
+ markerStartOffset: markerStartOffset,
11185
+ markerEndOffset: markerEndOffset
11186
+ };
11187
+ totalLength = object.getTotalLength();
11188
+ } else if (object.nodeName === g.Shape.PATH) {
11189
+ var _object$parsedStyle2 = object.parsedStyle,
11190
+ curve = _object$parsedStyle2.path.curve,
11191
+ _defX2 = _object$parsedStyle2.defX,
11192
+ _defY2 = _object$parsedStyle2.defY,
11193
+ _lineCap2 = _object$parsedStyle2.lineCap,
11194
+ _markerStart = _object$parsedStyle2.markerStart,
11195
+ _markerEnd = _object$parsedStyle2.markerEnd,
11196
+ _markerStartOffset = _object$parsedStyle2.markerStartOffset,
11197
+ _markerEndOffset = _object$parsedStyle2.markerEndOffset;
11198
+ parsedLineStyleProps = {
11199
+ // @ts-ignore
11200
+ x1: {
11201
+ value: curve[0][1]
11202
+ },
11203
+ // @ts-ignore
11204
+ y1: {
11205
+ value: curve[0][2]
11206
+ },
11207
+ // @ts-ignore
11208
+ x2: {
11209
+ value: curve[1][5]
11210
+ },
11211
+ // @ts-ignore
11212
+ y2: {
11213
+ value: curve[1][6]
11214
+ },
11215
+ // @ts-ignore
11216
+ z1: {
11217
+ value: 0
11218
+ },
11219
+ // @ts-ignore
11220
+ z2: {
11221
+ value: 0
11222
+ },
11223
+ defX: _defX2,
11224
+ defY: _defY2,
11225
+ lineCap: _lineCap2,
11226
+ isBillboard: true,
11227
+ markerStart: _markerStart,
11228
+ markerEnd: _markerEnd,
11229
+ markerStartOffset: _markerStartOffset,
11230
+ markerEndOffset: _markerEndOffset
11231
+ };
11232
+ totalLength = object.getTotalLength();
11233
+ }
11234
+
11235
+ var _parsedLineStyleProps = parsedLineStyleProps,
11236
+ x1 = _parsedLineStyleProps.x1,
11237
+ y1 = _parsedLineStyleProps.y1,
11238
+ x2 = _parsedLineStyleProps.x2,
11239
+ y2 = _parsedLineStyleProps.y2,
11240
+ z1 = _parsedLineStyleProps.z1,
11241
+ z2 = _parsedLineStyleProps.z2,
11242
+ defX = _parsedLineStyleProps.defX,
11243
+ defY = _parsedLineStyleProps.defY,
11244
+ lineCap = _parsedLineStyleProps.lineCap,
11245
+ isBillboard = _parsedLineStyleProps.isBillboard;
11246
+
11247
+ var _this$calcOffset = _this.calcOffset(parsedLineStyleProps),
11248
+ startOffsetX = _this$calcOffset.startOffsetX,
11249
+ startOffsetY = _this$calcOffset.startOffsetY,
11250
+ endOffsetX = _this$calcOffset.endOffsetX,
11251
+ endOffsetY = _this$calcOffset.endOffsetY;
11252
+
11253
+ var _this$calcDash = _this.calcDash(parsedLineStyleProps, totalLength),
11146
11254
  dashOffset = _this$calcDash.dashOffset,
11147
11255
  dashSegmentPercent = _this$calcDash.dashSegmentPercent,
11148
11256
  dashRatioInEachSegment = _this$calcDash.dashRatioInEachSegment;
@@ -11151,7 +11259,7 @@
11151
11259
  LineCap_MAP[lineCap.value]);
11152
11260
  packedDash.push(dashOffset, dashSegmentPercent, dashRatioInEachSegment, // isBillboard
11153
11261
  isBillboard ? 1 : 0);
11154
- interleaved.push(x1.value - defX, y1.value - defY, z1.value, x2.value - defX, y2.value - defY, z2.value);
11262
+ interleaved.push(x1.value - defX + startOffsetX, y1.value - defY + startOffsetY, z1.value, x2.value - defX + endOffsetX, y2.value - defY + endOffsetY, z2.value);
11155
11263
  indices.push(0 + offset, 2 + offset, 1 + offset, 0 + offset, 3 + offset, 2 + offset);
11156
11264
  offset += 4;
11157
11265
  });
@@ -11224,25 +11332,128 @@
11224
11332
 
11225
11333
  this.updateBatchedAttribute(objects, startIndex, name, value);
11226
11334
 
11227
- if (name === 'x1' || name === 'y1' || name === 'x2' || name === 'y2' || name === 'z1' || name === 'z2') {
11335
+ if (name === 'x1' || name === 'y1' || name === 'x2' || name === 'y2' || name === 'z1' || name === 'z2' || name === 'markerStartOffset' || name === 'markerEndOffset' || name === 'markerStart' || name === 'markerEnd' || name === 'points' || name === 'path') {
11228
11336
  var packed = [];
11229
11337
  objects.forEach(function (object) {
11230
- var _object$parsedStyle = object.parsedStyle,
11231
- x1 = _object$parsedStyle.x1,
11232
- y1 = _object$parsedStyle.y1,
11233
- x2 = _object$parsedStyle.x2,
11234
- y2 = _object$parsedStyle.y2,
11235
- z1 = _object$parsedStyle.z1,
11236
- z2 = _object$parsedStyle.z2,
11237
- defX = _object$parsedStyle.defX,
11238
- defY = _object$parsedStyle.defY;
11239
- packed.push(x1.value - defX, y1.value - defY, z1.value, x2.value - defX, y2.value - defY, z2.value);
11338
+ var parsedLineStyleProps;
11339
+
11340
+ if (object.nodeName === g.Shape.LINE) {
11341
+ parsedLineStyleProps = object.parsedStyle;
11342
+ } else if (object.nodeName === g.Shape.POLYLINE && object.renderable.proxyNodeName === g.Shape.LINE) {
11343
+ var _object$parsedStyle3 = object.parsedStyle,
11344
+ points = _object$parsedStyle3.points.points,
11345
+ _defX3 = _object$parsedStyle3.defX,
11346
+ _defY3 = _object$parsedStyle3.defY,
11347
+ lineCap = _object$parsedStyle3.lineCap,
11348
+ markerStart = _object$parsedStyle3.markerStart,
11349
+ markerEnd = _object$parsedStyle3.markerEnd,
11350
+ markerStartOffset = _object$parsedStyle3.markerStartOffset,
11351
+ markerEndOffset = _object$parsedStyle3.markerEndOffset;
11352
+ parsedLineStyleProps = {
11353
+ // @ts-ignore
11354
+ x1: {
11355
+ value: points[0][0]
11356
+ },
11357
+ // @ts-ignore
11358
+ y1: {
11359
+ value: points[0][1]
11360
+ },
11361
+ // @ts-ignore
11362
+ x2: {
11363
+ value: points[points.length - 1][0]
11364
+ },
11365
+ // @ts-ignore
11366
+ y2: {
11367
+ value: points[points.length - 1][1]
11368
+ },
11369
+ // @ts-ignore
11370
+ z1: {
11371
+ value: 0
11372
+ },
11373
+ // @ts-ignore
11374
+ z2: {
11375
+ value: 0
11376
+ },
11377
+ defX: _defX3,
11378
+ defY: _defY3,
11379
+ lineCap: lineCap,
11380
+ isBillboard: true,
11381
+ markerStart: markerStart,
11382
+ markerEnd: markerEnd,
11383
+ markerStartOffset: markerStartOffset,
11384
+ markerEndOffset: markerEndOffset
11385
+ };
11386
+ } else if (object.nodeName === g.Shape.PATH && object.renderable.proxyNodeName === g.Shape.LINE) {
11387
+ var _object$parsedStyle4 = object.parsedStyle,
11388
+ curve = _object$parsedStyle4.path.curve,
11389
+ _defX4 = _object$parsedStyle4.defX,
11390
+ _defY4 = _object$parsedStyle4.defY,
11391
+ _lineCap3 = _object$parsedStyle4.lineCap,
11392
+ _markerStart2 = _object$parsedStyle4.markerStart,
11393
+ _markerEnd2 = _object$parsedStyle4.markerEnd,
11394
+ _markerStartOffset2 = _object$parsedStyle4.markerStartOffset,
11395
+ _markerEndOffset2 = _object$parsedStyle4.markerEndOffset;
11396
+ parsedLineStyleProps = {
11397
+ // @ts-ignore
11398
+ x1: {
11399
+ value: curve[0][1]
11400
+ },
11401
+ // @ts-ignore
11402
+ y1: {
11403
+ value: curve[0][2]
11404
+ },
11405
+ // @ts-ignore
11406
+ x2: {
11407
+ value: curve[1][5]
11408
+ },
11409
+ // @ts-ignore
11410
+ y2: {
11411
+ value: curve[1][6]
11412
+ },
11413
+ // @ts-ignore
11414
+ z1: {
11415
+ value: 0
11416
+ },
11417
+ // @ts-ignore
11418
+ z2: {
11419
+ value: 0
11420
+ },
11421
+ defX: _defX4,
11422
+ defY: _defY4,
11423
+ lineCap: _lineCap3,
11424
+ isBillboard: true,
11425
+ markerStart: _markerStart2,
11426
+ markerEnd: _markerEnd2,
11427
+ markerStartOffset: _markerStartOffset2,
11428
+ markerEndOffset: _markerEndOffset2
11429
+ };
11430
+ }
11431
+
11432
+ var _parsedLineStyleProps2 = parsedLineStyleProps,
11433
+ x1 = _parsedLineStyleProps2.x1,
11434
+ y1 = _parsedLineStyleProps2.y1,
11435
+ x2 = _parsedLineStyleProps2.x2,
11436
+ y2 = _parsedLineStyleProps2.y2,
11437
+ z1 = _parsedLineStyleProps2.z1,
11438
+ z2 = _parsedLineStyleProps2.z2,
11439
+ defX = _parsedLineStyleProps2.defX,
11440
+ defY = _parsedLineStyleProps2.defY;
11441
+
11442
+ var _this2$calcOffset = _this2.calcOffset(parsedLineStyleProps),
11443
+ startOffsetX = _this2$calcOffset.startOffsetX,
11444
+ startOffsetY = _this2$calcOffset.startOffsetY,
11445
+ endOffsetX = _this2$calcOffset.endOffsetX,
11446
+ endOffsetY = _this2$calcOffset.endOffsetY;
11447
+
11448
+ packed.push(x1.value - defX + startOffsetX, y1.value - defY + startOffsetY, z1.value, x2.value - defX + endOffsetX, y2.value - defY + endOffsetY, z2.value);
11240
11449
  });
11241
11450
  this.geometry.updateVertexBuffer(InstancedLineVertexAttributeBufferIndex.POINT, InstancedLineVertexAttributeLocation.POINTA, startIndex, new Uint8Array(new Float32Array(packed).buffer));
11242
11451
  } else if (name === 'lineDashOffset' || name === 'lineDash') {
11243
11452
  var _packed = [];
11244
11453
  objects.forEach(function (object) {
11245
- var _this2$calcDash = _this2.calcDash(object),
11454
+ var totalLength = object.getTotalLength();
11455
+
11456
+ var _this2$calcDash = _this2.calcDash(object.parsedStyle, totalLength),
11246
11457
  dashOffset = _this2$calcDash.dashOffset,
11247
11458
  dashSegmentPercent = _this2$calcDash.dashSegmentPercent,
11248
11459
  dashRatioInEachSegment = _this2$calcDash.dashRatioInEachSegment;
@@ -11262,11 +11473,50 @@
11262
11473
  }
11263
11474
  };
11264
11475
 
11265
- _proto.calcDash = function calcDash(line) {
11266
- var _line$parsedStyle2 = line.parsedStyle,
11267
- lineDash = _line$parsedStyle2.lineDash,
11268
- lineDashOffset = _line$parsedStyle2.lineDashOffset;
11269
- var totalLength = line.getTotalLength();
11476
+ _proto.calcOffset = function calcOffset(parsedStyle) {
11477
+ var x1 = parsedStyle.x1,
11478
+ y1 = parsedStyle.y1,
11479
+ x2 = parsedStyle.x2,
11480
+ y2 = parsedStyle.y2,
11481
+ markerStart = parsedStyle.markerStart,
11482
+ markerEnd = parsedStyle.markerEnd,
11483
+ markerStartOffset = parsedStyle.markerStartOffset,
11484
+ markerEndOffset = parsedStyle.markerEndOffset;
11485
+ var startOffsetX = 0;
11486
+ var startOffsetY = 0;
11487
+ var endOffsetX = 0;
11488
+ var endOffsetY = 0;
11489
+ var rad = 0;
11490
+ var x;
11491
+ var y;
11492
+
11493
+ if (markerStart && markerStart instanceof g.DisplayObject && markerStartOffset) {
11494
+ x = x2.value - x1.value;
11495
+ y = y2.value - y1.value;
11496
+ rad = Math.atan2(y, x);
11497
+ startOffsetX = Math.cos(rad) * ((markerStartOffset === null || markerStartOffset === void 0 ? void 0 : markerStartOffset.value) || 0);
11498
+ startOffsetY = Math.sin(rad) * ((markerStartOffset === null || markerStartOffset === void 0 ? void 0 : markerStartOffset.value) || 0);
11499
+ }
11500
+
11501
+ if (markerEnd && markerEnd instanceof g.DisplayObject && markerEndOffset) {
11502
+ x = x1.value - x2.value;
11503
+ y = y1.value - y2.value;
11504
+ rad = Math.atan2(y, x);
11505
+ endOffsetX = Math.cos(rad) * ((markerEndOffset === null || markerEndOffset === void 0 ? void 0 : markerEndOffset.value) || 0);
11506
+ endOffsetY = Math.sin(rad) * ((markerEndOffset === null || markerEndOffset === void 0 ? void 0 : markerEndOffset.value) || 0);
11507
+ }
11508
+
11509
+ return {
11510
+ startOffsetX: startOffsetX,
11511
+ startOffsetY: startOffsetY,
11512
+ endOffsetX: endOffsetX,
11513
+ endOffsetY: endOffsetY
11514
+ };
11515
+ };
11516
+
11517
+ _proto.calcDash = function calcDash(parsedLineStyle, totalLength) {
11518
+ var lineDash = parsedLineStyle.lineDash,
11519
+ lineDashOffset = parsedLineStyle.lineDashOffset;
11270
11520
  var dashOffset = 0;
11271
11521
  var dashSegmentPercent = 1;
11272
11522
  var dashRatioInEachSegment = 0;
@@ -11760,7 +12010,7 @@
11760
12010
  lineDashOffset = _object$parsedStyle.lineDashOffset,
11761
12011
  visibility = _object$parsedStyle.visibility;
11762
12012
 
11763
- if (name === 'lineJoin' || name === 'lineCap' || object.nodeName === g.Shape.CIRCLE && name === 'r' || object.nodeName === g.Shape.ELLIPSE && (name === 'rx' || name === 'ry') || object.nodeName === g.Shape.RECT && (name === 'width' || name === 'height' || name === 'radius') || object.nodeName === g.Shape.LINE && (name === 'x1' || name === 'y1' || name === 'x2' || name === 'y2') || object.nodeName === g.Shape.POLYLINE && name === 'points' || object.nodeName === g.Shape.POLYGON && name === 'points' || object.nodeName === g.Shape.PATH && name === 'path') {
12013
+ if (name === 'lineJoin' || name === 'lineCap' || name === 'markerStart' || name === 'markerEnd' || name === 'markerStartOffset' || name === 'markerEndOffset' || object.nodeName === g.Shape.CIRCLE && name === 'r' || object.nodeName === g.Shape.ELLIPSE && (name === 'rx' || name === 'ry') || object.nodeName === g.Shape.RECT && (name === 'width' || name === 'height' || name === 'radius') || object.nodeName === g.Shape.LINE && (name === 'x1' || name === 'y1' || name === 'x2' || name === 'y2') || object.nodeName === g.Shape.POLYLINE && name === 'points' || object.nodeName === g.Shape.POLYGON && name === 'points' || object.nodeName === g.Shape.PATH && name === 'path') {
11764
12014
  // need re-calc geometry
11765
12015
  _this.material.geometryDirty = true;
11766
12016
  _this.material.programDirty = true;
@@ -12029,12 +12279,54 @@
12029
12279
  var _object$parsedStyle3 = object.parsedStyle,
12030
12280
  defX = _object$parsedStyle3.defX,
12031
12281
  defY = _object$parsedStyle3.defY;
12282
+ var _object$parsedStyle4 = object.parsedStyle,
12283
+ markerStart = _object$parsedStyle4.markerStart,
12284
+ markerEnd = _object$parsedStyle4.markerEnd,
12285
+ markerStartOffset = _object$parsedStyle4.markerStartOffset,
12286
+ markerEndOffset = _object$parsedStyle4.markerEndOffset;
12032
12287
  var points = [];
12033
12288
  var triangles = [];
12034
12289
 
12035
12290
  if (object.nodeName === g.Shape.POLYLINE || object.nodeName === g.Shape.POLYGON) {
12036
- points[0] = object.parsedStyle.points.points.reduce(function (prev, cur) {
12037
- prev.push(cur[0] - defX, cur[1] - defY);
12291
+ var polylinePoints = object.parsedStyle.points.points;
12292
+ var length = polylinePoints.length;
12293
+ var startOffsetX = 0;
12294
+ var startOffsetY = 0;
12295
+ var endOffsetX = 0;
12296
+ var endOffsetY = 0;
12297
+ var rad = 0;
12298
+ var x;
12299
+ var y;
12300
+
12301
+ if (markerStart && markerStart instanceof g.DisplayObject && markerStartOffset) {
12302
+ x = polylinePoints[1][0] - polylinePoints[0][0];
12303
+ y = polylinePoints[1][1] - polylinePoints[0][1];
12304
+ rad = Math.atan2(y, x);
12305
+ startOffsetX = Math.cos(rad) * ((markerStartOffset === null || markerStartOffset === void 0 ? void 0 : markerStartOffset.value) || 0);
12306
+ startOffsetY = Math.sin(rad) * ((markerStartOffset === null || markerStartOffset === void 0 ? void 0 : markerStartOffset.value) || 0);
12307
+ }
12308
+
12309
+ if (markerEnd && markerEnd instanceof g.DisplayObject && markerEndOffset) {
12310
+ x = polylinePoints[length - 2][0] - polylinePoints[length - 1][0];
12311
+ y = polylinePoints[length - 2][1] - polylinePoints[length - 1][1];
12312
+ rad = Math.atan2(y, x);
12313
+ endOffsetX = Math.cos(rad) * ((markerEndOffset === null || markerEndOffset === void 0 ? void 0 : markerEndOffset.value) || 0);
12314
+ endOffsetY = Math.sin(rad) * ((markerEndOffset === null || markerEndOffset === void 0 ? void 0 : markerEndOffset.value) || 0);
12315
+ }
12316
+
12317
+ points[0] = polylinePoints.reduce(function (prev, cur, i) {
12318
+ var offsetX = 0;
12319
+ var offsetY = 0;
12320
+
12321
+ if (i === 0) {
12322
+ offsetX = startOffsetX;
12323
+ offsetY = startOffsetY;
12324
+ } else if (i === length - 1) {
12325
+ offsetX = endOffsetX;
12326
+ offsetY = endOffsetY;
12327
+ }
12328
+
12329
+ prev.push(cur[0] - defX + offsetX, cur[1] - defY + offsetY);
12038
12330
  return prev;
12039
12331
  }, []); // close polygon, dealing with extra joint
12040
12332
 
@@ -12065,9 +12357,9 @@
12065
12357
  defY = path.rect.y; // support negative width/height of Rect
12066
12358
 
12067
12359
  if (object.nodeName === g.Shape.RECT) {
12068
- var _object$parsedStyle4 = object.parsedStyle,
12069
- width = _object$parsedStyle4.width,
12070
- height = _object$parsedStyle4.height;
12360
+ var _object$parsedStyle5 = object.parsedStyle,
12361
+ width = _object$parsedStyle5.width,
12362
+ height = _object$parsedStyle5.height;
12071
12363
 
12072
12364
  if (width.value < 0) {
12073
12365
  defX += path.rect.width;
@@ -12085,10 +12377,46 @@
12085
12377
  zCommandIndexes = _path.zCommandIndexes;
12086
12378
  var curve = [].concat(path.curve).map(function (c, i) {
12087
12379
  return zCommandIndexes.includes(i) ? ['Z'] : c;
12088
- });
12380
+ }); // @ts-ignore
12381
+
12382
+ var isClosed = curve[curve.length - 1][0] === 'Z';
12383
+ var _startOffsetX = 0;
12384
+ var _startOffsetY = 0;
12385
+ var _endOffsetX = 0;
12386
+ var _endOffsetY = 0;
12387
+ var _rad = 0;
12388
+
12389
+ var _x;
12390
+
12391
+ var _y;
12392
+
12393
+ if (markerStart && markerStart instanceof g.DisplayObject && markerStartOffset) {
12394
+ var _markerStart$parentNo = markerStart.parentNode.getStartTangent(),
12395
+ p1 = _markerStart$parentNo[0],
12396
+ p2 = _markerStart$parentNo[1];
12397
+
12398
+ _x = p1[0] - p2[0];
12399
+ _y = p1[1] - p2[1];
12400
+ _rad = Math.atan2(_y, _x);
12401
+ _startOffsetX = Math.cos(_rad) * ((markerStartOffset === null || markerStartOffset === void 0 ? void 0 : markerStartOffset.value) || 0);
12402
+ _startOffsetY = Math.sin(_rad) * ((markerStartOffset === null || markerStartOffset === void 0 ? void 0 : markerStartOffset.value) || 0);
12403
+ }
12404
+
12405
+ if (markerEnd && markerEnd instanceof g.DisplayObject && markerEndOffset) {
12406
+ var _markerEnd$parentNode = markerEnd.parentNode.getEndTangent(),
12407
+ _p = _markerEnd$parentNode[0],
12408
+ _p2 = _markerEnd$parentNode[1];
12409
+
12410
+ _x = _p[0] - _p2[0];
12411
+ _y = _p[1] - _p2[1];
12412
+ _rad = Math.atan2(_y, _x);
12413
+ _endOffsetX = Math.cos(_rad) * ((markerEndOffset === null || markerEndOffset === void 0 ? void 0 : markerEndOffset.value) || 0);
12414
+ _endOffsetY = Math.sin(_rad) * ((markerEndOffset === null || markerEndOffset === void 0 ? void 0 : markerEndOffset.value) || 0);
12415
+ }
12416
+
12089
12417
  var startPointIndex = -1;
12090
12418
  var mCommandsNum = -1;
12091
- curve.forEach(function (_ref) {
12419
+ curve.forEach(function (_ref, i) {
12092
12420
  var command = _ref[0],
12093
12421
  params = _ref.slice(1);
12094
12422
 
@@ -12096,9 +12424,12 @@
12096
12424
  mCommandsNum++;
12097
12425
  points[mCommandsNum] = [];
12098
12426
  startPointIndex = points[mCommandsNum].length;
12099
- points[mCommandsNum].push(params[0] - defX, params[1] - defY);
12427
+ points[mCommandsNum].push(params[0] - defX + _startOffsetX, params[1] - defY + _startOffsetY);
12100
12428
  } else if (command === 'C') {
12101
- curveTo(params[0] - defX, params[1] - defY, params[2] - defX, params[3] - defY, params[4] - defX, params[5] - defY, points[mCommandsNum]);
12429
+ // the last C command
12430
+ var offsetX = i === curve.length - (isClosed ? 2 : 1) ? _endOffsetX : 0;
12431
+ var offsetY = i === curve.length - (isClosed ? 2 : 1) ? _endOffsetY : 0;
12432
+ curveTo(params[0] - defX, params[1] - defY, params[2] - defX, params[3] - defY, params[4] - defX + offsetX, params[5] - defY + offsetY, points[mCommandsNum]);
12102
12433
  } else if (command === 'Z' && (object.nodeName === g.Shape.PATH || object.nodeName === g.Shape.RECT)) {
12103
12434
  var _points$mCommandsNum;
12104
12435
 
@@ -12372,7 +12703,7 @@
12372
12703
  anchor = _object$parsedStyle.anchor,
12373
12704
  visibility = _object$parsedStyle.visibility;
12374
12705
 
12375
- if (name === 'lineJoin' || name === 'lineCap' || object.nodeName === g.Shape.RECT && (name === 'width' || name === 'height' || name === 'radius') || object.nodeName === g.Shape.LINE && (name === 'x1' || name === 'y1' || name === 'x2' || name === 'y2') || object.nodeName === g.Shape.POLYLINE && name === 'points' || object.nodeName === g.Shape.POLYGON && name === 'points' || object.nodeName === g.Shape.PATH && name === 'path') {
12706
+ if (name === 'lineJoin' || name === 'lineCap' || name === 'markerStart' || name === 'markerEnd' || name === 'markerStartOffset' || name === 'markerEndOffset' || object.nodeName === g.Shape.RECT && (name === 'width' || name === 'height' || name === 'radius') || object.nodeName === g.Shape.LINE && (name === 'x1' || name === 'y1' || name === 'x2' || name === 'y2') || object.nodeName === g.Shape.POLYLINE && name === 'points' || object.nodeName === g.Shape.POLYGON && name === 'points' || object.nodeName === g.Shape.PATH && name === 'path') {
12376
12707
  // need re-calc geometry
12377
12708
  _this.material.geometryDirty = true;
12378
12709
  _this.material.programDirty = true;
@@ -13622,6 +13953,10 @@
13622
13953
  named: g.Shape.ELLIPSE
13623
13954
  }]
13624
13955
  })], CircleRenderer);
13956
+ /**
13957
+ * Try downgrading the "simple" Path / Polyline to InstancedLine.
13958
+ * @see https://github.com/antvis/G/issues/1113
13959
+ */
13625
13960
 
13626
13961
  var PathRenderer = /*#__PURE__*/function (_Batch) {
13627
13962
  _inheritsLoose$2(PathRenderer, _Batch);
@@ -13634,7 +13969,7 @@
13634
13969
  }
13635
13970
 
13636
13971
  _this = _Batch.call.apply(_Batch, [this].concat(args)) || this;
13637
- _this.meshes = [FillMesh, LineMesh];
13972
+ _this.meshes = [FillMesh, LineMesh, InstancedLineMesh];
13638
13973
  return _this;
13639
13974
  }
13640
13975
 
@@ -13652,7 +13987,9 @@
13652
13987
  var hasStroke = stroke && !stroke.isNone;
13653
13988
  var hasDash = lineDash && lineDash.length && lineDash.every(function (item) {
13654
13989
  return item.value !== 0;
13655
- }); // Polyline don't need fill
13990
+ });
13991
+ var isLine = this.isLine(object);
13992
+ object.renderable.proxyNodeName = isLine ? g.Shape.LINE : null; // Polyline don't need fill
13656
13993
 
13657
13994
  if (index === 0 && (object.nodeName === g.Shape.POLYLINE || fill.isNone)) {
13658
13995
  return false;
@@ -13660,7 +13997,7 @@
13660
13997
 
13661
13998
 
13662
13999
  if (index === 1) {
13663
- if (strokeOpacity.value === 0 || opacity.value === 0 || lineWidth.value === 0 || !hasStroke) {
14000
+ if (isLine || strokeOpacity.value === 0 || opacity.value === 0 || lineWidth.value === 0 || !hasStroke) {
13664
14001
  return false;
13665
14002
  }
13666
14003
 
@@ -13668,11 +14005,56 @@
13668
14005
  // @see https://github.com/antvis/g/issues/824
13669
14006
  return hasDash;
13670
14007
  }
14008
+ } // use Line for simple Path
14009
+
14010
+
14011
+ if (index === 2) {
14012
+ return isLine;
13671
14013
  }
13672
14014
 
13673
14015
  return true;
13674
14016
  };
13675
14017
 
14018
+ _proto.isLine = function isLine(object) {
14019
+ if (object.nodeName === g.Shape.PATH) {
14020
+ var curve = object.parsedStyle.path.curve;
14021
+ var eps = 0.01; // only contains M & L commands
14022
+
14023
+ if (curve.length === 2 && curve[0][0] === 'M' && curve[1][0] === 'C') {
14024
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
14025
+ var _curve$ = curve[0],
14026
+ _1 = _curve$[0],
14027
+ p1x = _curve$[1],
14028
+ p1y = _curve$[2]; // eslint-disable-next-line @typescript-eslint/no-unused-vars
14029
+
14030
+ var _curve$2 = curve[1],
14031
+ _2 = _curve$2[0],
14032
+ cpx1 = _curve$2[1],
14033
+ cpy1 = _curve$2[2],
14034
+ cpx2 = _curve$2[3],
14035
+ cpy2 = _curve$2[4],
14036
+ p2x = _curve$2[5],
14037
+ p2y = _curve$2[6];
14038
+ var tangent = (p1x - p2x) / (p1y - p2y);
14039
+ return (p1x - cpx1) / (p1y - cpy1) - tangent < eps && (cpx2 - p2x) / (cpy2 - p2y) - tangent < eps;
14040
+ }
14041
+ } else if (object.nodeName === g.Shape.POLYLINE) {
14042
+ var points = object.parsedStyle.points.points;
14043
+
14044
+ var _tangent = (points[1][0] - points[1][1]) / (points[0][0] - points[0][1]);
14045
+
14046
+ for (var i = 1; i < points.length - 1; i++) {
14047
+ if ((points[i + 1][0] - points[i + 1][1]) / (points[i][0] - points[i][1]) !== _tangent) {
14048
+ return false;
14049
+ }
14050
+ }
14051
+
14052
+ return true;
14053
+ }
14054
+
14055
+ return false;
14056
+ };
14057
+
13676
14058
  return PathRenderer;
13677
14059
  }(Batch);
13678
14060