Skip to content

Commit b119d35

Browse files
author
DD Liu
committed
Fix floating point issues near 0
1 parent 00554df commit b119d35

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/Drawable.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const getLocalPosition = (drawable, vec) => {
3737
// localPosition matches that transformation.
3838
localPosition[0] = 0.5 - (((v0 * m[0]) + (v1 * m[4]) + m[12]) / d);
3939
localPosition[1] = (((v0 * m[1]) + (v1 * m[5]) + m[13]) / d) + 0.5;
40+
if (Math.abs(localPosition[0] < 1e-8)) localPosition[0] = 0;
41+
if (Math.abs(localPosition[1] < 1e-8)) localPosition[1] = 0;
4042
// Apply texture effect transform if the localPosition is within the drawable's space,
4143
// and any effects are currently active.
4244
if (drawable.enabledEffects !== 0 &&

0 commit comments

Comments
 (0)