I'm trying to create pics that behave like nodes. Following the instructions of shifting scopes and naming scopes for pics, I managed to manually create pics and move them to behave like nodes.
The main problem, is that if the pic is not constructed in a way that the first node remains at the center of the scope, then the whole pic is shifted (see my example below).
My problem is how to automatically re-center the scope such that it doesn't matter how the pic was constructed the anchor will always be at its center. Is there a way to center the scope like using the pic shift but automatically?
MWE
\documentclass[convert={outext=.png}]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\makeatletter
\begin{tikzpicture}[
% https://tex.stackexchange.com/a/185283/7561
pic shift/.store in=\shiftcoord,
pic shift={(0,0)},
% https://tex.stackexchange.com/a/241737/7561
pics/named scope code/.style 2 args={code={\tikz@fig@mustbenamed%
\begin{scope}[shift={\shiftcoord}, local bounding box/.expanded=\tikz@fig@name, #1]#2\end{scope}%
}},
% this pic is shifted since the other nodes are placed at the right of the first one
pics/balls/.style = {named scope code={node distance=5pt}{%
\node[draw, circle] (c1) {};
\node[draw, circle, right=of c1] (c2) {};
\node[draw, circle, right=of c2] (c3) {};
}},
% same as the above pic, but now the nodes are placed around the first one instead
pics/center balls/.style = {named scope code={node distance=5pt}{%
\node[draw, circle] (c1) {};
\node[draw, circle, left=of c1] (c2) {};
\node[draw, circle, right=of c1] (c3) {};
}},
]
% base node for reference
\node (o) {O};
% first pic
\draw pic[right=of o] (b) {balls};
% this is shifted
\draw pic[below=5pt of b] (b2) {balls};
% this is centered by moving it by hand
\draw pic[below=20pt of b, pic shift={(-.5,0)}] (b2) {balls};
% this is centered by design
\draw pic[below=35pt of b] (b3) {center balls};
\end{tikzpicture}
\makeatother
\end{document}



