I saved the coordinates of the circleWidget in advance, then when I opened it again, I got the coordinates from the server and rendered it on the image, now the circle is not drawn.
render code is:
const renderLabelData = () => {
const center = [74.4009870392814, 284.10467299253185, 0];
const point2 = [121.54116747218805, 251.60032328973563, 0]
const corner = [57.26019001757384, 57.26019001757384, 57.26019001757384];
scene.circleHandle.getWidgetState().getEllipseHandle().setOrigin(center);
scene.circleHandle.getWidgetState().getPoint2Handle().setOrigin(point2);
painter.paintEllipse(center, corner);
initializeHandle(scene.circleHandle);
};
const initializeHandle = (handle) => {
handle.onStartInteractionEvent(() => {
painter.startStroke();
});
handle.onEndInteractionEvent(() => {
painter.endStroke();
});
};
paint code:
scene.circleHandle.onEndInteractionEvent(() => {
const center = scene.circleHandle
.getWidgetState()
.getEllipseHandle()
.getOrigin();
const point2 = scene.circleHandle
.getWidgetState()
.getPoint2Handle()
.getOrigin();
if (center && point2) {
const radius = vec3.distance(center, point2);
const corner = [radius, radius, radius];
painter.paintEllipse(center, corner);
}
});
initializeHandle(scene.circleHandle);