Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to make gcode in a LineTubeGeometry have different radius #6

Open
jane-rose opened this issue Apr 6, 2022 · 15 comments

Comments

@jane-rose
Copy link
Contributor

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.
4B8E7F7E-86AB-4C6E-BBB6-5746A8488DA1

@aligator
Copy link
Owner

aligator commented Apr 6, 2022

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

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?

@aligator
Copy link
Owner

aligator commented Apr 6, 2022

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?

@aligator
Copy link
Owner

aligator commented Apr 6, 2022

I implemented an "onAddLine" now:
#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.

@jane-rose
Copy link
Contributor Author

jane-rose commented Apr 7, 2022

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.

@jane-rose
Copy link
Contributor Author

jane-rose commented Apr 7, 2022

Or is there any ways to hide or show some gcode dynamic like using shadermaterial.

@aligator
Copy link
Owner

aligator commented Apr 7, 2022

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:
#9

For now you can try #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 :-)

@jane-rose
Copy link
Contributor Author

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.

@aligator
Copy link
Owner

aligator commented Apr 7, 2022

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.

@jane-rose
Copy link
Contributor Author

jane-rose commented Apr 8, 2022

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.

@aligator
Copy link
Owner

aligator commented Apr 8, 2022

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) :-)

@aligator
Copy link
Owner

aligator commented Apr 8, 2022

I just experimented a bit:
In this PR #9 I added

  1. gcode-line based colorizer + usage example in the example folder
  2. 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 :-)
    Screenshot_2022-04-08_21-23-10

@aligator
Copy link
Owner

aligator commented Apr 8, 2022

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?

@jane-rose
Copy link
Contributor Author

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.

@jane-rose
Copy link
Contributor Author

I just experimented a bit: In this PR #9 I added

  1. gcode-line based colorizer + usage example in the example folder
  2. 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 :-)
    Screenshot_2022-04-08_21-23-10

Your meshObject looks good. My meshObject has a few issue. It will show extra vertices etc.
image
image

@aligator
Copy link
Owner

aligator commented Apr 9, 2022

JFYI: I splitted the custom material experiment into #14 and merged the line colorizer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants