@antv/g-lite 1.3.0-next.19 → 1.3.0-next.20

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.js CHANGED
@@ -4246,6 +4246,12 @@ function getOrCalculatePathTotalLength(path) {
4246
4246
  }
4247
4247
  return path.parsedStyle.d.totalLength;
4248
4248
  }
4249
+ function getOrCalculatePolylineTotalLength(polyline) {
4250
+ if (polyline.parsedStyle.points.totalLength === 0) {
4251
+ polyline.parsedStyle.points.totalLength = gMath.polylineLength(polyline.parsedStyle.points.points);
4252
+ }
4253
+ return polyline.parsedStyle.points.totalLength;
4254
+ }
4249
4255
  function removeRedundantMCommand(path) {
4250
4256
  for (var i = 0; i < path.length; i++) {
4251
4257
  var prevSegment = path[i - 1];
@@ -5116,27 +5122,10 @@ function parsePoints(pointsOrStr, object) {
5116
5122
  else {
5117
5123
  points = pointsOrStr;
5118
5124
  }
5119
- var segments = [];
5120
- var tempLength = 0;
5121
- var segmentT;
5122
- var segmentL;
5123
- var totalLength = gMath.polylineLength(points);
5124
- points.forEach(function (p, i) {
5125
- if (points[i + 1]) {
5126
- segmentT = [0, 0];
5127
- segmentT[0] = tempLength / totalLength;
5128
- segmentL = gMath.lineLength(p[0], p[1], points[i + 1][0], points[i + 1][1]);
5129
- tempLength += segmentL;
5130
- segmentT[1] = tempLength / totalLength;
5131
- segments.push(segmentT);
5132
- }
5133
- });
5134
- // const minX = Math.min(...points.map((point) => point[0]));
5135
- // const minY = Math.min(...points.map((point) => point[1]));
5136
5125
  return {
5137
5126
  points: points,
5138
- totalLength: totalLength,
5139
- segments: segments,
5127
+ totalLength: 0,
5128
+ segments: [],
5140
5129
  };
5141
5130
  }
5142
5131
  function mergePoints(left, right) {
@@ -13636,7 +13625,7 @@ var Polyline = /** @class */ (function (_super) {
13636
13625
  } }, rest)) || this;
13637
13626
  }
13638
13627
  Polyline.prototype.getTotalLength = function () {
13639
- return this.parsedStyle.points.totalLength;
13628
+ return getOrCalculatePolylineTotalLength(this);
13640
13629
  };
13641
13630
  Polyline.prototype.getPointAtLength = function (distance, inWorldSpace) {
13642
13631
  if (inWorldSpace === void 0) { inWorldSpace = false; }
@@ -13644,16 +13633,34 @@ var Polyline = /** @class */ (function (_super) {
13644
13633
  };
13645
13634
  Polyline.prototype.getPoint = function (ratio, inWorldSpace) {
13646
13635
  if (inWorldSpace === void 0) { inWorldSpace = false; }
13647
- var _a = this.parsedStyle.points, points = _a.points, segments = _a.segments;
13636
+ var points = this.parsedStyle.points.points;
13637
+ if (this.parsedStyle.points.segments.length === 0) {
13638
+ var segments_1 = [];
13639
+ var tempLength_1 = 0;
13640
+ var segmentT_1;
13641
+ var segmentL_1;
13642
+ var totalLength_1 = this.getTotalLength();
13643
+ points.forEach(function (p, i) {
13644
+ if (points[i + 1]) {
13645
+ segmentT_1 = [0, 0];
13646
+ segmentT_1[0] = tempLength_1 / totalLength_1;
13647
+ segmentL_1 = gMath.lineLength(p[0], p[1], points[i + 1][0], points[i + 1][1]);
13648
+ tempLength_1 += segmentL_1;
13649
+ segmentT_1[1] = tempLength_1 / totalLength_1;
13650
+ segments_1.push(segmentT_1);
13651
+ }
13652
+ });
13653
+ this.parsedStyle.points.segments = segments_1;
13654
+ }
13648
13655
  var subt = 0;
13649
13656
  var index = 0;
13650
- segments.forEach(function (v, i) {
13657
+ this.parsedStyle.points.segments.forEach(function (v, i) {
13651
13658
  if (ratio >= v[0] && ratio <= v[1]) {
13652
13659
  subt = (ratio - v[0]) / (v[1] - v[0]);
13653
13660
  index = i;
13654
13661
  }
13655
13662
  });
13656
- var _b = gMath.linePointAt(points[index][0], points[index][1], points[index + 1][0], points[index + 1][1], subt), x = _b.x, y = _b.y;
13663
+ var _a = gMath.linePointAt(points[index][0], points[index][1], points[index + 1][0], points[index + 1][1], subt), x = _a.x, y = _a.y;
13657
13664
  var transformed = glMatrix.vec3.transformMat4(glMatrix.vec3.create(), glMatrix.vec3.fromValues(x, y, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
13658
13665
  // apply local transformation
13659
13666
  return new Point(transformed[0], transformed[1]);
@@ -14724,6 +14731,7 @@ var PrepareRendererPlugin = /** @class */ (function () {
14724
14731
  this.toSync = new Set();
14725
14732
  this.isFirstTimeRendering = true;
14726
14733
  this.syncing = false;
14734
+ this.isFirstTimeRenderingFinished = false;
14727
14735
  }
14728
14736
  PrepareRendererPlugin.prototype.apply = function (context) {
14729
14737
  var _this = this;
@@ -14793,6 +14801,7 @@ var PrepareRendererPlugin = /** @class */ (function () {
14793
14801
  _this.syncing = true;
14794
14802
  ric(function () {
14795
14803
  _this.syncRTree(true);
14804
+ _this.isFirstTimeRenderingFinished = true;
14796
14805
  });
14797
14806
  }
14798
14807
  else {
@@ -14820,6 +14829,14 @@ var PrepareRendererPlugin = /** @class */ (function () {
14820
14829
  }
14821
14830
  var renderBounds = node.getRenderBounds();
14822
14831
  if (renderBounds) {
14832
+ var renderable = node.renderable;
14833
+ if (force) {
14834
+ if (!renderable.dirtyRenderBounds) {
14835
+ renderable.dirtyRenderBounds = new AABB();
14836
+ }
14837
+ // save last dirty aabb
14838
+ renderable.dirtyRenderBounds.update(renderBounds.center, renderBounds.halfExtents);
14839
+ }
14823
14840
  var _a = tslib.__read(renderBounds.getMin(), 2), minX = _a[0], minY = _a[1];
14824
14841
  var _b = tslib.__read(renderBounds.getMax(), 2), maxX = _b[0], maxY = _b[1];
14825
14842
  if (!rBushNode.aabb) {