port view matrix code from blockcillin JS