THREE.MeshLine icon indicating copy to clipboard operation
THREE.MeshLine copied to clipboard

Support for clipping planes

Open jeremyabel opened this issue 8 years ago • 6 comments

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

jeremyabel avatar Feb 08 '17 18:02 jeremyabel

Sounds interesting! How would you do it?

spite avatar Feb 08 '17 19:02 spite

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

jeremyabel avatar Feb 08 '17 19:02 jeremyabel

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

spite avatar Feb 11 '17 12:02 spite

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?

EmilPoulsen avatar Nov 30 '20 08:11 EmilPoulsen

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

jeremyabel avatar Nov 30 '20 16:11 jeremyabel

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

EmilPoulsen avatar Nov 30 '20 17:11 EmilPoulsen