spite / THREE.MeshLine

Mesh replacement for THREE.Line
MIT License
2.14k stars 381 forks source link

Support for clipping planes #33

Open jeremyabel opened 7 years ago

jeremyabel commented 7 years ago

Would be useful I think! (for me at least :P) I can submit a PR if you want.

spite commented 7 years ago

Sounds interesting! How would you do it?

jeremyabel commented 7 years ago

I took a look at the clipping_planes files here: https://github.com/mrdoob/three.js/tree/dev/src/renderers/shaders/ShaderChunk

since I just needed one clipping plane I put this at the top of the main function in the fragment shader:

if ( useClippingPlane == 1.0 && dot( vPosition, clippingPlane.xyz ) > clippingPlane.w ) discard;

useClipplingPlane is a float, clippingPlane is a vec4 where XYZ = plane normal, W = distance from camera

spite commented 7 years ago

Ah, I see! What was your use case?

I'm not sure is useful for every case, may be it could be added under an #ifdef

EmilPoulsen commented 3 years ago

hey @spite @jeremyabel did this go anywhere? clipping planes for the MeshLineMaterial would be extremely useful for something that I'm working on currently.

I'd be happy to put some work into a PR. Any suggestions on where to start, or how to approach it?

jeremyabel commented 3 years ago

The line I posted above on Feb 8th 2017 should still work

EmilPoulsen commented 3 years ago

ok, thanks @jeremyabel!

would be nice if that could be picked up by a MeshLineMaterial.clippingPlanes property, similar to the other material types.. any thoughts on how that would work?

Cheers