Let's start with an example, $N=n^2=7^2=49$. $49$ can also be produced by simply writing $49= (6+1)^2 = 36 + 2\cdot6 + 1 = 36 + 13$. So if we can find a way to represent 13 as a sum of two squares, we will have a representation of 49 as a sum of 3 squares. 13 is an integer of the form $4k+1$ so it can be represented by a sum of 2 squares (I recently posted an algorithm). It is easy to see that $13= 2^2 + 3^2$. So basically, to write 49 as a sum of 3 squares all that was needed is the representation of 13 as a sum and a difference of 2 squares. $13=2^2+3^2=7^2-6^2$. Then it's just a matter of moving $6^2$ to the left hand side to get $49 = 2^2 + 3^2 + 6^2$.
When adding consecutive odd numbers to form the square $49$, $13$ is the last odd number to be added. Note that this algorithm will not work for squares of the form $4k$ simply because the last odd number to be added is of the form $4k+3$. For example $64= 49+ 15= 7^2 + 15$.
To summarize the algorithm:
1-Given an integer $N=n^2$ we want to write as $N=a^2+b^2+c^2$
3-Express $m$ as $m=((m+1)/2)^2 - ((m-1)/2)^2 = n^2 - c^2$
4-Find the decomposition of $m$ as $m=a^2 + b^2$ using my algorithm posted on this site ( or some other algorithm of your choice)
6-Write $N=n^2=a^2 + b^2 +c^2$
Can this algorithm be considered as an application of De Gua's theorem, the equivalent of the Pythagorean theorem in 3D?