You should change this loop body to

`Cartesian3.add(meanPoint, positions[i], meanPoint);`

and after the loop multiply by the inverse length. This way there is only one multiplication and zero allocations since `meanPoint` is also the result parameter to `Cartesian3.add`.