Skip to content

Commit fdbd1ad

Browse files
author
DD Liu
committed
Fix syntax and bump the error allowance
1 parent 27f3781 commit fdbd1ad

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Drawable.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const log = require('./util/log');
1313
* @type {twgl.v3}
1414
*/
1515
const __isTouchingPosition = twgl.v3.create();
16+
const FLOATING_POINT_ERROR_ALLOWANCE = 1e-6;
1617

1718
/**
1819
* Convert a scratch space location into a texture space float. Uses the
@@ -39,8 +40,8 @@ const getLocalPosition = (drawable, vec) => {
3940
localPosition[1] = (((v0 * m[1]) + (v1 * m[5]) + m[13]) / d) + 0.5;
4041
// Fix floating point issues near 0.
4142
// TODO: Check if this can be removed after render pull 479 is merged
42-
if (Math.abs(localPosition[0] < 1e-8)) localPosition[0] = 0;
43-
if (Math.abs(localPosition[1] < 1e-8)) localPosition[1] = 0;
43+
if (Math.abs(localPosition[0]) < FLOATING_POINT_ERROR_ALLOWANCE) localPosition[0] = 0;
44+
if (Math.abs(localPosition[1]) < FLOATING_POINT_ERROR_ALLOWANCE) localPosition[1] = 0;
4445
// Apply texture effect transform if the localPosition is within the drawable's space,
4546
// and any effects are currently active.
4647
if (drawable.enabledEffects !== 0 &&

0 commit comments

Comments
 (0)