wanadev / gltf-bounding-box

Computes the global bounding box of a gltf model
Other
20 stars 7 forks source link

[BUG] Integer division causes center to be rounded even if precision is set #13

Closed aronfiechter closed 5 years ago

aronfiechter commented 5 years ago

In the files gltf1-bounding-box.js and gltf2-bounding-box.js the center is computed as:

center: {
    x: precise.round((boundings.max[0] + boundings.min[0]) / 2, precision + 1),
    y: precise.round((boundings.max[2] + boundings.min[2]) / 2, precision + 1),
    z: precise.round((boundings.max[1] + boundings.min[1]) / 2, precision + 1),
},

However, the division by 2 is integer division and causes the number argument of precise.round to always be an integer.

To correct this bug, I believe it is enough to divide by 2.0 instead.

Should I make a PR for this?

aronfiechter commented 5 years ago

(I'm stupid, there's no integer division in JS.)