Q:

Problems with huge (physical) coordinates in WebGL?

With the help of WebGL I display microscopic 3D data in the browser. The position of the elements I display is given in nanometers relative to a common origin. This causes the coordinates to get quite big: A bounding box around my current data set ranges from 0; 0; 0 to 120000, 130000, 250000. Working with coordinates in this volume is currently no problem and I couldn't find any problems with the floating point calculations.
Do you see any potential problems when I want to scale up and coordinates get maybe 1000 times bigger? Would you recommend scaling down coordinates as part of the modelview transform? If possible, I would like to continue working in this nanometer based coordinate system. Within my tests with 10, 100 and 1000 times bigger coordinates I couldn't see a problem so far.

A:

WebGL use 32 bits floats for every coordinate. If this is enough, highly depends on what you do with it, but for example you can't make a smooth animation after (around) 100k because you lose too much decimal precision.
If you want to test how 32 bits float deals with big numbers, here is a function.
function testFloat32(x) {
    var arr = new Float32Array(1);
    arr[0] = x;
    return arr[0];
}

testFloat32(32000.123456798);      // ==> 32000.123046875
testFloat32(35000.123456798);      // ==> 35000.125
testFloat32(120000.65465684);      // ==> 120000.65625
testFloat32(130000.57546565);      // ==> 130000.578125
testFloat32(250000.58785446);      // ==> 250000.59375
testFloat32(1000000.54541545);     // ==> 1000000.5625
testFloat32(10000000.98796541652); // ==> 10000001
testFloat32(100000000.5879654645); // ==> 100000000
testFloat32(1234567890);           // ==> 1234567936
testFloat32(100000001);            // ==> 100000000
testFloat32(100000002);            // ==> 100000000
testFloat32(100000003);            // ==> 100000000

