How to do high precision transformations?

I’ve found the problem. Apparently Float32Arrays are used for matrix calculations. This is fine when directly dealing with the GPU, but not so much for internal model transformations. To demonstrate this:

// low precision
var lowp = new Float32Array(1);
lowp[0] = 999999868.4547106;
console.log(lowp[0]); // = 999999872

// high precision
var highp = new Float64Array(1);
highp[0] = 999999868.4547106;
console.log(highp[0]); // = 999999868.4547106

I wanted to backtrack the source code where the issue was. But the BabylonJS source code was just too much to walk through. Then I tried a ThreeJS playground, and it seemed the issue happened there too. So then I looked into the ThreeJS source code, and it is much less bloated, and made for efficiency. There I found that the matrix calculation was using Float32Arrays.

I’d like to create my own custom function that does the necessary calculations, and then using Float32Arrays, since I’d rather not modify the BabylonJS library directly for consistency reasons. Not sure how easy this will be, but I’ll let you know what I came up with when I’m done, if I don’t switch to using ThreeJS.