File tree Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ const log = require('./util/log');
13
13
* @type {twgl.v3 }
14
14
*/
15
15
const __isTouchingPosition = twgl . v3 . create ( ) ;
16
+ const FLOATING_POINT_ERROR_ALLOWANCE = 1e-6 ;
16
17
17
18
/**
18
19
* Convert a scratch space location into a texture space float. Uses the
@@ -37,6 +38,10 @@ const getLocalPosition = (drawable, vec) => {
37
38
// localPosition matches that transformation.
38
39
localPosition [ 0 ] = 0.5 - ( ( ( v0 * m [ 0 ] ) + ( v1 * m [ 4 ] ) + m [ 12 ] ) / d ) ;
39
40
localPosition [ 1 ] = ( ( ( v0 * m [ 1 ] ) + ( v1 * m [ 5 ] ) + m [ 13 ] ) / d ) + 0.5 ;
41
+ // Fix floating point issues near 0.
42
+ // TODO: Check if this can be removed after render pull 479 is merged
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 ;
40
45
// Apply texture effect transform if the localPosition is within the drawable's space,
41
46
// and any effects are currently active.
42
47
if ( drawable . enabledEffects !== 0 &&
You can’t perform that action at this time.
0 commit comments