mrdoob / three.js

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

Why extrudeGeometry are relate on binormal of spline? #12056

Closed budblack closed 7 years ago

budblack commented 7 years ago

I found code in '/three.js/src/geometries/ExtrudeGeometry.js:464'

normal.copy( splineTube.normals[ 0 ] ).multiplyScalar( vert.x );
binormal.copy( splineTube.binormals[ 0 ] ).multiplyScalar( vert.y );

It means that coordinate in extrud are almost only related the direction of normal and binormal. But not the world coordinate.

In some specical cases, such as pull along Axis X or Z. When Value of x or z changed less than y, binormal towards to horizontal. Value of x or z changed more than y, binormal towards to Vertical.

I think only draw an extrude with a horizontal shape, should we deal it's coordinate carefully. In other time, coordinate of shape should not be relate on normal or binormal of spline.

Mugen87 commented 7 years ago

The mentioned normals and binormals properties of a given extrude path are calculated with Curve .computeFrenetFrames(). These data can be used to define an orthonormal basis for points on the curve, which can be very useful for generating correct extrusions. The theory behind this approach is based on the Frenet–Serret formulas.

budblack commented 7 years ago

Thx a lot. I'v read some papers about it. Now I know there's no contact between extrude's Y direction and world coordinate. Coordinate of a shape (or frames) to an extrude is only related on extrude path's derivative.