@antv/g6 5.0.0-beta.8 → 5.0.0-beta.9
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/g6.min.js +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/item/edge.d.ts +1 -5
- package/esm/item/edge.js +15 -12
- package/esm/item/edge.js.map +1 -1
- package/esm/item/node.js +7 -3
- package/esm/item/node.js.map +1 -1
- package/esm/stdlib/item/node/base3d.d.ts +1 -0
- package/esm/stdlib/item/node/base3d.js +1 -0
- package/esm/stdlib/item/node/base3d.js.map +1 -1
- package/esm/util/point.js +4 -1
- package/esm/util/point.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/item/edge.d.ts +1 -5
- package/lib/item/edge.js +15 -12
- package/lib/item/edge.js.map +1 -1
- package/lib/item/node.js +7 -3
- package/lib/item/node.js.map +1 -1
- package/lib/stdlib/item/node/base3d.d.ts +1 -0
- package/lib/stdlib/item/node/base3d.js +1 -0
- package/lib/stdlib/item/node/base3d.js.map +1 -1
- package/lib/util/point.js +4 -1
- package/lib/util/point.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/item/edge.ts +24 -19
- package/src/item/node.ts +6 -4
- package/src/stdlib/item/node/base3d.ts +1 -0
- package/src/util/point.ts +4 -1
package/src/item/edge.ts
CHANGED
|
@@ -44,11 +44,13 @@ export default class Edge extends Item {
|
|
|
44
44
|
public targetItem: Node | Combo;
|
|
45
45
|
|
|
46
46
|
/** Caches to avoid unnecessary calculations. */
|
|
47
|
-
private
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
private cache: {
|
|
48
|
+
sourcePositionCache?: Point;
|
|
49
|
+
targetPositionCache?: Point;
|
|
50
|
+
controlPointsCache?: Point;
|
|
51
|
+
sourcePointCache?: Point;
|
|
52
|
+
targetPointCache?: Point;
|
|
53
|
+
} = {};
|
|
52
54
|
|
|
53
55
|
constructor(props: IProps) {
|
|
54
56
|
super(props);
|
|
@@ -187,8 +189,8 @@ export default class Edge extends Item {
|
|
|
187
189
|
)
|
|
188
190
|
) {
|
|
189
191
|
return {
|
|
190
|
-
sourcePoint: this.sourcePointCache,
|
|
191
|
-
targetPoint: this.targetPointCache,
|
|
192
|
+
sourcePoint: this.cache.sourcePointCache,
|
|
193
|
+
targetPoint: this.cache.targetPointCache,
|
|
192
194
|
changed: false,
|
|
193
195
|
};
|
|
194
196
|
}
|
|
@@ -214,17 +216,17 @@ export default class Edge extends Item {
|
|
|
214
216
|
targetPosition,
|
|
215
217
|
).nearestPoint;
|
|
216
218
|
}
|
|
217
|
-
this.sourcePointCache = this.sourceItem.getAnchorPoint(
|
|
219
|
+
this.cache.sourcePointCache = this.sourceItem.getAnchorPoint(
|
|
218
220
|
sourcePrevious,
|
|
219
221
|
sourceAnchor,
|
|
220
222
|
);
|
|
221
|
-
this.targetPointCache = this.targetItem.getAnchorPoint(
|
|
223
|
+
this.cache.targetPointCache = this.targetItem.getAnchorPoint(
|
|
222
224
|
targetPrevious,
|
|
223
225
|
targetAnchor,
|
|
224
226
|
);
|
|
225
227
|
return {
|
|
226
|
-
sourcePoint: this.sourcePointCache,
|
|
227
|
-
targetPoint: this.targetPointCache,
|
|
228
|
+
sourcePoint: this.cache.sourcePointCache,
|
|
229
|
+
targetPoint: this.cache.targetPointCache,
|
|
228
230
|
changed: true,
|
|
229
231
|
};
|
|
230
232
|
}
|
|
@@ -237,15 +239,18 @@ export default class Edge extends Item {
|
|
|
237
239
|
* @returns
|
|
238
240
|
*/
|
|
239
241
|
private shouldUpdatePoints(sourcePosition, targetPosition, controlPoints) {
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
242
|
+
const isComboEnd =
|
|
243
|
+
this.sourceItem.type === 'combo' || this.targetItem.type === 'combo';
|
|
244
|
+
const changed =
|
|
245
|
+
!(
|
|
246
|
+
isSamePoint(sourcePosition, this.cache.sourcePositionCache) &&
|
|
247
|
+
isSamePoint(targetPosition, this.cache.targetPositionCache) &&
|
|
248
|
+
controlPoints === this.cache.controlPointsCache
|
|
249
|
+
) || isComboEnd;
|
|
245
250
|
if (changed) {
|
|
246
|
-
this.sourcePositionCache = sourcePosition;
|
|
247
|
-
this.targetPositionCache = targetPosition;
|
|
248
|
-
this.controlPointsCache = controlPoints;
|
|
251
|
+
this.cache.sourcePositionCache = sourcePosition;
|
|
252
|
+
this.cache.targetPositionCache = targetPosition;
|
|
253
|
+
this.cache.controlPointsCache = controlPoints;
|
|
249
254
|
}
|
|
250
255
|
return changed;
|
|
251
256
|
}
|
package/src/item/node.ts
CHANGED
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
getRectIntersectByPoint,
|
|
15
15
|
} from '../util/point';
|
|
16
16
|
import { ComboModelData } from '../types/combo';
|
|
17
|
-
import { isArraySame } from '../util/array';
|
|
18
17
|
import Item from './item';
|
|
19
18
|
|
|
20
19
|
interface IProps {
|
|
@@ -270,14 +269,16 @@ export default class Node extends Item {
|
|
|
270
269
|
const keyShapeWidth = keyShapeRenderBBox.max[0] - keyShapeRenderBBox.min[0];
|
|
271
270
|
const keyShapeHeight =
|
|
272
271
|
keyShapeRenderBBox.max[1] - keyShapeRenderBBox.min[1];
|
|
272
|
+
const keyShapeDepth = keyShapeRenderBBox.max[2] - keyShapeRenderBBox.min[2];
|
|
273
273
|
const anchorPositions = anchorPoints.map((pointRatio) => {
|
|
274
|
-
const [xRatio, yRatio] = pointRatio;
|
|
274
|
+
const [xRatio, yRatio, zRatio] = pointRatio;
|
|
275
275
|
return {
|
|
276
276
|
x: keyShapeWidth * xRatio + keyShapeRenderBBox.min[0],
|
|
277
277
|
y: keyShapeHeight * yRatio + keyShapeRenderBBox.min[1],
|
|
278
278
|
};
|
|
279
279
|
});
|
|
280
280
|
|
|
281
|
+
console.log('anchorIdx', anchorIdx, anchorPositions, shapeType, innerPoint);
|
|
281
282
|
if (anchorIdx !== undefined && anchorPositions[anchorIdx]) {
|
|
282
283
|
return anchorPositions[anchorIdx];
|
|
283
284
|
}
|
|
@@ -323,6 +324,7 @@ export default class Node extends Item {
|
|
|
323
324
|
}
|
|
324
325
|
|
|
325
326
|
let linkPoint = intersectPoint;
|
|
327
|
+
if (!isNaN(z)) linkPoint.z = z;
|
|
326
328
|
|
|
327
329
|
// If the node has anchorPoints in the data, find the nearest anchor point.
|
|
328
330
|
if (anchorPoints.length) {
|
|
@@ -334,7 +336,7 @@ export default class Node extends Item {
|
|
|
334
336
|
}
|
|
335
337
|
if (!linkPoint) {
|
|
336
338
|
// If the calculations above are all failed, return the data's position
|
|
337
|
-
return { x, y };
|
|
339
|
+
return { x, y, z };
|
|
338
340
|
}
|
|
339
341
|
return linkPoint;
|
|
340
342
|
}
|
|
@@ -342,7 +344,7 @@ export default class Node extends Item {
|
|
|
342
344
|
public getPosition(): Point {
|
|
343
345
|
const initiated =
|
|
344
346
|
this.shapeMap.keyShape && this.group.attributes.x !== undefined;
|
|
345
|
-
if (initiated) {
|
|
347
|
+
if (initiated && this.renderExt.dimensions !== 3) {
|
|
346
348
|
const { center } = this.shapeMap.keyShape.getRenderBounds();
|
|
347
349
|
return { x: center[0], y: center[1], z: center[2] };
|
|
348
350
|
}
|
package/src/util/point.ts
CHANGED
|
@@ -52,7 +52,10 @@ export const distanceVec = (p1: vec2, p2: vec2): number => {
|
|
|
52
52
|
export const distance = (p1: Point, p2: Point): number => {
|
|
53
53
|
const vx = p1.x - p2.x;
|
|
54
54
|
const vy = p1.y - p2.y;
|
|
55
|
-
|
|
55
|
+
const vz = p1.z - p2.z;
|
|
56
|
+
return isNaN(vz)
|
|
57
|
+
? Math.sqrt(vx * vx + vy * vy)
|
|
58
|
+
: Math.sqrt(vx * vx + vy * vy + vz * vz);
|
|
56
59
|
};
|
|
57
60
|
|
|
58
61
|
/**
|