|
@@ -52,10 +52,10 @@ ExtrudeGeometry.prototype.constructor = ExtrudeGeometry;
|
|
|
|
|
|
ExtrudeGeometry.prototype.toJSON = function () {
|
|
|
|
|
|
- var data = Geometry.prototype.toJSON.call( this );
|
|
|
+ const data = Geometry.prototype.toJSON.call( this );
|
|
|
|
|
|
- var shapes = this.parameters.shapes;
|
|
|
- var options = this.parameters.options;
|
|
|
+ const shapes = this.parameters.shapes;
|
|
|
+ const options = this.parameters.options;
|
|
|
|
|
|
return toJSON( shapes, options, data );
|
|
|
|
|
@@ -76,14 +76,14 @@ function ExtrudeBufferGeometry( shapes, options ) {
|
|
|
|
|
|
shapes = Array.isArray( shapes ) ? shapes : [ shapes ];
|
|
|
|
|
|
- var scope = this;
|
|
|
+ const scope = this;
|
|
|
|
|
|
- var verticesArray = [];
|
|
|
- var uvArray = [];
|
|
|
+ const verticesArray = [];
|
|
|
+ const uvArray = [];
|
|
|
|
|
|
- for ( var i = 0, l = shapes.length; i < l; i ++ ) {
|
|
|
+ for ( let i = 0, l = shapes.length; i < l; i ++ ) {
|
|
|
|
|
|
- var shape = shapes[ i ];
|
|
|
+ const shape = shapes[ i ];
|
|
|
addShape( shape );
|
|
|
|
|
|
}
|
|
@@ -99,23 +99,23 @@ function ExtrudeBufferGeometry( shapes, options ) {
|
|
|
|
|
|
function addShape( shape ) {
|
|
|
|
|
|
- var placeholder = [];
|
|
|
+ const placeholder = [];
|
|
|
|
|
|
// options
|
|
|
|
|
|
- var curveSegments = options.curveSegments !== undefined ? options.curveSegments : 12;
|
|
|
- var steps = options.steps !== undefined ? options.steps : 1;
|
|
|
- var depth = options.depth !== undefined ? options.depth : 100;
|
|
|
+ const curveSegments = options.curveSegments !== undefined ? options.curveSegments : 12;
|
|
|
+ const steps = options.steps !== undefined ? options.steps : 1;
|
|
|
+ let depth = options.depth !== undefined ? options.depth : 100;
|
|
|
|
|
|
- var bevelEnabled = options.bevelEnabled !== undefined ? options.bevelEnabled : true;
|
|
|
- var bevelThickness = options.bevelThickness !== undefined ? options.bevelThickness : 6;
|
|
|
- var bevelSize = options.bevelSize !== undefined ? options.bevelSize : bevelThickness - 2;
|
|
|
- var bevelOffset = options.bevelOffset !== undefined ? options.bevelOffset : 0;
|
|
|
- var bevelSegments = options.bevelSegments !== undefined ? options.bevelSegments : 3;
|
|
|
+ let bevelEnabled = options.bevelEnabled !== undefined ? options.bevelEnabled : true;
|
|
|
+ let bevelThickness = options.bevelThickness !== undefined ? options.bevelThickness : 6;
|
|
|
+ let bevelSize = options.bevelSize !== undefined ? options.bevelSize : bevelThickness - 2;
|
|
|
+ let bevelOffset = options.bevelOffset !== undefined ? options.bevelOffset : 0;
|
|
|
+ let bevelSegments = options.bevelSegments !== undefined ? options.bevelSegments : 3;
|
|
|
|
|
|
- var extrudePath = options.extrudePath;
|
|
|
+ const extrudePath = options.extrudePath;
|
|
|
|
|
|
- var uvgen = options.UVGenerator !== undefined ? options.UVGenerator : WorldUVGenerator;
|
|
|
+ const uvgen = options.UVGenerator !== undefined ? options.UVGenerator : WorldUVGenerator;
|
|
|
|
|
|
// deprecated options
|
|
|
|
|
@@ -128,8 +128,8 @@ function ExtrudeBufferGeometry( shapes, options ) {
|
|
|
|
|
|
//
|
|
|
|
|
|
- var extrudePts, extrudeByPath = false;
|
|
|
- var splineTube, binormal, normal, position2;
|
|
|
+ let extrudePts, extrudeByPath = false;
|
|
|
+ let splineTube, binormal, normal, position2;
|
|
|
|
|
|
if ( extrudePath ) {
|
|
|
|
|
@@ -165,14 +165,12 @@ function ExtrudeBufferGeometry( shapes, options ) {
|
|
|
|
|
|
// Variables initialization
|
|
|
|
|
|
- var ahole, h, hl; // looping of holes
|
|
|
+ const shapePoints = shape.extractPoints( curveSegments );
|
|
|
|
|
|
- var shapePoints = shape.extractPoints( curveSegments );
|
|
|
+ let vertices = shapePoints.shape;
|
|
|
+ const holes = shapePoints.holes;
|
|
|
|
|
|
- var vertices = shapePoints.shape;
|
|
|
- var holes = shapePoints.holes;
|
|
|
-
|
|
|
- var reverse = ! ShapeUtils.isClockWise( vertices );
|
|
|
+ const reverse = ! ShapeUtils.isClockWise( vertices );
|
|
|
|
|
|
if ( reverse ) {
|
|
|
|
|
@@ -180,9 +178,9 @@ function ExtrudeBufferGeometry( shapes, options ) {
|
|
|
|
|
|
// Maybe we should also check if holes are in the opposite direction, just to be safe ...
|
|
|
|
|
|
- for ( h = 0, hl = holes.length; h < hl; h ++ ) {
|
|
|
+ for ( let h = 0, hl = holes.length; h < hl; h ++ ) {
|
|
|
|
|
|
- ahole = holes[ h ];
|
|
|
+ const ahole = holes[ h ];
|
|
|
|
|
|
if ( ShapeUtils.isClockWise( ahole ) ) {
|
|
|
|
|
@@ -195,15 +193,15 @@ function ExtrudeBufferGeometry( shapes, options ) {
|
|
|
}
|
|
|
|
|
|
|
|
|
- var faces = ShapeUtils.triangulateShape( vertices, holes );
|
|
|
+ const faces = ShapeUtils.triangulateShape( vertices, holes );
|
|
|
|
|
|
/* Vertices */
|
|
|
|
|
|
- var contour = vertices; // vertices has all points but contour has only points of circumference
|
|
|
+ const contour = vertices; // vertices has all points but contour has only points of circumference
|
|
|
|
|
|
- for ( h = 0, hl = holes.length; h < hl; h ++ ) {
|
|
|
+ for ( let h = 0, hl = holes.length; h < hl; h ++ ) {
|
|
|
|
|
|
- ahole = holes[ h ];
|
|
|
+ const ahole = holes[ h ];
|
|
|
|
|
|
vertices = vertices.concat( ahole );
|
|
|
|
|
@@ -218,9 +216,7 @@ function ExtrudeBufferGeometry( shapes, options ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- var b, bs, t, z,
|
|
|
- vert, vlen = vertices.length,
|
|
|
- face, flen = faces.length;
|
|
|
+ const vlen = vertices.length, flen = faces.length;
|
|
|
|
|
|
|
|
|
// Find directions for point movement
|
|
@@ -235,20 +231,20 @@ function ExtrudeBufferGeometry( shapes, options ) {
|
|
|
// 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; // resulting translation vector for inPt
|
|
|
+ let v_trans_x, v_trans_y, shrink_by; // resulting translation vector for inPt
|
|
|
|
|
|
// good reading for geometry algorithms (here: line-line intersection)
|
|
|
// http://geomalgorithms.com/a05-_intersect-1.html
|
|
|
|
|
|
- var v_prev_x = inPt.x - inPrev.x,
|
|
|
+ const v_prev_x = inPt.x - inPrev.x,
|
|
|
v_prev_y = inPt.y - inPrev.y;
|
|
|
- var v_next_x = inNext.x - inPt.x,
|
|
|
+ const 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 );
|
|
|
+ const v_prev_lensq = ( v_prev_x * v_prev_x + v_prev_y * v_prev_y );
|
|
|
|
|
|
// check for collinear edges
|
|
|
- var collinear0 = ( v_prev_x * v_next_y - v_prev_y * v_next_x );
|
|
|
+ const collinear0 = ( v_prev_x * v_next_y - v_prev_y * v_next_x );
|
|
|
|
|
|
if ( Math.abs( collinear0 ) > Number.EPSILON ) {
|
|
|
|
|
@@ -256,20 +252,20 @@ function ExtrudeBufferGeometry( shapes, options ) {
|
|
|
|
|
|
// 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 );
|
|
|
+ const v_prev_len = Math.sqrt( v_prev_lensq );
|
|
|
+ const 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 );
|
|
|
+ const ptPrevShift_x = ( inPrev.x - v_prev_y / v_prev_len );
|
|
|
+ const 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 );
|
|
|
+ const ptNextShift_x = ( inNext.x - v_next_y / v_next_len );
|
|
|
+ const 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 -
|
|
|
+ const 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 );
|
|
|
|
|
@@ -280,7 +276,7 @@ function ExtrudeBufferGeometry( shapes, options ) {
|
|
|
|
|
|
// 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 );
|
|
|
+ const v_trans_lensq = ( v_trans_x * v_trans_x + v_trans_y * v_trans_y );
|
|
|
if ( v_trans_lensq <= 2 ) {
|
|
|
|
|
|
return new Vector2( v_trans_x, v_trans_y );
|
|
@@ -295,7 +291,8 @@ function ExtrudeBufferGeometry( shapes, options ) {
|
|
|
|
|
|
// handle special case of collinear edges
|
|
|
|
|
|
- var direction_eq = false; // assumes: opposite
|
|
|
+ let direction_eq = false; // assumes: opposite
|
|
|
+
|
|
|
if ( v_prev_x > Number.EPSILON ) {
|
|
|
|
|
|
if ( v_next_x > Number.EPSILON ) {
|
|
@@ -349,9 +346,9 @@ function ExtrudeBufferGeometry( shapes, options ) {
|
|
|
}
|
|
|
|
|
|
|
|
|
- var contourMovements = [];
|
|
|
+ const contourMovements = [];
|
|
|
|
|
|
- for ( var i = 0, il = contour.length, j = il - 1, k = i + 1; i < il; i ++, j ++, k ++ ) {
|
|
|
+ for ( let i = 0, il = contour.length, j = il - 1, k = i + 1; i < il; i ++, j ++, k ++ ) {
|
|
|
|
|
|
if ( j === il ) j = 0;
|
|
|
if ( k === il ) k = 0;
|
|
@@ -363,16 +360,16 @@ function ExtrudeBufferGeometry( shapes, options ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- var holesMovements = [],
|
|
|
- oneHoleMovements, verticesMovements = contourMovements.concat();
|
|
|
+ const holesMovements = [];
|
|
|
+ let oneHoleMovements, verticesMovements = contourMovements.concat();
|
|
|
|
|
|
- for ( h = 0, hl = holes.length; h < hl; h ++ ) {
|
|
|
+ for ( let h = 0, hl = holes.length; h < hl; h ++ ) {
|
|
|
|
|
|
- ahole = holes[ h ];
|
|
|
+ const ahole = holes[ h ];
|
|
|
|
|
|
oneHoleMovements = [];
|
|
|
|
|
|
- for ( i = 0, il = ahole.length, j = il - 1, k = i + 1; i < il; i ++, j ++, k ++ ) {
|
|
|
+ for ( let i = 0, il = ahole.length, j = il - 1, k = i + 1; i < il; i ++, j ++, k ++ ) {
|
|
|
|
|
|
if ( j === il ) j = 0;
|
|
|
if ( k === il ) k = 0;
|
|
@@ -390,19 +387,19 @@ function ExtrudeBufferGeometry( shapes, options ) {
|
|
|
|
|
|
// Loop bevelSegments, 1 for the front, 1 for the back
|
|
|
|
|
|
- for ( b = 0; b < bevelSegments; b ++ ) {
|
|
|
+ for ( let b = 0; b < bevelSegments; b ++ ) {
|
|
|
|
|
|
//for ( b = bevelSegments; b > 0; b -- ) {
|
|
|
|
|
|
- t = b / bevelSegments;
|
|
|
- z = bevelThickness * Math.cos( t * Math.PI / 2 );
|
|
|
- bs = bevelSize * Math.sin( t * Math.PI / 2 ) + bevelOffset;
|
|
|
+ const t = b / bevelSegments;
|
|
|
+ const z = bevelThickness * Math.cos( t * Math.PI / 2 );
|
|
|
+ const bs = bevelSize * Math.sin( t * Math.PI / 2 ) + bevelOffset;
|
|
|
|
|
|
// contract shape
|
|
|
|
|
|
- for ( i = 0, il = contour.length; i < il; i ++ ) {
|
|
|
+ for ( let i = 0, il = contour.length; i < il; i ++ ) {
|
|
|
|
|
|
- vert = scalePt2( contour[ i ], contourMovements[ i ], bs );
|
|
|
+ const vert = scalePt2( contour[ i ], contourMovements[ i ], bs );
|
|
|
|
|
|
v( vert.x, vert.y, - z );
|
|
|
|
|
@@ -410,14 +407,14 @@ function ExtrudeBufferGeometry( shapes, options ) {
|
|
|
|
|
|
// expand holes
|
|
|
|
|
|
- for ( h = 0, hl = holes.length; h < hl; h ++ ) {
|
|
|
+ for ( let h = 0, hl = holes.length; h < hl; h ++ ) {
|
|
|
|
|
|
- ahole = holes[ h ];
|
|
|
+ const ahole = holes[ h ];
|
|
|
oneHoleMovements = holesMovements[ h ];
|
|
|
|
|
|
- for ( i = 0, il = ahole.length; i < il; i ++ ) {
|
|
|
+ for ( let i = 0, il = ahole.length; i < il; i ++ ) {
|
|
|
|
|
|
- vert = scalePt2( ahole[ i ], oneHoleMovements[ i ], bs );
|
|
|
+ const vert = scalePt2( ahole[ i ], oneHoleMovements[ i ], bs );
|
|
|
|
|
|
v( vert.x, vert.y, - z );
|
|
|
|
|
@@ -427,13 +424,13 @@ function ExtrudeBufferGeometry( shapes, options ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- bs = bevelSize + bevelOffset;
|
|
|
+ const bs = bevelSize + bevelOffset;
|
|
|
|
|
|
// Back facing vertices
|
|
|
|
|
|
- for ( i = 0; i < vlen; i ++ ) {
|
|
|
+ for ( let i = 0; i < vlen; i ++ ) {
|
|
|
|
|
|
- vert = bevelEnabled ? scalePt2( vertices[ i ], verticesMovements[ i ], bs ) : vertices[ i ];
|
|
|
+ const vert = bevelEnabled ? scalePt2( vertices[ i ], verticesMovements[ i ], bs ) : vertices[ i ];
|
|
|
|
|
|
if ( ! extrudeByPath ) {
|
|
|
|
|
@@ -457,13 +454,11 @@ function ExtrudeBufferGeometry( shapes, options ) {
|
|
|
// Add stepped vertices...
|
|
|
// Including front facing vertices
|
|
|
|
|
|
- var s;
|
|
|
+ for ( let s = 1; s <= steps; s ++ ) {
|
|
|
|
|
|
- for ( s = 1; s <= steps; s ++ ) {
|
|
|
+ for ( let i = 0; i < vlen; i ++ ) {
|
|
|
|
|
|
- for ( i = 0; i < vlen; i ++ ) {
|
|
|
-
|
|
|
- vert = bevelEnabled ? scalePt2( vertices[ i ], verticesMovements[ i ], bs ) : vertices[ i ];
|
|
|
+ const vert = bevelEnabled ? scalePt2( vertices[ i ], verticesMovements[ i ], bs ) : vertices[ i ];
|
|
|
|
|
|
if ( ! extrudeByPath ) {
|
|
|
|
|
@@ -490,31 +485,31 @@ function ExtrudeBufferGeometry( shapes, options ) {
|
|
|
// Add bevel segments planes
|
|
|
|
|
|
//for ( b = 1; b <= bevelSegments; b ++ ) {
|
|
|
- for ( b = bevelSegments - 1; b >= 0; b -- ) {
|
|
|
+ for ( let b = bevelSegments - 1; b >= 0; b -- ) {
|
|
|
|
|
|
- t = b / bevelSegments;
|
|
|
- z = bevelThickness * Math.cos( t * Math.PI / 2 );
|
|
|
- bs = bevelSize * Math.sin( t * Math.PI / 2 ) + bevelOffset;
|
|
|
+ const t = b / bevelSegments;
|
|
|
+ const z = bevelThickness * Math.cos( t * Math.PI / 2 );
|
|
|
+ const bs = bevelSize * Math.sin( t * Math.PI / 2 ) + bevelOffset;
|
|
|
|
|
|
// contract shape
|
|
|
|
|
|
- for ( i = 0, il = contour.length; i < il; i ++ ) {
|
|
|
+ for ( let i = 0, il = contour.length; i < il; i ++ ) {
|
|
|
|
|
|
- vert = scalePt2( contour[ i ], contourMovements[ i ], bs );
|
|
|
+ const vert = scalePt2( contour[ i ], contourMovements[ i ], bs );
|
|
|
v( vert.x, vert.y, depth + z );
|
|
|
|
|
|
}
|
|
|
|
|
|
// expand holes
|
|
|
|
|
|
- for ( h = 0, hl = holes.length; h < hl; h ++ ) {
|
|
|
+ for ( let h = 0, hl = holes.length; h < hl; h ++ ) {
|
|
|
|
|
|
- ahole = holes[ h ];
|
|
|
+ const ahole = holes[ h ];
|
|
|
oneHoleMovements = holesMovements[ h ];
|
|
|
|
|
|
- for ( i = 0, il = ahole.length; i < il; i ++ ) {
|
|
|
+ for ( let i = 0, il = ahole.length; i < il; i ++ ) {
|
|
|
|
|
|
- vert = scalePt2( ahole[ i ], oneHoleMovements[ i ], bs );
|
|
|
+ const vert = scalePt2( ahole[ i ], oneHoleMovements[ i ], bs );
|
|
|
|
|
|
if ( ! extrudeByPath ) {
|
|
|
|
|
@@ -547,18 +542,18 @@ function ExtrudeBufferGeometry( shapes, options ) {
|
|
|
|
|
|
function buildLidFaces() {
|
|
|
|
|
|
- var start = verticesArray.length / 3;
|
|
|
+ const start = verticesArray.length / 3;
|
|
|
|
|
|
if ( bevelEnabled ) {
|
|
|
|
|
|
- var layer = 0; // steps + 1
|
|
|
- var offset = vlen * layer;
|
|
|
+ let layer = 0; // steps + 1
|
|
|
+ let offset = vlen * layer;
|
|
|
|
|
|
// Bottom faces
|
|
|
|
|
|
- for ( i = 0; i < flen; i ++ ) {
|
|
|
+ for ( let i = 0; i < flen; i ++ ) {
|
|
|
|
|
|
- face = faces[ i ];
|
|
|
+ const face = faces[ i ];
|
|
|
f3( face[ 2 ] + offset, face[ 1 ] + offset, face[ 0 ] + offset );
|
|
|
|
|
|
}
|
|
@@ -568,9 +563,9 @@ function ExtrudeBufferGeometry( shapes, options ) {
|
|
|
|
|
|
// Top faces
|
|
|
|
|
|
- for ( i = 0; i < flen; i ++ ) {
|
|
|
+ for ( let i = 0; i < flen; i ++ ) {
|
|
|
|
|
|
- face = faces[ i ];
|
|
|
+ const face = faces[ i ];
|
|
|
f3( face[ 0 ] + offset, face[ 1 ] + offset, face[ 2 ] + offset );
|
|
|
|
|
|
}
|
|
@@ -579,18 +574,18 @@ function ExtrudeBufferGeometry( shapes, options ) {
|
|
|
|
|
|
// Bottom faces
|
|
|
|
|
|
- for ( i = 0; i < flen; i ++ ) {
|
|
|
+ for ( let i = 0; i < flen; i ++ ) {
|
|
|
|
|
|
- face = faces[ i ];
|
|
|
+ const face = faces[ i ];
|
|
|
f3( face[ 2 ], face[ 1 ], face[ 0 ] );
|
|
|
|
|
|
}
|
|
|
|
|
|
// Top faces
|
|
|
|
|
|
- for ( i = 0; i < flen; i ++ ) {
|
|
|
+ for ( let i = 0; i < flen; i ++ ) {
|
|
|
|
|
|
- face = faces[ i ];
|
|
|
+ const face = faces[ i ];
|
|
|
f3( face[ 0 ] + vlen * steps, face[ 1 ] + vlen * steps, face[ 2 ] + vlen * steps );
|
|
|
|
|
|
}
|
|
@@ -605,14 +600,14 @@ function ExtrudeBufferGeometry( shapes, options ) {
|
|
|
|
|
|
function buildSideFaces() {
|
|
|
|
|
|
- var start = verticesArray.length / 3;
|
|
|
- var layeroffset = 0;
|
|
|
+ const start = verticesArray.length / 3;
|
|
|
+ let layeroffset = 0;
|
|
|
sidewalls( contour, layeroffset );
|
|
|
layeroffset += contour.length;
|
|
|
|
|
|
- for ( h = 0, hl = holes.length; h < hl; h ++ ) {
|
|
|
+ for ( let h = 0, hl = holes.length; h < hl; h ++ ) {
|
|
|
|
|
|
- ahole = holes[ h ];
|
|
|
+ const ahole = holes[ h ];
|
|
|
sidewalls( ahole, layeroffset );
|
|
|
|
|
|
//, true
|
|
@@ -628,26 +623,22 @@ function ExtrudeBufferGeometry( shapes, options ) {
|
|
|
|
|
|
function sidewalls( contour, layeroffset ) {
|
|
|
|
|
|
- var j, k;
|
|
|
- i = contour.length;
|
|
|
+ let i = contour.length;
|
|
|
|
|
|
while ( -- i >= 0 ) {
|
|
|
|
|
|
- j = i;
|
|
|
- k = i - 1;
|
|
|
+ const j = i;
|
|
|
+ let k = i - 1;
|
|
|
if ( k < 0 ) k = contour.length - 1;
|
|
|
|
|
|
//console.log('b', i,j, i-1, k,vertices.length);
|
|
|
|
|
|
- var s = 0,
|
|
|
- sl = steps + bevelSegments * 2;
|
|
|
-
|
|
|
- for ( s = 0; s < sl; s ++ ) {
|
|
|
+ for ( let s = 0, sl = ( steps + bevelSegments * 2 ); s < sl; s ++ ) {
|
|
|
|
|
|
- var slen1 = vlen * s;
|
|
|
- var slen2 = vlen * ( s + 1 );
|
|
|
+ const slen1 = vlen * s;
|
|
|
+ const slen2 = vlen * ( s + 1 );
|
|
|
|
|
|
- var a = layeroffset + j + slen1,
|
|
|
+ const a = layeroffset + j + slen1,
|
|
|
b = layeroffset + k + slen1,
|
|
|
c = layeroffset + k + slen2,
|
|
|
d = layeroffset + j + slen2;
|
|
@@ -675,8 +666,8 @@ function ExtrudeBufferGeometry( shapes, options ) {
|
|
|
addVertex( b );
|
|
|
addVertex( c );
|
|
|
|
|
|
- var nextIndex = verticesArray.length / 3;
|
|
|
- var uvs = uvgen.generateTopUV( scope, verticesArray, nextIndex - 3, nextIndex - 2, nextIndex - 1 );
|
|
|
+ const nextIndex = verticesArray.length / 3;
|
|
|
+ const uvs = uvgen.generateTopUV( scope, verticesArray, nextIndex - 3, nextIndex - 2, nextIndex - 1 );
|
|
|
|
|
|
addUV( uvs[ 0 ] );
|
|
|
addUV( uvs[ 1 ] );
|
|
@@ -695,8 +686,8 @@ function ExtrudeBufferGeometry( shapes, options ) {
|
|
|
addVertex( d );
|
|
|
|
|
|
|
|
|
- var nextIndex = verticesArray.length / 3;
|
|
|
- var uvs = uvgen.generateSideWallUV( scope, verticesArray, nextIndex - 6, nextIndex - 3, nextIndex - 2, nextIndex - 1 );
|
|
|
+ const nextIndex = verticesArray.length / 3;
|
|
|
+ const uvs = uvgen.generateSideWallUV( scope, verticesArray, nextIndex - 6, nextIndex - 3, nextIndex - 2, nextIndex - 1 );
|
|
|
|
|
|
addUV( uvs[ 0 ] );
|
|
|
addUV( uvs[ 1 ] );
|
|
@@ -733,10 +724,10 @@ ExtrudeBufferGeometry.prototype.constructor = ExtrudeBufferGeometry;
|
|
|
|
|
|
ExtrudeBufferGeometry.prototype.toJSON = function () {
|
|
|
|
|
|
- var data = BufferGeometry.prototype.toJSON.call( this );
|
|
|
+ const data = BufferGeometry.prototype.toJSON.call( this );
|
|
|
|
|
|
- var shapes = this.parameters.shapes;
|
|
|
- var options = this.parameters.options;
|
|
|
+ const shapes = this.parameters.shapes;
|
|
|
+ const options = this.parameters.options;
|
|
|
|
|
|
return toJSON( shapes, options, data );
|
|
|
|
|
@@ -744,16 +735,16 @@ ExtrudeBufferGeometry.prototype.toJSON = function () {
|
|
|
|
|
|
//
|
|
|
|
|
|
-var WorldUVGenerator = {
|
|
|
+const WorldUVGenerator = {
|
|
|
|
|
|
generateTopUV: function ( geometry, vertices, indexA, indexB, indexC ) {
|
|
|
|
|
|
- var a_x = vertices[ indexA * 3 ];
|
|
|
- var a_y = vertices[ indexA * 3 + 1 ];
|
|
|
- var b_x = vertices[ indexB * 3 ];
|
|
|
- var b_y = vertices[ indexB * 3 + 1 ];
|
|
|
- var c_x = vertices[ indexC * 3 ];
|
|
|
- var c_y = vertices[ indexC * 3 + 1 ];
|
|
|
+ const a_x = vertices[ indexA * 3 ];
|
|
|
+ const a_y = vertices[ indexA * 3 + 1 ];
|
|
|
+ const b_x = vertices[ indexB * 3 ];
|
|
|
+ const b_y = vertices[ indexB * 3 + 1 ];
|
|
|
+ const c_x = vertices[ indexC * 3 ];
|
|
|
+ const c_y = vertices[ indexC * 3 + 1 ];
|
|
|
|
|
|
return [
|
|
|
new Vector2( a_x, a_y ),
|
|
@@ -765,18 +756,18 @@ var WorldUVGenerator = {
|
|
|
|
|
|
generateSideWallUV: function ( geometry, vertices, indexA, indexB, indexC, indexD ) {
|
|
|
|
|
|
- var a_x = vertices[ indexA * 3 ];
|
|
|
- var a_y = vertices[ indexA * 3 + 1 ];
|
|
|
- var a_z = vertices[ indexA * 3 + 2 ];
|
|
|
- var b_x = vertices[ indexB * 3 ];
|
|
|
- var b_y = vertices[ indexB * 3 + 1 ];
|
|
|
- var b_z = vertices[ indexB * 3 + 2 ];
|
|
|
- var c_x = vertices[ indexC * 3 ];
|
|
|
- var c_y = vertices[ indexC * 3 + 1 ];
|
|
|
- var c_z = vertices[ indexC * 3 + 2 ];
|
|
|
- var d_x = vertices[ indexD * 3 ];
|
|
|
- var d_y = vertices[ indexD * 3 + 1 ];
|
|
|
- var d_z = vertices[ indexD * 3 + 2 ];
|
|
|
+ const a_x = vertices[ indexA * 3 ];
|
|
|
+ const a_y = vertices[ indexA * 3 + 1 ];
|
|
|
+ const a_z = vertices[ indexA * 3 + 2 ];
|
|
|
+ const b_x = vertices[ indexB * 3 ];
|
|
|
+ const b_y = vertices[ indexB * 3 + 1 ];
|
|
|
+ const b_z = vertices[ indexB * 3 + 2 ];
|
|
|
+ const c_x = vertices[ indexC * 3 ];
|
|
|
+ const c_y = vertices[ indexC * 3 + 1 ];
|
|
|
+ const c_z = vertices[ indexC * 3 + 2 ];
|
|
|
+ const d_x = vertices[ indexD * 3 ];
|
|
|
+ const d_y = vertices[ indexD * 3 + 1 ];
|
|
|
+ const d_z = vertices[ indexD * 3 + 2 ];
|
|
|
|
|
|
if ( Math.abs( a_y - b_y ) < 0.01 ) {
|
|
|
|
|
@@ -809,9 +800,9 @@ function toJSON( shapes, options, data ) {
|
|
|
|
|
|
if ( Array.isArray( shapes ) ) {
|
|
|
|
|
|
- for ( var i = 0, l = shapes.length; i < l; i ++ ) {
|
|
|
+ for ( let i = 0, l = shapes.length; i < l; i ++ ) {
|
|
|
|
|
|
- var shape = shapes[ i ];
|
|
|
+ const shape = shapes[ i ];
|
|
|
|
|
|
data.shapes.push( shape.uuid );
|
|
|
|