hudbrog / gCodeViewer

a visual web based gcode analyzer
Other
419 stars 148 forks source link

Bug in renderer3d then also breaks 2D view #49

Closed Clotoo closed 7 years ago

Clotoo commented 7 years ago

Description : When a GCODE contains an actual ZERO coordinate (as X, Y, or Z), then the corresponding point in the 3D visualizer doesn't appear where it should be. The bug doesn't appear at first in the 2D view, but after opening 3D view it appears, and when going back to 2D view it appears there too.

Steps to reproduce :

Cause : After thorough investigation, it appears the offending point (for the first layer) corresponds to line 513 in the GCODE G1 X-0.000 Y-17.597 E3.84787 It is not a parsing problem though, the parser correctly reads it as { x=0 y=-17.597 z=NaN, ... } The problem is in the 3D model builder when iterating through the cmds (renderer3d.js line 49)

            if(!cmds[j].x)cmds[j].x=prevX;
            if(!cmds[j].y)cmds[j].y=prevY;
            if(!cmds[j].z)cmds[j].z=prevZ;

Number zero is interpreted as False.

Fix : I am not familiar enough with your code to be sure, but I think replacing the !cmds[j].x with a isNaN(cmds[j].x) instead should do the job. isNaN will return true in case of NaN or undefined.

hudbrog commented 7 years ago

That is THE BEST bug report I've ever seen. So good that I even applied the fix =) Works now =) Thanks a lot!

fmargueirat commented 7 years ago

I must agree. As a developer, I wish all the bug reports I get were these detailed. Adding the potential solution is a great plus.

On Wed, May 24, 2017 at 10:23 AM, Alex Ustyantsev notifications@github.com wrote:

That is THE BEST bug report I've ever seen. So good that I even applied the fix =) Works now =) Thanks a lot!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/hudbrog/gCodeViewer/issues/49#issuecomment-303739445, or mute the thread https://github.com/notifications/unsubscribe-auth/AHNp40y1VcV9Zteqiwxt1OafK0wdyah1ks5r9D1ygaJpZM4NlKwy .