-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
New Meshline #11040
New Meshline #11040
Conversation
You're such a life saver! ❤️ |
What do you think about make this transparent though? So if We'll have to lose |
After some research i was not able to find a nice integration of both approaches. But to be honest, i don't know all parts of Therefore i would propose something different 😅.
|
As this is screen space implementation it won't work properly when using WebVR. That's why I needed to create a actual geometry mesh line for a-painter.
Actually for me is also confusing the name |
examples/webgl_meshline.html
Outdated
|
||
var object = scene.children[ i ]; | ||
|
||
if ( object instanceof THREE.Line ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
THREE.MeshLine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
examples/webgl_meshline.html
Outdated
|
||
// animate line width | ||
|
||
material1.meshLineWidth = 10 * ( 1 + 0.5 * Math.sin( 5 * time ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
material2.meshLineWidth = 100 * ( 1 + 0.5 * Math.sin( 5 * time ) );
Suggestion. Vary material2
instead, and use OrbitControls
. It is easier to zoom and see the subtitles of what is going on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100 *
please so it is visible on small devices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps also set size attenuation on the first one.
What are the units of width
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sry, overlooked the 100 * thing. I've also added size attenuation to the first material.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meshLineWidth
should be equal to the value of gl.lineWidth()
so it's pixel...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this. You can change it later if you want. For now, it is helpful. :)
I'm not sure about the way how to handle different line implementations. We could create separate entities like @fernandojsg, @WestLangley What's your opinion about this? |
What's the actual problem in this case?
Can you share the code for this? I am interested to see your solution 😊 |
I am not sure
|
He's probably creating a tube. Which makes me think that we could also create a tube too.. |
If it is consistent with THREE.Points, then fine. If not, we should figure out why. Also consider DPR. |
Thinking about names I like @WestLangley proposal for I'll try to open a PR for the |
We used to have |
It's not a Ribbon, either, if we're being technical. I'm afraid you're trying to cram way too functionality in Line: WebGL Lines are mathematical lines, and there's the unfortunate problem with lineWidth across platforms, which makes sense, since the definition of a line is precisely that doesn't have breadth or thickness. That's the main and only thing to solve for a Line replacement (and it could be built into the THREE.Line family transparently). Other stuff, like adding properties from other materials or rendering lines in VR (what does that even mean!), it should just be a Mesh, any Mesh: CurvePath, ShapePath, Ribbon, what have you. Just my two cents. |
Agreed. I think we should leave the VR use case out of this discussion. We don't want to turn |
So, unless someone else tries it before me, I'll use this code as reference and try to add support for |
Sounds good to me. If i can manage it, i'll have a look at the integration of the code into |
Ok I agree, it sound good to me too, better to leave the " |
@WestLangley That was a good hint! 👍 The last commit makes the line width of |
This is needed to distinguish WebGLProgram instances that use mesh lines from those that don't. This is done based on a so called program code, which is, besides other things, based on the list of known parameter values for the parameters names from the parameter list. If two materials only differ in whether they use mesh lines and the one that doesn't is loaded first, then without this change no new program will be generated if the material with enabled mesh lines is loaded afterwards, which effectively disables mesh lines for this material.
WebGLProgram: add meshLine to list of parameter names
I think a too small sampling rate causes issues when calculating the line extrusions in the vertex shader. |
see #11349 |
This PR introduces a new and flexible way of drawing lines via Screen-Space Projected Lines. The implementation is based on https://github.com/spite/THREE.MeshLine by @spite.
Demo
You can create a mesh line like this:
geometry
can be aGeometry
orBufferGeometry
. Users can provide vertices (position) and color data (for vertex colors).material
must be aMeshBasicMaterial
. It's the only material that is supported right now. You can use three new material properties to control the visual appearance of the line:meshLine
(likemorphTargets
) ,meshLineWidth
,meshLineSizeAttenuation
. Other material properties likecolor
,transparent
oropacity
also work.MeshLine
that can be used to create nice curve shapes (widthCallback
).As soon as we commit to a final API design and naming conventions, i will also create some docs with a subsequent PR.
There is still an open issue. I'm not sure how to handle the situation if the geometry of a mesh line changes.
MeshLine
always needs to process the given geometry to prepare the data for the vertex shader. The original MeshLine project does this with a separate methodsetGeometry
. But i wonder if we can find a way that fits better to the library conventions and is maybe more convenient.