mrdoob / three.js

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

ExtrudeGeometry depth gives different result than extrudePath #5258

Closed Wilt closed 6 years ago

Wilt commented 10 years ago

I use THREE.ExtrudedGeometry in two different ways and I expected the same result.

Once I use the depth to set the extrusion options. Another time I use an extrude path which is a line from Vector3(0, 0, 0) to Vector3(0, 0, depth)

The strange thing is that the resulting geometry is unsuspectingly rotated around the Z-axis. Why is this? Is this expected behavior or am I doing something wrong?

I am not sure if this is an issue or expected behavior, but it confused me. I posted a question with details about the issue here on Stackoverflow: http://stackoverflow.com/questions/25626171/threejs-extrudegeometry-depth-gives-different-result-than-extrudepath

And a fiddle can be found here: http://jsfiddle.net/wilt/yfkd85s8/1/

mrdoob commented 10 years ago

/ping @zz85

WestLangley commented 10 years ago

The algorithm is designed to handle any 3D path, and consequently, the shape must be allowed to "spin" along the length of the path.

In the current algorithm, the orientation of the shape at the initial point of the path is based on the Frenet Frame that is generated at the starting point, and that initial frame is arbitrary.

zz85 commented 10 years ago

as explained on SO, @WestLangley is correct. If extrudePath is specified, ExtrudeGeometry extrudes along any freeform 3d path. The amount of rotation is determined by arrays of tangents, normals, binormals as passed in by any frames parameter. By default, it uses THREE.TubeGeometry.FrenetFrames which picks a starting a starting normal and slowly rotates for adjustments.