Fix initialization of viewportTransform array

Add unit tests
JSDoc tweaks

Closes #1494
This is for cloning? Perhaps an old `slice(0)` trick would be better (faster, simpler)?