Fix rotation binding for triangles

This commit is contained in:
Steve Ruiz 2021-12-09 22:38:23 +00:00
parent c5124b160e
commit eb234330dd
2 changed files with 3 additions and 2 deletions

View file

@ -480,7 +480,7 @@ export class ArrowUtil extends TDShapeUtil<T, E> {
handlePoint = Vec.sub(hits[0], shape.point)
}
} else if (target.type === TDShapeType.Triangle) {
const points = getTrianglePoints(target, BINDING_DISTANCE).map((pt) =>
const points = getTrianglePoints(target, BINDING_DISTANCE, target.rotation).map((pt) =>
Vec.add(pt, target.point)
)

View file

@ -267,7 +267,7 @@ export class TriangleUtil extends TDShapeUtil<T, E> {
/* Helpers */
/* -------------------------------------------------- */
export function getTrianglePoints(shape: T, offset = 0) {
export function getTrianglePoints(shape: T, offset = 0, rotation = 0) {
const {
size: [w, h],
} = shape
@ -279,6 +279,7 @@ export function getTrianglePoints(shape: T, offset = 0) {
]
if (offset) points = getOffsetPolygon(points, offset)
if (rotation) points = points.map((pt) => Vec.rotWith(pt, [w / 2, h / 2], rotation))
return points
}