@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/css/parser/points.d.ts +1 -1
- package/dist/index.esm.js +41 -24
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +40 -23
- package/dist/index.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/plugins/PrepareRendererPlugin.d.ts +1 -0
- package/dist/utils/path.d.ts +1 -0
- package/package.json +2 -2
|
@@ -8,7 +8,7 @@ import type { DisplayObject } from '../..';
|
|
|
8
8
|
export declare function parsePoints(pointsOrStr: string | [number, number][], object?: DisplayObject): {
|
|
9
9
|
points: [number, number][];
|
|
10
10
|
totalLength: number;
|
|
11
|
-
segments: [
|
|
11
|
+
segments: any[];
|
|
12
12
|
};
|
|
13
13
|
export declare function mergePoints(left: any, right: any): [
|
|
14
14
|
[
|
package/dist/index.esm.js
CHANGED
|
@@ -3,7 +3,7 @@ import EventEmitter from 'eventemitter3';
|
|
|
3
3
|
import { mat4, vec4, vec3, mat3, quat as quat$1, vec2 } from 'gl-matrix';
|
|
4
4
|
import { isNumber, distanceSquareRoot, isString, isNil, clamp, getTotalLength, min, max, isNumberEqual, mod, normalizePath, path2Curve, equalizeSegments, getDrawDirection, reverseCurve, clonePath, getRotatedCurve, isArray, isBoolean, isObject, isUndefined, getPointAtLength } from '@antv/util';
|
|
5
5
|
import * as d3 from 'd3-color';
|
|
6
|
-
import { arcBox, cubicBox, quadBox,
|
|
6
|
+
import { polylineLength, arcBox, cubicBox, quadBox, linePointAt, lineLength } from '@antv/g-math';
|
|
7
7
|
|
|
8
8
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
9
9
|
|
|
@@ -4225,6 +4225,12 @@ function getOrCalculatePathTotalLength(path) {
|
|
|
4225
4225
|
}
|
|
4226
4226
|
return path.parsedStyle.d.totalLength;
|
|
4227
4227
|
}
|
|
4228
|
+
function getOrCalculatePolylineTotalLength(polyline) {
|
|
4229
|
+
if (polyline.parsedStyle.points.totalLength === 0) {
|
|
4230
|
+
polyline.parsedStyle.points.totalLength = polylineLength(polyline.parsedStyle.points.points);
|
|
4231
|
+
}
|
|
4232
|
+
return polyline.parsedStyle.points.totalLength;
|
|
4233
|
+
}
|
|
4228
4234
|
function removeRedundantMCommand(path) {
|
|
4229
4235
|
for (var i = 0; i < path.length; i++) {
|
|
4230
4236
|
var prevSegment = path[i - 1];
|
|
@@ -5095,27 +5101,10 @@ function parsePoints(pointsOrStr, object) {
|
|
|
5095
5101
|
else {
|
|
5096
5102
|
points = pointsOrStr;
|
|
5097
5103
|
}
|
|
5098
|
-
var segments = [];
|
|
5099
|
-
var tempLength = 0;
|
|
5100
|
-
var segmentT;
|
|
5101
|
-
var segmentL;
|
|
5102
|
-
var totalLength = polylineLength(points);
|
|
5103
|
-
points.forEach(function (p, i) {
|
|
5104
|
-
if (points[i + 1]) {
|
|
5105
|
-
segmentT = [0, 0];
|
|
5106
|
-
segmentT[0] = tempLength / totalLength;
|
|
5107
|
-
segmentL = lineLength(p[0], p[1], points[i + 1][0], points[i + 1][1]);
|
|
5108
|
-
tempLength += segmentL;
|
|
5109
|
-
segmentT[1] = tempLength / totalLength;
|
|
5110
|
-
segments.push(segmentT);
|
|
5111
|
-
}
|
|
5112
|
-
});
|
|
5113
|
-
// const minX = Math.min(...points.map((point) => point[0]));
|
|
5114
|
-
// const minY = Math.min(...points.map((point) => point[1]));
|
|
5115
5104
|
return {
|
|
5116
5105
|
points: points,
|
|
5117
|
-
totalLength:
|
|
5118
|
-
segments:
|
|
5106
|
+
totalLength: 0,
|
|
5107
|
+
segments: [],
|
|
5119
5108
|
};
|
|
5120
5109
|
}
|
|
5121
5110
|
function mergePoints(left, right) {
|
|
@@ -13615,7 +13604,7 @@ var Polyline = /** @class */ (function (_super) {
|
|
|
13615
13604
|
} }, rest)) || this;
|
|
13616
13605
|
}
|
|
13617
13606
|
Polyline.prototype.getTotalLength = function () {
|
|
13618
|
-
return this
|
|
13607
|
+
return getOrCalculatePolylineTotalLength(this);
|
|
13619
13608
|
};
|
|
13620
13609
|
Polyline.prototype.getPointAtLength = function (distance, inWorldSpace) {
|
|
13621
13610
|
if (inWorldSpace === void 0) { inWorldSpace = false; }
|
|
@@ -13623,16 +13612,34 @@ var Polyline = /** @class */ (function (_super) {
|
|
|
13623
13612
|
};
|
|
13624
13613
|
Polyline.prototype.getPoint = function (ratio, inWorldSpace) {
|
|
13625
13614
|
if (inWorldSpace === void 0) { inWorldSpace = false; }
|
|
13626
|
-
var
|
|
13615
|
+
var points = this.parsedStyle.points.points;
|
|
13616
|
+
if (this.parsedStyle.points.segments.length === 0) {
|
|
13617
|
+
var segments_1 = [];
|
|
13618
|
+
var tempLength_1 = 0;
|
|
13619
|
+
var segmentT_1;
|
|
13620
|
+
var segmentL_1;
|
|
13621
|
+
var totalLength_1 = this.getTotalLength();
|
|
13622
|
+
points.forEach(function (p, i) {
|
|
13623
|
+
if (points[i + 1]) {
|
|
13624
|
+
segmentT_1 = [0, 0];
|
|
13625
|
+
segmentT_1[0] = tempLength_1 / totalLength_1;
|
|
13626
|
+
segmentL_1 = lineLength(p[0], p[1], points[i + 1][0], points[i + 1][1]);
|
|
13627
|
+
tempLength_1 += segmentL_1;
|
|
13628
|
+
segmentT_1[1] = tempLength_1 / totalLength_1;
|
|
13629
|
+
segments_1.push(segmentT_1);
|
|
13630
|
+
}
|
|
13631
|
+
});
|
|
13632
|
+
this.parsedStyle.points.segments = segments_1;
|
|
13633
|
+
}
|
|
13627
13634
|
var subt = 0;
|
|
13628
13635
|
var index = 0;
|
|
13629
|
-
segments.forEach(function (v, i) {
|
|
13636
|
+
this.parsedStyle.points.segments.forEach(function (v, i) {
|
|
13630
13637
|
if (ratio >= v[0] && ratio <= v[1]) {
|
|
13631
13638
|
subt = (ratio - v[0]) / (v[1] - v[0]);
|
|
13632
13639
|
index = i;
|
|
13633
13640
|
}
|
|
13634
13641
|
});
|
|
13635
|
-
var
|
|
13642
|
+
var _a = linePointAt(points[index][0], points[index][1], points[index + 1][0], points[index + 1][1], subt), x = _a.x, y = _a.y;
|
|
13636
13643
|
var transformed = vec3.transformMat4(vec3.create(), vec3.fromValues(x, y, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
|
|
13637
13644
|
// apply local transformation
|
|
13638
13645
|
return new Point(transformed[0], transformed[1]);
|
|
@@ -14703,6 +14710,7 @@ var PrepareRendererPlugin = /** @class */ (function () {
|
|
|
14703
14710
|
this.toSync = new Set();
|
|
14704
14711
|
this.isFirstTimeRendering = true;
|
|
14705
14712
|
this.syncing = false;
|
|
14713
|
+
this.isFirstTimeRenderingFinished = false;
|
|
14706
14714
|
}
|
|
14707
14715
|
PrepareRendererPlugin.prototype.apply = function (context) {
|
|
14708
14716
|
var _this = this;
|
|
@@ -14772,6 +14780,7 @@ var PrepareRendererPlugin = /** @class */ (function () {
|
|
|
14772
14780
|
_this.syncing = true;
|
|
14773
14781
|
ric(function () {
|
|
14774
14782
|
_this.syncRTree(true);
|
|
14783
|
+
_this.isFirstTimeRenderingFinished = true;
|
|
14775
14784
|
});
|
|
14776
14785
|
}
|
|
14777
14786
|
else {
|
|
@@ -14799,6 +14808,14 @@ var PrepareRendererPlugin = /** @class */ (function () {
|
|
|
14799
14808
|
}
|
|
14800
14809
|
var renderBounds = node.getRenderBounds();
|
|
14801
14810
|
if (renderBounds) {
|
|
14811
|
+
var renderable = node.renderable;
|
|
14812
|
+
if (force) {
|
|
14813
|
+
if (!renderable.dirtyRenderBounds) {
|
|
14814
|
+
renderable.dirtyRenderBounds = new AABB();
|
|
14815
|
+
}
|
|
14816
|
+
// save last dirty aabb
|
|
14817
|
+
renderable.dirtyRenderBounds.update(renderBounds.center, renderBounds.halfExtents);
|
|
14818
|
+
}
|
|
14802
14819
|
var _a = __read(renderBounds.getMin(), 2), minX = _a[0], minY = _a[1];
|
|
14803
14820
|
var _b = __read(renderBounds.getMax(), 2), maxX = _b[0], maxY = _b[1];
|
|
14804
14821
|
if (!rBushNode.aabb) {
|