对嵌套的group进行矩阵旋转会导致节点消失 #4772
zzjjbbaa posted onGitHub
使用矩阵可以达到任意变换:
``` // 单个图形旋转 const shape = group.addShape.... const shapeMatrix = shape.getMatrix(); if (!shapeMatrix) shapeMatrix =[1, 0, 0, 1, 0, 0, 0, 0, 1]; shapeMatrix = transform(shapeMatrix, [ ['t', -center[0], -center[1]], // 先平移到旋转中心 ['r', Math.PI / 3], // 旋转 Math.PI / 3 ['t', center[0], center[1]], // 平移回来 ]); shape.setMatrix(shapeMatrix);
// 整个图形组旋转 const groupMatrix = group.getMatrix(); if(!groupMatrix) groupMatrix = [1, 0, 0, 1, 0, 0, 0, 0, 1]; groupMatrix = transform(shapeMatrix, [ ['t', -center[0], -center[1]], // 先平移到旋转中心 ['r', Math.PI / 3], // 旋转 Math.PI / 3 ['t', center[0], center[1]], // 平移回来 ]); group.setMatrix(groupMatrix);
Originally posted by @Yanyan-Wang in https://github.com/antvis/G6/issues/1789#issuecomment-658008052