|
@@ -17,8 +17,6 @@
|
|
|
* extrudePath: <THREE.CurvePath> // 3d spline path to extrude shape along. (creates Frames if .frames aren't defined)
|
|
|
* frames: <THREE.TubeGeometry.FrenetFrames> // containing arrays of tangents, normals, binormals
|
|
|
*
|
|
|
- * material: <int> // material index for front and back faces
|
|
|
- * extrudeMaterial: <int> // material index for extrusion and beveled faces
|
|
|
* uvGenerator: <Object> // object that provides UV generator functions
|
|
|
*
|
|
|
* }
|
|
@@ -80,9 +78,6 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
|
|
|
var extrudePath = options.extrudePath;
|
|
|
var extrudePts, extrudeByPath = false;
|
|
|
|
|
|
- var material = options.material;
|
|
|
- var extrudeMaterial = options.extrudeMaterial;
|
|
|
-
|
|
|
// Use default WorldUVGenerator if no UV generators are specified.
|
|
|
var uvgen = options.UVGenerator !== undefined ? options.UVGenerator : THREE.ExtrudeGeometry.WorldUVGenerator;
|
|
|
|
|
@@ -190,14 +185,14 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
|
|
|
function getBevelVec( inPt, inPrev, inNext ) {
|
|
|
|
|
|
var EPSILON = 0.0000000001;
|
|
|
-
|
|
|
+
|
|
|
// computes for inPt the corresponding point inPt' on a new contour
|
|
|
// shiftet by 1 unit (length of normalized vector) to the left
|
|
|
// if we walk along contour clockwise, this new contour is outside the old one
|
|
|
//
|
|
|
// inPt' is the intersection of the two lines parallel to the two
|
|
|
// adjacent edges of inPt at a distance of 1 unit on the left side.
|
|
|
-
|
|
|
+
|
|
|
var v_trans_x, v_trans_y, shrink_by = 1; // resulting translation vector for inPt
|
|
|
|
|
|
// good reading for geometry algorithms (here: line-line intersection)
|
|
@@ -205,38 +200,38 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
|
|
|
|
|
|
var v_prev_x = inPt.x - inPrev.x, v_prev_y = inPt.y - inPrev.y;
|
|
|
var v_next_x = inNext.x - inPt.x, v_next_y = inNext.y - inPt.y;
|
|
|
-
|
|
|
+
|
|
|
var v_prev_lensq = ( v_prev_x * v_prev_x + v_prev_y * v_prev_y );
|
|
|
-
|
|
|
+
|
|
|
// check for colinear edges
|
|
|
var colinear0 = ( v_prev_x * v_next_y - v_prev_y * v_next_x );
|
|
|
-
|
|
|
+
|
|
|
if ( Math.abs( colinear0 ) > EPSILON ) { // not colinear
|
|
|
-
|
|
|
+
|
|
|
// length of vectors for normalizing
|
|
|
-
|
|
|
+
|
|
|
var v_prev_len = Math.sqrt( v_prev_lensq );
|
|
|
var v_next_len = Math.sqrt( v_next_x * v_next_x + v_next_y * v_next_y );
|
|
|
-
|
|
|
+
|
|
|
// shift adjacent points by unit vectors to the left
|
|
|
-
|
|
|
+
|
|
|
var ptPrevShift_x = ( inPrev.x - v_prev_y / v_prev_len );
|
|
|
var ptPrevShift_y = ( inPrev.y + v_prev_x / v_prev_len );
|
|
|
-
|
|
|
+
|
|
|
var ptNextShift_x = ( inNext.x - v_next_y / v_next_len );
|
|
|
var ptNextShift_y = ( inNext.y + v_next_x / v_next_len );
|
|
|
-
|
|
|
+
|
|
|
// scaling factor for v_prev to intersection point
|
|
|
-
|
|
|
+
|
|
|
var sf = ( ( ptNextShift_x - ptPrevShift_x ) * v_next_y -
|
|
|
( ptNextShift_y - ptPrevShift_y ) * v_next_x ) /
|
|
|
( v_prev_x * v_next_y - v_prev_y * v_next_x );
|
|
|
-
|
|
|
+
|
|
|
// vector from inPt to intersection point
|
|
|
-
|
|
|
+
|
|
|
v_trans_x = ( ptPrevShift_x + v_prev_x * sf - inPt.x );
|
|
|
v_trans_y = ( ptPrevShift_y + v_prev_y * sf - inPt.y );
|
|
|
-
|
|
|
+
|
|
|
// Don't normalize!, otherwise sharp corners become ugly
|
|
|
// but prevent crazy spikes
|
|
|
var v_trans_lensq = ( v_trans_x * v_trans_x + v_trans_y * v_trans_y )
|
|
@@ -245,7 +240,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
|
|
|
} else {
|
|
|
shrink_by = Math.sqrt( v_trans_lensq / 2 );
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
} else { // handle special case of colinear edges
|
|
|
|
|
|
var direction_eq = false; // assumes: opposite
|
|
@@ -592,8 +587,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
|
|
|
b += shapesOffset;
|
|
|
c += shapesOffset;
|
|
|
|
|
|
- // normal, color, material
|
|
|
- scope.faces.push( new THREE.Face3( a, b, c, null, null, material ) );
|
|
|
+ scope.faces.push( new THREE.Face3( a, b, c ) );
|
|
|
|
|
|
var uvs = uvgen.generateTopUV( scope, a, b, c );
|
|
|
|
|
@@ -608,8 +602,8 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
|
|
|
c += shapesOffset;
|
|
|
d += shapesOffset;
|
|
|
|
|
|
- scope.faces.push( new THREE.Face3( a, b, d, null, null, extrudeMaterial ) );
|
|
|
- scope.faces.push( new THREE.Face3( b, c, d, null, null, extrudeMaterial ) );
|
|
|
+ scope.faces.push( new THREE.Face3( a, b, d ) );
|
|
|
+ scope.faces.push( new THREE.Face3( b, c, d ) );
|
|
|
|
|
|
var uvs = uvgen.generateSideWallUV( scope, a, b, c, d );
|
|
|
|