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
TubeGeometry: Added parametric radius via THREE.Path. #13971
Conversation
Such a change will require a change to the computed normals, too. |
Right... might be easier to call .computeVertexNormals afterwards? |
That is a problem do to the seams -- in @Mugen87 I expect |
Sharing vertices might cause problems with uv-coordinates. I'm not sure this approach will work for |
Rats. I forgot So the solution must be the analytic one. |
Yes, this is a cool feature. :-) You should see a clearly-visible seam if you reduce You can also use |
How about specifying Here is my hack to compute the adjusted normal. var P = new Vector3();
var P1 = new Vector3();
var P2 = new Vector3();
...
// normal
normal.x = ( cos * N.x + sin * B.x );
normal.y = ( cos * N.y + sin * B.y );
normal.z = ( cos * N.z + sin * B.z );
normal.normalize();
if ( radius instanceof Function ) {
var delta = 0.0001;
var t1 = i / tubularSegments - delta;
var t2 = i / tubularSegments + delta;
// Capping in case of danger
if ( t1 < 0 ) t1 = 0;
if ( t2 > 1 ) t2 = 1;
P1 = path.getPointAt( t1, P1 );
P2 = path.getPointAt( t2, P2 );
var delta = P1.distanceTo( P2 );
var r1 = radius( t1 );
var r2 = radius( t2 );
normal.addScaledVector( T, - ( r2 - r1 ) / delta ).normalize();
} |
@Mugen87 This pattern is unfortunate... P1 = path.getPointAt( t1, P1 ); If the function accepts a target, it can be path.getPointAt( t1, P1 ); If not, then it must be P1 = path.getPointAt( t1 ); So we have to write it to accommodate both... |
@WestLangley my version of this takes a number or a function as radius, but @mrdoob said it couldn't be like that because it couldn't be serialised. So I have another version which takes an array of values, but that's cumbersome. Path has the most flexibility of all |
@spite OK. The math I posted to compute the normal can be easily modified to accommodate |
We still have to adjust the documentation of |
will this be ever merged in the master? |
The PR is not yet complete since it's also necessary to add serialization/deserialization and update the docs/TS file. Besides, I'm not sure we really need this feature. In the meanwhile, I tend to keep the geometry generators as simple as possible. @mrdoob has to decide what he prefers. |
@benjaminadrom do what i do if you really need that feature: import it as another type of Geometry (like ParametricTubeGeometry) and use it instead of the default TubeGeometry |
Thanks a lot for your suggestion, |
The idea was that you create yourself a custom class with the code from this PR. |
|
For variable radius along the tube geometry (like the old taper, but with more control using a Path). Still works with a number, and it should be serialisable.