Is there a way to make gcode in a LineTubeGeometry have different radius
See image as below. If we want to display the LineTubeGeometry of the inner wall, hide the line corresponding to the gcode of travel. Change the radius does not work. Thanks.

There is renderer.travelWidth = 0;
which should just hide them

If that's not the case for you, we need to debug it...
How does your filtering work? Does it work when you do not aply any filter?
I think when you filter the lines by just removing them, it will still draw lines between the end and start of the shown segments. But as they are not width=0 (which I use to detect travel lines) they are not treated as such...
Are you filtering by altering the gcode? If so, it may help to just add new travel moves which travel over the skipped lines.
I am also thinking about a hook into the parser, so that you can filter lines directly when they are added, based on the gCode line-numers. Do you think that would help?
I implemented an "onAddLine" now: https://github.com/aligator/gcode-viewer/pull/8
Could you please check if that is sufficient for you? I think if you parse your gcode in advance and know which gcode-lines match which line-types, it should work with that.
I think when you filter the lines by just removing them, it will still draw lines between the end and start of the shown segments. But as they are not width=0 (which I use to detect travel lines) they are not treated as such...
Are you filtering by altering the gcode? If so, it may help to just add new travel moves which travel over the skipped lines.
I am also thinking about a hook into the parser, so that you can filter lines directly when they are added, based on the gCode line-numers. Do you think that would help?
Yeap, cause of the segments. As you said and i thought, adding new travel moves which travel over the skipped lines works.By the way, what's the usage of SegmentColorizer? Cause of i can't use shadermaterial to change color and radius for LineTubeGeometry of the inner wall . I have to generate 7 separate LineTubeGeometry to show all the line types.
Or is there any ways to hide or show some gcode dynamic like using shadermaterial.
Currently the segment colorizer does only supoirt colorizing by the values of the metadata it gets (e.g. speed).
But yesterday I had the idea that the info of the current gcode-line would be helpfull here: https://github.com/aligator/gcode-viewer/pull/9
For now you can try https://github.com/aligator/gcode-viewer/pull/8 to just skip lines based on the gcode line.
I haven't looked into utilizing the shadermaterial yet. But that sounds like the best option... I have to dig into it :-)
But skiping lines still doesn't solve the problem. As u said, it will still draw lines between the last end gcode line and next start gcode line.
if you skip the lines, yes. But not if you set the line radius for these lines to 0.
could you try something like this with the #8:
renderer.onAddLine = (newLine, lineNumber) => {
if (lineNumber > 100 && lineNumber < 30000) {
newLine.radius = 0
return [newLine]
}
return [newLine]
}
Then all skiped lines will just be width 0 and therefore be hidden.
I have to generate 7 separate LineTubeGeometry to show all the line types.
Sorry, I didn't make it clearly. I do known that. But in this way, i have to generate 7 separate LineTubeGeometry with all points to show all the line types geometry. It takes too much times. I have to dig into it to find another way, thanks.
yes, its only a simple work around for now.
It may be possible with an shadermaterial as you suggested, but I have no idea how exactly that would work. If you have any good suggestion, I can add to the lib to allow something like this, just tell me (or create a PR) :-)
I just experimented a bit: In this PR https://github.com/aligator/gcode-viewer/pull/9 I added
- gcode-line based colorizer + usage example in the example folder
- I experimented with adding a custom shader. For now it's just a re-implementation of the PhongMaterial, but with that base it shouldn't be that hard to adapt the fragment and vertex shaders to filter lines.
Then it should be possible to just replace the material without triggering a re-parsing to hide specific parts of the model :-)
ok, I played around with the shaders, but I couldn't realy get something to work. Apparently it is not that trivial to just not render vertices or to use transparency...
I haven't done very much with shaders, yet. I am even not sure if the new attribute gets passed correctly to the shader...
So if you do have some ideas, I am open to them.
Another option may be the combination of #9 and #8. e.g. drawing the different line types by using the gcodeLine information #9 (-> single object) and setting the width to 0 for filtered lines #8. The only drawback I see with that is that you have to re-parse the gcode to rerender the object every time.
What do you think?
Another option may be the combination of #9 and #8. e.g. drawing the different line types by using the gcodeLine information #9 (-> single object) and setting the width to 0 for filtered lines #8. The only drawback I see with that is that you have to re-parse the gcode to rerender the object every time.
What do you think?
It sound good in some case. But re-parsing is not fit me. I will do this as a long term job. Thanks.
I just experimented a bit: In this PR #9 I added
- gcode-line based colorizer + usage example in the example folder
- I experimented with adding a custom shader. For now it's just a re-implementation of the PhongMaterial, but with that base it shouldn't be that hard to adapt the fragment and vertex shaders to filter lines. Then it should be possible to just replace the material without triggering a re-parsing to hide specific parts of the model :-)
![]()
Your meshObject looks good. My meshObject has a few issue. It will show extra vertices etc.

JFYI: I splitted the custom material experiment into https://github.com/aligator/gcode-viewer/pull/14 and merged the line colorizer.