mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
102.1k stars 35.34k forks source link

Extrude with non-uniform steps #2537

Closed tiagocardoso closed 9 years ago

tiagocardoso commented 11 years ago

Hello,

By now, the ExtrudeGeometry can accept a 3D spline and a number of steps. It then uses the steps to subdivide the spline uniformly.

I hope I got this correct.

But there are times that you might use algorithms to form a specific extrude path with corners of curves and straight lines that you don't want to have a uniform splitting, but to user or a array of U's in the step variable or just use explicitly the extrude path points.

Does this make sense to you ? Can we have it :) ?

Thanks in advance.

mrdoob commented 11 years ago

Maybe you could directly hack into the ExtrudeGeometry to get the results you're after?

tiagocardoso commented 11 years ago

Yes, I'm actually using Three.Dart. I'll first make changes in Dart and after make them to three.js. The idea is to not use steps blindly but with some heuristic: On straight line3d always have just 1 set. For curved lines (spline, closedspline, etc..) use the step number. For composed curves (curvepath) multiply the steps by the number of curved lines and add 1 for every straight line.

This will make it necessary to have specific U array with all the steps as they will not be uniform (especially to create the FrenetFrames).

An option would be for the step argument also be able to receive an array with U's so we can know them in advance and be able to create our own frenet frames.

As we go into the future, may change from step to angle tolerant. What do you think ?

mrdoob commented 11 years ago

Sounds good to me, but would be better to see the results and see the benefits. I assume is basically more efficient geometries.

nelsonsilva commented 11 years ago

The "problem" that would be solved by this change is that when you reduce the number of steps you might lose curve "corners" which should always be there. So if you have a path with curves you should always at least try to keep the apexes. This could be solved by setting up a tolerance param but allowing the user to specify an array of steps allows greater control and the changes to the existing code are minimal.