浏览代码

Geometries: Move to let/const.

Mugen87 5 年之前
父节点
当前提交
02a5f534d2

+ 9 - 10
src/geometries/CircleGeometry.js

@@ -56,16 +56,15 @@ function CircleBufferGeometry( radius, segments, thetaStart, thetaLength ) {
 
 	// buffers
 
-	var indices = [];
-	var vertices = [];
-	var normals = [];
-	var uvs = [];
+	const indices = [];
+	const vertices = [];
+	const normals = [];
+	const uvs = [];
 
 	// helper variables
 
-	var i, s;
-	var vertex = new Vector3();
-	var uv = new Vector2();
+	const vertex = new Vector3();
+	const uv = new Vector2();
 
 	// center point
 
@@ -73,9 +72,9 @@ function CircleBufferGeometry( radius, segments, thetaStart, thetaLength ) {
 	normals.push( 0, 0, 1 );
 	uvs.push( 0.5, 0.5 );
 
-	for ( s = 0, i = 3; s <= segments; s ++, i += 3 ) {
+	for ( let s = 0, i = 3; s <= segments; s ++, i += 3 ) {
 
-		var segment = thetaStart + s / segments * thetaLength;
+		const segment = thetaStart + s / segments * thetaLength;
 
 		// vertex
 
@@ -99,7 +98,7 @@ function CircleBufferGeometry( radius, segments, thetaStart, thetaLength ) {
 
 	// indices
 
-	for ( i = 1; i <= segments; i ++ ) {
+	for ( let i = 1; i <= segments; i ++ ) {
 
 		indices.push( i, i + 1, 0 );
 

+ 43 - 44
src/geometries/CylinderGeometry.js

@@ -55,7 +55,7 @@ function CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments
 		thetaLength: thetaLength
 	};
 
-	var scope = this;
+	const scope = this;
 
 	radiusTop = radiusTop !== undefined ? radiusTop : 1;
 	radiusBottom = radiusBottom !== undefined ? radiusBottom : 1;
@@ -70,17 +70,17 @@ function CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments
 
 	// buffers
 
-	var indices = [];
-	var vertices = [];
-	var normals = [];
-	var uvs = [];
+	const indices = [];
+	const vertices = [];
+	const normals = [];
+	const uvs = [];
 
 	// helper variables
 
-	var index = 0;
-	var indexArray = [];
-	var halfHeight = height / 2;
-	var groupStart = 0;
+	let index = 0;
+	const indexArray = [];
+	const halfHeight = height / 2;
+	let groupStart = 0;
 
 	// generate geometry
 
@@ -102,35 +102,34 @@ function CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments
 
 	function generateTorso() {
 
-		var x, y;
-		var normal = new Vector3();
-		var vertex = new Vector3();
+		const normal = new Vector3();
+		const vertex = new Vector3();
 
-		var groupCount = 0;
+		let groupCount = 0;
 
 		// this will be used to calculate the normal
-		var slope = ( radiusBottom - radiusTop ) / height;
+		const slope = ( radiusBottom - radiusTop ) / height;
 
 		// generate vertices, normals and uvs
 
-		for ( y = 0; y <= heightSegments; y ++ ) {
+		for ( let y = 0; y <= heightSegments; y ++ ) {
 
-			var indexRow = [];
+			const indexRow = [];
 
-			var v = y / heightSegments;
+			const v = y / heightSegments;
 
 			// calculate the radius of the current row
 
-			var radius = v * ( radiusBottom - radiusTop ) + radiusTop;
+			const radius = v * ( radiusBottom - radiusTop ) + radiusTop;
 
-			for ( x = 0; x <= radialSegments; x ++ ) {
+			for ( let x = 0; x <= radialSegments; x ++ ) {
 
-				var u = x / radialSegments;
+				const u = x / radialSegments;
 
-				var theta = u * thetaLength + thetaStart;
+				const theta = u * thetaLength + thetaStart;
 
-				var sinTheta = Math.sin( theta );
-				var cosTheta = Math.cos( theta );
+				const sinTheta = Math.sin( theta );
+				const cosTheta = Math.cos( theta );
 
 				// vertex
 
@@ -162,16 +161,16 @@ function CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments
 
 		// generate indices
 
-		for ( x = 0; x < radialSegments; x ++ ) {
+		for ( let x = 0; x < radialSegments; x ++ ) {
 
-			for ( y = 0; y < heightSegments; y ++ ) {
+			for ( let y = 0; y < heightSegments; y ++ ) {
 
 				// we use the index array to access the correct indices
 
-				var a = indexArray[ y ][ x ];
-				var b = indexArray[ y + 1 ][ x ];
-				var c = indexArray[ y + 1 ][ x + 1 ];
-				var d = indexArray[ y ][ x + 1 ];
+				const a = indexArray[ y ][ x ];
+				const b = indexArray[ y + 1 ][ x ];
+				const c = indexArray[ y + 1 ][ x + 1 ];
+				const d = indexArray[ y ][ x + 1 ];
 
 				// faces
 
@@ -198,15 +197,15 @@ function CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments
 
 	function generateCap( top ) {
 
-		var x, centerIndexStart, centerIndexEnd;
+		let centerIndexStart, centerIndexEnd;
 
-		var uv = new Vector2();
-		var vertex = new Vector3();
+		const uv = new Vector2();
+		const vertex = new Vector3();
 
-		var groupCount = 0;
+		let groupCount = 0;
 
-		var radius = ( top === true ) ? radiusTop : radiusBottom;
-		var sign = ( top === true ) ? 1 : - 1;
+		const radius = ( top === true ) ? radiusTop : radiusBottom;
+		const sign = ( top === true ) ? 1 : - 1;
 
 		// save the index of the first center vertex
 		centerIndexStart = index;
@@ -215,7 +214,7 @@ function CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments
 		// because the geometry needs one set of uvs per face,
 		// we must generate a center vertex per face/segment
 
-		for ( x = 1; x <= radialSegments; x ++ ) {
+		for ( let x = 1; x <= radialSegments; x ++ ) {
 
 			// vertex
 
@@ -241,13 +240,13 @@ function CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments
 
 		// now we generate the surrounding vertices, normals and uvs
 
-		for ( x = 0; x <= radialSegments; x ++ ) {
+		for ( let x = 0; x <= radialSegments; x ++ ) {
 
-			var u = x / radialSegments;
-			var theta = u * thetaLength + thetaStart;
+			const u = x / radialSegments;
+			const theta = u * thetaLength + thetaStart;
 
-			var cosTheta = Math.cos( theta );
-			var sinTheta = Math.sin( theta );
+			const cosTheta = Math.cos( theta );
+			const sinTheta = Math.sin( theta );
 
 			// vertex
 
@@ -274,10 +273,10 @@ function CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments
 
 		// generate indices
 
-		for ( x = 0; x < radialSegments; x ++ ) {
+		for ( let x = 0; x < radialSegments; x ++ ) {
 
-			var c = centerIndexStart + x;
-			var i = centerIndexEnd + x;
+			const c = centerIndexStart + x;
+			const i = centerIndexEnd + x;
 
 			if ( top === true ) {
 

+ 4 - 4
src/geometries/DodecahedronGeometry.js

@@ -31,10 +31,10 @@ DodecahedronGeometry.prototype.constructor = DodecahedronGeometry;
 
 function DodecahedronBufferGeometry( radius, detail ) {
 
-	var t = ( 1 + Math.sqrt( 5 ) ) / 2;
-	var r = 1 / t;
+	const t = ( 1 + Math.sqrt( 5 ) ) / 2;
+	const r = 1 / t;
 
-	var vertices = [
+	const vertices = [
 
 		// (±1, ±1, ±1)
 		- 1, - 1, - 1,	- 1, - 1, 1,
@@ -55,7 +55,7 @@ function DodecahedronBufferGeometry( radius, detail ) {
 		- t, 0, r, t, 0, r
 	];
 
-	var indices = [
+	const indices = [
 		3, 11, 7, 	3, 7, 15, 	3, 15, 13,
 		7, 19, 17, 	7, 17, 6, 	7, 6, 15,
 		17, 4, 8, 	17, 8, 10, 	17, 10, 6,

+ 13 - 12
src/geometries/EdgesGeometry.js

@@ -22,17 +22,18 @@ function EdgesGeometry( geometry, thresholdAngle ) {
 
 	// buffer
 
-	var vertices = [];
+	const vertices = [];
 
 	// helper variables
 
-	var thresholdDot = Math.cos( MathUtils.DEG2RAD * thresholdAngle );
-	var edge = [ 0, 0 ], edges = {}, edge1, edge2;
-	var key, keys = [ 'a', 'b', 'c' ];
+	const thresholdDot = Math.cos( MathUtils.DEG2RAD * thresholdAngle );
+	const edge = [ 0, 0 ], edges = {};
+	let edge1, edge2, key;
+	const keys = [ 'a', 'b', 'c' ];
 
 	// prepare source geometry
 
-	var geometry2;
+	let geometry2;
 
 	if ( geometry.isBufferGeometry ) {
 
@@ -48,16 +49,16 @@ function EdgesGeometry( geometry, thresholdAngle ) {
 	geometry2.mergeVertices();
 	geometry2.computeFaceNormals();
 
-	var sourceVertices = geometry2.vertices;
-	var faces = geometry2.faces;
+	const sourceVertices = geometry2.vertices;
+	const faces = geometry2.faces;
 
 	// now create a data structure where each entry represents an edge with its adjoining faces
 
-	for ( var i = 0, l = faces.length; i < l; i ++ ) {
+	for ( let i = 0, l = faces.length; i < l; i ++ ) {
 
-		var face = faces[ i ];
+		const face = faces[ i ];
 
-		for ( var j = 0; j < 3; j ++ ) {
+		for ( let j = 0; j < 3; j ++ ) {
 
 			edge1 = face[ keys[ j ] ];
 			edge2 = face[ keys[ ( j + 1 ) % 3 ] ];
@@ -84,13 +85,13 @@ function EdgesGeometry( geometry, thresholdAngle ) {
 
 	for ( key in edges ) {
 
-		var e = edges[ key ];
+		const e = edges[ key ];
 
 		// an edge is only rendered if the angle (in degrees) between the face normals of the adjoining faces exceeds this value. default = 1 degree.
 
 		if ( e.face2 === undefined || faces[ e.face1 ].normal.dot( faces[ e.face2 ].normal ) <= thresholdDot ) {
 
-			var vertex = sourceVertices[ e.index1 ];
+			let vertex = sourceVertices[ e.index1 ];
 			vertices.push( vertex.x, vertex.y, vertex.z );
 
 			vertex = sourceVertices[ e.index2 ];

+ 130 - 139
src/geometries/ExtrudeGeometry.js

@@ -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 );
 

+ 3 - 3
src/geometries/IcosahedronGeometry.js

@@ -31,15 +31,15 @@ IcosahedronGeometry.prototype.constructor = IcosahedronGeometry;
 
 function IcosahedronBufferGeometry( radius, detail ) {
 
-	var t = ( 1 + Math.sqrt( 5 ) ) / 2;
+	const t = ( 1 + Math.sqrt( 5 ) ) / 2;
 
-	var vertices = [
+	const vertices = [
 		- 1, t, 0, 	1, t, 0, 	- 1, - t, 0, 	1, - t, 0,
 		 0, - 1, t, 	0, 1, t,	0, - 1, - t, 	0, 1, - t,
 		 t, 0, - 1, 	t, 0, 1, 	- t, 0, - 1, 	- t, 0, 1
 	];
 
-	var indices = [
+	const indices = [
 		 0, 11, 5, 	0, 5, 1, 	0, 1, 7, 	0, 7, 10, 	0, 10, 11,
 		 1, 5, 9, 	5, 11, 4,	11, 10, 2,	10, 7, 6,	7, 1, 8,
 		 3, 9, 4, 	3, 4, 2,	3, 2, 6,	3, 6, 8,	3, 8, 9,

+ 24 - 26
src/geometries/LatheGeometry.js

@@ -60,28 +60,26 @@ function LatheBufferGeometry( points, segments, phiStart, phiLength ) {
 
 	// buffers
 
-	var indices = [];
-	var vertices = [];
-	var uvs = [];
+	const indices = [];
+	const vertices = [];
+	const uvs = [];
 
 	// helper variables
 
-	var base;
-	var inverseSegments = 1.0 / segments;
-	var vertex = new Vector3();
-	var uv = new Vector2();
-	var i, j;
+	const inverseSegments = 1.0 / segments;
+	const vertex = new Vector3();
+	const uv = new Vector2();
 
 	// generate vertices and uvs
 
-	for ( i = 0; i <= segments; i ++ ) {
+	for ( let i = 0; i <= segments; i ++ ) {
 
-		var phi = phiStart + i * inverseSegments * phiLength;
+		const phi = phiStart + i * inverseSegments * phiLength;
 
-		var sin = Math.sin( phi );
-		var cos = Math.cos( phi );
+		const sin = Math.sin( phi );
+		const cos = Math.cos( phi );
 
-		for ( j = 0; j <= ( points.length - 1 ); j ++ ) {
+		for ( let j = 0; j <= ( points.length - 1 ); j ++ ) {
 
 			// vertex
 
@@ -105,16 +103,16 @@ function LatheBufferGeometry( points, segments, phiStart, phiLength ) {
 
 	// indices
 
-	for ( i = 0; i < segments; i ++ ) {
+	for ( let i = 0; i < segments; i ++ ) {
 
-		for ( j = 0; j < ( points.length - 1 ); j ++ ) {
+		for ( let j = 0; j < ( points.length - 1 ); j ++ ) {
 
-			base = j + i * points.length;
+			const base = j + i * points.length;
 
-			var a = base;
-			var b = base + points.length;
-			var c = base + points.length + 1;
-			var d = base + 1;
+			const a = base;
+			const b = base + points.length;
+			const c = base + points.length + 1;
+			const d = base + 1;
 
 			// faces
 
@@ -140,16 +138,16 @@ function LatheBufferGeometry( points, segments, phiStart, phiLength ) {
 
 	if ( phiLength === Math.PI * 2 ) {
 
-		var normals = this.attributes.normal.array;
-		var n1 = new Vector3();
-		var n2 = new Vector3();
-		var n = new Vector3();
+		const normals = this.attributes.normal.array;
+		const n1 = new Vector3();
+		const n2 = new Vector3();
+		const n = new Vector3();
 
 		// this is the buffer offset for the last line of vertices
 
-		base = segments * points.length * 3;
+		const base = segments * points.length * 3;
 
-		for ( i = 0, j = 0; i < points.length; i ++, j += 3 ) {
+		for ( let i = 0, j = 0; i < points.length; i ++, j += 3 ) {
 
 			// select the normal of the vertex in the first line
 

+ 2 - 2
src/geometries/OctahedronGeometry.js

@@ -31,12 +31,12 @@ OctahedronGeometry.prototype.constructor = OctahedronGeometry;
 
 function OctahedronBufferGeometry( radius, detail ) {
 
-	var vertices = [
+	const vertices = [
 		1, 0, 0, 	- 1, 0, 0,	0, 1, 0,
 		0, - 1, 0, 	0, 0, 1,	0, 0, - 1
 	];
 
-	var indices = [
+	const indices = [
 		0, 2, 4,	0, 4, 3,	0, 3, 5,
 		0, 5, 2,	1, 2, 5,	1, 5, 3,
 		1, 3, 4,	1, 4, 2

+ 19 - 21
src/geometries/ParametricGeometry.js

@@ -49,19 +49,17 @@ function ParametricBufferGeometry( func, slices, stacks ) {
 
 	// buffers
 
-	var indices = [];
-	var vertices = [];
-	var normals = [];
-	var uvs = [];
+	const indices = [];
+	const vertices = [];
+	const normals = [];
+	const uvs = [];
 
-	var EPS = 0.00001;
+	const EPS = 0.00001;
 
-	var normal = new Vector3();
+	const normal = new Vector3();
 
-	var p0 = new Vector3(), p1 = new Vector3();
-	var pu = new Vector3(), pv = new Vector3();
-
-	var i, j;
+	const p0 = new Vector3(), p1 = new Vector3();
+	const pu = new Vector3(), pv = new Vector3();
 
 	if ( func.length < 3 ) {
 
@@ -71,15 +69,15 @@ function ParametricBufferGeometry( func, slices, stacks ) {
 
 	// generate vertices, normals and uvs
 
-	var sliceCount = slices + 1;
+	const sliceCount = slices + 1;
 
-	for ( i = 0; i <= stacks; i ++ ) {
+	for ( let i = 0; i <= stacks; i ++ ) {
 
-		var v = i / stacks;
+		const v = i / stacks;
 
-		for ( j = 0; j <= slices; j ++ ) {
+		for ( let j = 0; j <= slices; j ++ ) {
 
-			var u = j / slices;
+			const u = j / slices;
 
 			// vertex
 
@@ -129,14 +127,14 @@ function ParametricBufferGeometry( func, slices, stacks ) {
 
 	// generate indices
 
-	for ( i = 0; i < stacks; i ++ ) {
+	for ( let i = 0; i < stacks; i ++ ) {
 
-		for ( j = 0; j < slices; j ++ ) {
+		for ( let j = 0; j < slices; j ++ ) {
 
-			var a = i * sliceCount + j;
-			var b = i * sliceCount + j + 1;
-			var c = ( i + 1 ) * sliceCount + j + 1;
-			var d = ( i + 1 ) * sliceCount + j;
+			const a = i * sliceCount + j;
+			const b = i * sliceCount + j + 1;
+			const c = ( i + 1 ) * sliceCount + j + 1;
+			const d = ( i + 1 ) * sliceCount + j;
 
 			// faces one and two
 

+ 22 - 24
src/geometries/PlaneGeometry.js

@@ -48,36 +48,34 @@ function PlaneBufferGeometry( width, height, widthSegments, heightSegments ) {
 	width = width || 1;
 	height = height || 1;
 
-	var width_half = width / 2;
-	var height_half = height / 2;
+	const width_half = width / 2;
+	const height_half = height / 2;
 
-	var gridX = Math.floor( widthSegments ) || 1;
-	var gridY = Math.floor( heightSegments ) || 1;
+	const gridX = Math.floor( widthSegments ) || 1;
+	const gridY = Math.floor( heightSegments ) || 1;
 
-	var gridX1 = gridX + 1;
-	var gridY1 = gridY + 1;
+	const gridX1 = gridX + 1;
+	const gridY1 = gridY + 1;
 
-	var segment_width = width / gridX;
-	var segment_height = height / gridY;
-
-	var ix, iy;
+	const segment_width = width / gridX;
+	const segment_height = height / gridY;
 
 	// buffers
 
-	var indices = [];
-	var vertices = [];
-	var normals = [];
-	var uvs = [];
+	const indices = [];
+	const vertices = [];
+	const normals = [];
+	const uvs = [];
 
 	// generate vertices, normals and uvs
 
-	for ( iy = 0; iy < gridY1; iy ++ ) {
+	for ( let iy = 0; iy < gridY1; iy ++ ) {
 
-		var y = iy * segment_height - height_half;
+		const y = iy * segment_height - height_half;
 
-		for ( ix = 0; ix < gridX1; ix ++ ) {
+		for ( let ix = 0; ix < gridX1; ix ++ ) {
 
-			var x = ix * segment_width - width_half;
+			const x = ix * segment_width - width_half;
 
 			vertices.push( x, - y, 0 );
 
@@ -92,14 +90,14 @@ function PlaneBufferGeometry( width, height, widthSegments, heightSegments ) {
 
 	// indices
 
-	for ( iy = 0; iy < gridY; iy ++ ) {
+	for ( let iy = 0; iy < gridY; iy ++ ) {
 
-		for ( ix = 0; ix < gridX; ix ++ ) {
+		for ( let ix = 0; ix < gridX; ix ++ ) {
 
-			var a = ix + gridX1 * iy;
-			var b = ix + gridX1 * ( iy + 1 );
-			var c = ( ix + 1 ) + gridX1 * ( iy + 1 );
-			var d = ( ix + 1 ) + gridX1 * iy;
+			const a = ix + gridX1 * iy;
+			const b = ix + gridX1 * ( iy + 1 );
+			const c = ( ix + 1 ) + gridX1 * ( iy + 1 );
+			const d = ( ix + 1 ) + gridX1 * iy;
 
 			// faces
 

+ 38 - 40
src/geometries/PolyhedronGeometry.js

@@ -54,8 +54,8 @@ function PolyhedronBufferGeometry( vertices, indices, radius, detail ) {
 
 	// default buffer data
 
-	var vertexBuffer = [];
-	var uvBuffer = [];
+	const vertexBuffer = [];
+	const uvBuffer = [];
 
 	// the subdivision creates the vertex buffer data
 
@@ -89,13 +89,13 @@ function PolyhedronBufferGeometry( vertices, indices, radius, detail ) {
 
 	function subdivide( detail ) {
 
-		var a = new Vector3();
-		var b = new Vector3();
-		var c = new Vector3();
+		const a = new Vector3();
+		const b = new Vector3();
+		const c = new Vector3();
 
 		// iterate over all faces and apply a subdivison with the given detail value
 
-		for ( var i = 0; i < indices.length; i += 3 ) {
+		for ( let i = 0; i < indices.length; i += 3 ) {
 
 			// get the vertices of the face
 
@@ -113,26 +113,24 @@ function PolyhedronBufferGeometry( vertices, indices, radius, detail ) {
 
 	function subdivideFace( a, b, c, detail ) {
 
-		var cols = Math.pow( 2, detail );
+		const cols = Math.pow( 2, detail );
 
 		// we use this multidimensional array as a data structure for creating the subdivision
 
-		var v = [];
-
-		var i, j;
+		const v = [];
 
 		// construct all of the vertices for this subdivision
 
-		for ( i = 0; i <= cols; i ++ ) {
+		for ( let i = 0; i <= cols; i ++ ) {
 
 			v[ i ] = [];
 
-			var aj = a.clone().lerp( c, i / cols );
-			var bj = b.clone().lerp( c, i / cols );
+			const aj = a.clone().lerp( c, i / cols );
+			const bj = b.clone().lerp( c, i / cols );
 
-			var rows = cols - i;
+			const rows = cols - i;
 
-			for ( j = 0; j <= rows; j ++ ) {
+			for ( let j = 0; j <= rows; j ++ ) {
 
 				if ( j === 0 && i === cols ) {
 
@@ -150,11 +148,11 @@ function PolyhedronBufferGeometry( vertices, indices, radius, detail ) {
 
 		// construct all of the faces
 
-		for ( i = 0; i < cols; i ++ ) {
+		for ( let i = 0; i < cols; i ++ ) {
 
-			for ( j = 0; j < 2 * ( cols - i ) - 1; j ++ ) {
+			for ( let j = 0; j < 2 * ( cols - i ) - 1; j ++ ) {
 
-				var k = Math.floor( j / 2 );
+				const k = Math.floor( j / 2 );
 
 				if ( j % 2 === 0 ) {
 
@@ -178,11 +176,11 @@ function PolyhedronBufferGeometry( vertices, indices, radius, detail ) {
 
 	function applyRadius( radius ) {
 
-		var vertex = new Vector3();
+		const vertex = new Vector3();
 
 		// iterate over the entire buffer and apply the radius to each vertex
 
-		for ( var i = 0; i < vertexBuffer.length; i += 3 ) {
+		for ( let i = 0; i < vertexBuffer.length; i += 3 ) {
 
 			vertex.x = vertexBuffer[ i + 0 ];
 			vertex.y = vertexBuffer[ i + 1 ];
@@ -200,16 +198,16 @@ function PolyhedronBufferGeometry( vertices, indices, radius, detail ) {
 
 	function generateUVs() {
 
-		var vertex = new Vector3();
+		const vertex = new Vector3();
 
-		for ( var i = 0; i < vertexBuffer.length; i += 3 ) {
+		for ( let i = 0; i < vertexBuffer.length; i += 3 ) {
 
 			vertex.x = vertexBuffer[ i + 0 ];
 			vertex.y = vertexBuffer[ i + 1 ];
 			vertex.z = vertexBuffer[ i + 2 ];
 
-			var u = azimuth( vertex ) / 2 / Math.PI + 0.5;
-			var v = inclination( vertex ) / Math.PI + 0.5;
+			const u = azimuth( vertex ) / 2 / Math.PI + 0.5;
+			const v = inclination( vertex ) / Math.PI + 0.5;
 			uvBuffer.push( u, 1 - v );
 
 		}
@@ -224,16 +222,16 @@ function PolyhedronBufferGeometry( vertices, indices, radius, detail ) {
 
 		// handle case when face straddles the seam, see #3269
 
-		for ( var i = 0; i < uvBuffer.length; i += 6 ) {
+		for ( let i = 0; i < uvBuffer.length; i += 6 ) {
 
 			// uv data of a single face
 
-			var x0 = uvBuffer[ i + 0 ];
-			var x1 = uvBuffer[ i + 2 ];
-			var x2 = uvBuffer[ i + 4 ];
+			const x0 = uvBuffer[ i + 0 ];
+			const x1 = uvBuffer[ i + 2 ];
+			const x2 = uvBuffer[ i + 4 ];
 
-			var max = Math.max( x0, x1, x2 );
-			var min = Math.min( x0, x1, x2 );
+			const max = Math.max( x0, x1, x2 );
+			const min = Math.min( x0, x1, x2 );
 
 			// 0.9 is somewhat arbitrary
 
@@ -257,7 +255,7 @@ function PolyhedronBufferGeometry( vertices, indices, radius, detail ) {
 
 	function getVertexByIndex( index, vertex ) {
 
-		var stride = index * 3;
+		const stride = index * 3;
 
 		vertex.x = vertices[ stride + 0 ];
 		vertex.y = vertices[ stride + 1 ];
@@ -267,17 +265,17 @@ function PolyhedronBufferGeometry( vertices, indices, radius, detail ) {
 
 	function correctUVs() {
 
-		var a = new Vector3();
-		var b = new Vector3();
-		var c = new Vector3();
+		const a = new Vector3();
+		const b = new Vector3();
+		const c = new Vector3();
 
-		var centroid = new Vector3();
+		const centroid = new Vector3();
 
-		var uvA = new Vector2();
-		var uvB = new Vector2();
-		var uvC = new Vector2();
+		const uvA = new Vector2();
+		const uvB = new Vector2();
+		const uvC = new Vector2();
 
-		for ( var i = 0, j = 0; i < vertexBuffer.length; i += 9, j += 6 ) {
+		for ( let i = 0, j = 0; i < vertexBuffer.length; i += 9, j += 6 ) {
 
 			a.set( vertexBuffer[ i + 0 ], vertexBuffer[ i + 1 ], vertexBuffer[ i + 2 ] );
 			b.set( vertexBuffer[ i + 3 ], vertexBuffer[ i + 4 ], vertexBuffer[ i + 5 ] );
@@ -289,7 +287,7 @@ function PolyhedronBufferGeometry( vertices, indices, radius, detail ) {
 
 			centroid.copy( a ).add( b ).add( c ).divideScalar( 3 );
 
-			var azi = azimuth( centroid );
+			const azi = azimuth( centroid );
 
 			correctUV( uvA, j + 0, a, azi );
 			correctUV( uvB, j + 2, b, azi );

+ 19 - 21
src/geometries/RingGeometry.js

@@ -62,29 +62,27 @@ function RingBufferGeometry( innerRadius, outerRadius, thetaSegments, phiSegment
 
 	// buffers
 
-	var indices = [];
-	var vertices = [];
-	var normals = [];
-	var uvs = [];
+	const indices = [];
+	const vertices = [];
+	const normals = [];
+	const uvs = [];
 
 	// some helper variables
 
-	var segment;
-	var radius = innerRadius;
-	var radiusStep = ( ( outerRadius - innerRadius ) / phiSegments );
-	var vertex = new Vector3();
-	var uv = new Vector2();
-	var j, i;
+	let radius = innerRadius;
+	const radiusStep = ( ( outerRadius - innerRadius ) / phiSegments );
+	const vertex = new Vector3();
+	const uv = new Vector2();
 
 	// generate vertices, normals and uvs
 
-	for ( j = 0; j <= phiSegments; j ++ ) {
+	for ( let j = 0; j <= phiSegments; j ++ ) {
 
-		for ( i = 0; i <= thetaSegments; i ++ ) {
+		for ( let i = 0; i <= thetaSegments; i ++ ) {
 
 			// values are generate from the inside of the ring to the outside
 
-			segment = thetaStart + i / thetaSegments * thetaLength;
+			const segment = thetaStart + i / thetaSegments * thetaLength;
 
 			// vertex
 
@@ -114,18 +112,18 @@ function RingBufferGeometry( innerRadius, outerRadius, thetaSegments, phiSegment
 
 	// indices
 
-	for ( j = 0; j < phiSegments; j ++ ) {
+	for ( let j = 0; j < phiSegments; j ++ ) {
 
-		var thetaSegmentLevel = j * ( thetaSegments + 1 );
+		const thetaSegmentLevel = j * ( thetaSegments + 1 );
 
-		for ( i = 0; i < thetaSegments; i ++ ) {
+		for ( let i = 0; i < thetaSegments; i ++ ) {
 
-			segment = i + thetaSegmentLevel;
+			const segment = i + thetaSegmentLevel;
 
-			var a = segment;
-			var b = segment + thetaSegments + 1;
-			var c = segment + thetaSegments + 2;
-			var d = segment + 1;
+			const a = segment;
+			const b = segment + thetaSegments + 1;
+			const c = segment + thetaSegments + 2;
+			const d = segment + 1;
 
 			// faces
 

+ 29 - 31
src/geometries/ShapeGeometry.js

@@ -39,9 +39,9 @@ ShapeGeometry.prototype.constructor = ShapeGeometry;
 
 ShapeGeometry.prototype.toJSON = function () {
 
-	var data = Geometry.prototype.toJSON.call( this );
+	const data = Geometry.prototype.toJSON.call( this );
 
-	var shapes = this.parameters.shapes;
+	const shapes = this.parameters.shapes;
 
 	return toJSON( shapes, data );
 
@@ -64,15 +64,15 @@ function ShapeBufferGeometry( shapes, curveSegments ) {
 
 	// buffers
 
-	var indices = [];
-	var vertices = [];
-	var normals = [];
-	var uvs = [];
+	const indices = [];
+	const vertices = [];
+	const normals = [];
+	const uvs = [];
 
 	// helper variables
 
-	var groupStart = 0;
-	var groupCount = 0;
+	let groupStart = 0;
+	let groupCount = 0;
 
 	// allow single and array values for "shapes" parameter
 
@@ -82,7 +82,7 @@ function ShapeBufferGeometry( shapes, curveSegments ) {
 
 	} else {
 
-		for ( var i = 0; i < shapes.length; i ++ ) {
+		for ( let i = 0; i < shapes.length; i ++ ) {
 
 			addShape( shapes[ i ] );
 
@@ -107,13 +107,11 @@ function ShapeBufferGeometry( shapes, curveSegments ) {
 
 	function addShape( shape ) {
 
-		var i, l, shapeHole;
+		const indexOffset = vertices.length / 3;
+		const points = shape.extractPoints( curveSegments );
 
-		var indexOffset = vertices.length / 3;
-		var points = shape.extractPoints( curveSegments );
-
-		var shapeVertices = points.shape;
-		var shapeHoles = points.holes;
+		let shapeVertices = points.shape;
+		const shapeHoles = points.holes;
 
 		// check direction of vertices
 
@@ -123,9 +121,9 @@ function ShapeBufferGeometry( shapes, curveSegments ) {
 
 		}
 
-		for ( i = 0, l = shapeHoles.length; i < l; i ++ ) {
+		for ( let i = 0, l = shapeHoles.length; i < l; i ++ ) {
 
-			shapeHole = shapeHoles[ i ];
+			const shapeHole = shapeHoles[ i ];
 
 			if ( ShapeUtils.isClockWise( shapeHole ) === true ) {
 
@@ -135,22 +133,22 @@ function ShapeBufferGeometry( shapes, curveSegments ) {
 
 		}
 
-		var faces = ShapeUtils.triangulateShape( shapeVertices, shapeHoles );
+		const faces = ShapeUtils.triangulateShape( shapeVertices, shapeHoles );
 
 		// join vertices of inner and outer paths to a single array
 
-		for ( i = 0, l = shapeHoles.length; i < l; i ++ ) {
+		for ( let i = 0, l = shapeHoles.length; i < l; i ++ ) {
 
-			shapeHole = shapeHoles[ i ];
+			const shapeHole = shapeHoles[ i ];
 			shapeVertices = shapeVertices.concat( shapeHole );
 
 		}
 
 		// vertices, normals, uvs
 
-		for ( i = 0, l = shapeVertices.length; i < l; i ++ ) {
+		for ( let i = 0, l = shapeVertices.length; i < l; i ++ ) {
 
-			var vertex = shapeVertices[ i ];
+			const vertex = shapeVertices[ i ];
 
 			vertices.push( vertex.x, vertex.y, 0 );
 			normals.push( 0, 0, 1 );
@@ -160,13 +158,13 @@ function ShapeBufferGeometry( shapes, curveSegments ) {
 
 		// incides
 
-		for ( i = 0, l = faces.length; i < l; i ++ ) {
+		for ( let i = 0, l = faces.length; i < l; i ++ ) {
 
-			var face = faces[ i ];
+			const face = faces[ i ];
 
-			var a = face[ 0 ] + indexOffset;
-			var b = face[ 1 ] + indexOffset;
-			var c = face[ 2 ] + indexOffset;
+			const a = face[ 0 ] + indexOffset;
+			const b = face[ 1 ] + indexOffset;
+			const c = face[ 2 ] + indexOffset;
 
 			indices.push( a, b, c );
 			groupCount += 3;
@@ -182,9 +180,9 @@ ShapeBufferGeometry.prototype.constructor = ShapeBufferGeometry;
 
 ShapeBufferGeometry.prototype.toJSON = function () {
 
-	var data = BufferGeometry.prototype.toJSON.call( this );
+	const data = BufferGeometry.prototype.toJSON.call( this );
 
-	var shapes = this.parameters.shapes;
+	const shapes = this.parameters.shapes;
 
 	return toJSON( shapes, data );
 
@@ -198,9 +196,9 @@ function toJSON( shapes, 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 );
 

+ 21 - 23
src/geometries/SphereGeometry.js

@@ -64,34 +64,32 @@ function SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart,
 	thetaStart = thetaStart !== undefined ? thetaStart : 0;
 	thetaLength = thetaLength !== undefined ? thetaLength : Math.PI;
 
-	var thetaEnd = Math.min( thetaStart + thetaLength, Math.PI );
+	const thetaEnd = Math.min( thetaStart + thetaLength, Math.PI );
 
-	var ix, iy;
+	let index = 0;
+	const grid = [];
 
-	var index = 0;
-	var grid = [];
-
-	var vertex = new Vector3();
-	var normal = new Vector3();
+	const vertex = new Vector3();
+	const normal = new Vector3();
 
 	// buffers
 
-	var indices = [];
-	var vertices = [];
-	var normals = [];
-	var uvs = [];
+	const indices = [];
+	const vertices = [];
+	const normals = [];
+	const uvs = [];
 
 	// generate vertices, normals and uvs
 
-	for ( iy = 0; iy <= heightSegments; iy ++ ) {
+	for ( let iy = 0; iy <= heightSegments; iy ++ ) {
 
-		var verticesRow = [];
+		const verticesRow = [];
 
-		var v = iy / heightSegments;
+		const v = iy / heightSegments;
 
 		// special case for the poles
 
-		var uOffset = 0;
+		let uOffset = 0;
 
 		if ( iy == 0 && thetaStart == 0 ) {
 
@@ -103,9 +101,9 @@ function SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart,
 
 		}
 
-		for ( ix = 0; ix <= widthSegments; ix ++ ) {
+		for ( let ix = 0; ix <= widthSegments; ix ++ ) {
 
-			var u = ix / widthSegments;
+			const u = ix / widthSegments;
 
 			// vertex
 
@@ -134,14 +132,14 @@ function SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart,
 
 	// indices
 
-	for ( iy = 0; iy < heightSegments; iy ++ ) {
+	for ( let iy = 0; iy < heightSegments; iy ++ ) {
 
-		for ( ix = 0; ix < widthSegments; ix ++ ) {
+		for ( let ix = 0; ix < widthSegments; ix ++ ) {
 
-			var a = grid[ iy ][ ix + 1 ];
-			var b = grid[ iy ][ ix ];
-			var c = grid[ iy + 1 ][ ix ];
-			var d = grid[ iy + 1 ][ ix + 1 ];
+			const a = grid[ iy ][ ix + 1 ];
+			const b = grid[ iy ][ ix ];
+			const c = grid[ iy + 1 ][ ix ];
+			const d = grid[ iy + 1 ][ ix + 1 ];
 
 			if ( iy !== 0 || thetaStart > 0 ) indices.push( a, b, d );
 			if ( iy !== heightSegments - 1 || thetaEnd < Math.PI ) indices.push( b, c, d );

+ 2 - 2
src/geometries/TetrahedronGeometry.js

@@ -31,11 +31,11 @@ TetrahedronGeometry.prototype.constructor = TetrahedronGeometry;
 
 function TetrahedronBufferGeometry( radius, detail ) {
 
-	var vertices = [
+	const vertices = [
 		1, 1, 1, 	- 1, - 1, 1, 	- 1, 1, - 1, 	1, - 1, - 1
 	];
 
-	var indices = [
+	const indices = [
 		2, 1, 0, 	0, 3, 2,	1, 3, 0,	2, 3, 1
 	];
 

+ 2 - 2
src/geometries/TextGeometry.js

@@ -48,7 +48,7 @@ function TextBufferGeometry( text, parameters ) {
 
 	parameters = parameters || {};
 
-	var font = parameters.font;
+	const font = parameters.font;
 
 	if ( ! ( font && font.isFont ) ) {
 
@@ -57,7 +57,7 @@ function TextBufferGeometry( text, parameters ) {
 
 	}
 
-	var shapes = font.generateShapes( text, parameters.size );
+	const shapes = font.generateShapes( text, parameters.size );
 
 	// translate parameters to ExtrudeGeometry API
 

+ 17 - 19
src/geometries/TorusGeometry.js

@@ -57,27 +57,25 @@ function TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc
 
 	// buffers
 
-	var indices = [];
-	var vertices = [];
-	var normals = [];
-	var uvs = [];
+	const indices = [];
+	const vertices = [];
+	const normals = [];
+	const uvs = [];
 
 	// helper variables
 
-	var center = new Vector3();
-	var vertex = new Vector3();
-	var normal = new Vector3();
-
-	var j, i;
+	const center = new Vector3();
+	const vertex = new Vector3();
+	const normal = new Vector3();
 
 	// generate vertices, normals and uvs
 
-	for ( j = 0; j <= radialSegments; j ++ ) {
+	for ( let j = 0; j <= radialSegments; j ++ ) {
 
-		for ( i = 0; i <= tubularSegments; i ++ ) {
+		for ( let i = 0; i <= tubularSegments; i ++ ) {
 
-			var u = i / tubularSegments * arc;
-			var v = j / radialSegments * Math.PI * 2;
+			const u = i / tubularSegments * arc;
+			const v = j / radialSegments * Math.PI * 2;
 
 			// vertex
 
@@ -106,16 +104,16 @@ function TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc
 
 	// generate indices
 
-	for ( j = 1; j <= radialSegments; j ++ ) {
+	for ( let j = 1; j <= radialSegments; j ++ ) {
 
-		for ( i = 1; i <= tubularSegments; i ++ ) {
+		for ( let i = 1; i <= tubularSegments; i ++ ) {
 
 			// indices
 
-			var a = ( tubularSegments + 1 ) * j + i - 1;
-			var b = ( tubularSegments + 1 ) * ( j - 1 ) + i - 1;
-			var c = ( tubularSegments + 1 ) * ( j - 1 ) + i;
-			var d = ( tubularSegments + 1 ) * j + i;
+			const a = ( tubularSegments + 1 ) * j + i - 1;
+			const b = ( tubularSegments + 1 ) * ( j - 1 ) + i - 1;
+			const c = ( tubularSegments + 1 ) * ( j - 1 ) + i;
+			const d = ( tubularSegments + 1 ) * j + i;
 
 			// faces
 

+ 27 - 29
src/geometries/TorusKnotGeometry.js

@@ -63,32 +63,30 @@ function TorusKnotBufferGeometry( radius, tube, tubularSegments, radialSegments,
 
 	// buffers
 
-	var indices = [];
-	var vertices = [];
-	var normals = [];
-	var uvs = [];
+	const indices = [];
+	const vertices = [];
+	const normals = [];
+	const uvs = [];
 
 	// helper variables
 
-	var i, j;
+	const vertex = new Vector3();
+	const normal = new Vector3();
 
-	var vertex = new Vector3();
-	var normal = new Vector3();
+	const P1 = new Vector3();
+	const P2 = new Vector3();
 
-	var P1 = new Vector3();
-	var P2 = new Vector3();
-
-	var B = new Vector3();
-	var T = new Vector3();
-	var N = new Vector3();
+	const B = new Vector3();
+	const T = new Vector3();
+	const N = new Vector3();
 
 	// generate vertices, normals and uvs
 
-	for ( i = 0; i <= tubularSegments; ++ i ) {
+	for ( let i = 0; i <= tubularSegments; ++ i ) {
 
 		// the radian "u" is used to calculate the position on the torus curve of the current tubular segement
 
-		var u = i / tubularSegments * p * Math.PI * 2;
+		const u = i / tubularSegments * p * Math.PI * 2;
 
 		// now we calculate two points. P1 is our current position on the curve, P2 is a little farther ahead.
 		// these points are used to create a special "coordinate space", which is necessary to calculate the correct vertex positions
@@ -108,14 +106,14 @@ function TorusKnotBufferGeometry( radius, tube, tubularSegments, radialSegments,
 		B.normalize();
 		N.normalize();
 
-		for ( j = 0; j <= radialSegments; ++ j ) {
+		for ( let j = 0; j <= radialSegments; ++ j ) {
 
 			// now calculate the vertices. they are nothing more than an extrusion of the torus curve.
 			// because we extrude a shape in the xy-plane, there is no need to calculate a z-value.
 
-			var v = j / radialSegments * Math.PI * 2;
-			var cx = - tube * Math.cos( v );
-			var cy = tube * Math.sin( v );
+			const v = j / radialSegments * Math.PI * 2;
+			const cx = - tube * Math.cos( v );
+			const cy = tube * Math.sin( v );
 
 			// now calculate the final vertex position.
 			// first we orient the extrusion with our basis vectos, then we add it to the current position on the curve
@@ -143,16 +141,16 @@ function TorusKnotBufferGeometry( radius, tube, tubularSegments, radialSegments,
 
 	// generate indices
 
-	for ( j = 1; j <= tubularSegments; j ++ ) {
+	for ( let j = 1; j <= tubularSegments; j ++ ) {
 
-		for ( i = 1; i <= radialSegments; i ++ ) {
+		for ( let i = 1; i <= radialSegments; i ++ ) {
 
 			// indices
 
-			var a = ( radialSegments + 1 ) * ( j - 1 ) + ( i - 1 );
-			var b = ( radialSegments + 1 ) * j + ( i - 1 );
-			var c = ( radialSegments + 1 ) * j + i;
-			var d = ( radialSegments + 1 ) * ( j - 1 ) + i;
+			const a = ( radialSegments + 1 ) * ( j - 1 ) + ( i - 1 );
+			const b = ( radialSegments + 1 ) * j + ( i - 1 );
+			const c = ( radialSegments + 1 ) * j + i;
+			const d = ( radialSegments + 1 ) * ( j - 1 ) + i;
 
 			// faces
 
@@ -174,10 +172,10 @@ function TorusKnotBufferGeometry( radius, tube, tubularSegments, radialSegments,
 
 	function calculatePositionOnCurve( u, p, q, radius, position ) {
 
-		var cu = Math.cos( u );
-		var su = Math.sin( u );
-		var quOverP = q / p * u;
-		var cs = Math.cos( quOverP );
+		const cu = Math.cos( u );
+		const su = Math.sin( u );
+		const quOverP = q / p * u;
+		const cs = Math.cos( quOverP );
 
 		position.x = radius * ( 2 + cs ) * 0.5 * cu;
 		position.y = radius * ( 2 + cs ) * su * 0.5;

+ 26 - 28
src/geometries/TubeGeometry.js

@@ -32,7 +32,7 @@ function TubeGeometry( path, tubularSegments, radius, radialSegments, closed, ta
 
 	if ( taper !== undefined ) console.warn( 'THREE.TubeGeometry: taper has been removed.' );
 
-	var bufferGeometry = new TubeBufferGeometry( path, tubularSegments, radius, radialSegments, closed );
+	const bufferGeometry = new TubeBufferGeometry( path, tubularSegments, radius, radialSegments, closed );
 
 	// expose internals
 
@@ -71,7 +71,7 @@ function TubeBufferGeometry( path, tubularSegments, radius, radialSegments, clos
 	radialSegments = radialSegments || 8;
 	closed = closed || false;
 
-	var frames = path.computeFrenetFrames( tubularSegments, closed );
+	const frames = path.computeFrenetFrames( tubularSegments, closed );
 
 	// expose internals
 
@@ -81,19 +81,17 @@ function TubeBufferGeometry( path, tubularSegments, radius, radialSegments, clos
 
 	// helper variables
 
-	var vertex = new Vector3();
-	var normal = new Vector3();
-	var uv = new Vector2();
-	var P = new Vector3();
-
-	var i, j;
+	const vertex = new Vector3();
+	const normal = new Vector3();
+	const uv = new Vector2();
+	let P = new Vector3();
 
 	// buffer
 
-	var vertices = [];
-	var normals = [];
-	var uvs = [];
-	var indices = [];
+	const vertices = [];
+	const normals = [];
+	const uvs = [];
+	const indices = [];
 
 	// create buffer data
 
@@ -110,7 +108,7 @@ function TubeBufferGeometry( path, tubularSegments, radius, radialSegments, clos
 
 	function generateBufferData() {
 
-		for ( i = 0; i < tubularSegments; i ++ ) {
+		for ( let i = 0; i < tubularSegments; i ++ ) {
 
 			generateSegment( i );
 
@@ -142,17 +140,17 @@ function TubeBufferGeometry( path, tubularSegments, radius, radialSegments, clos
 
 		// retrieve corresponding normal and binormal
 
-		var N = frames.normals[ i ];
-		var B = frames.binormals[ i ];
+		const N = frames.normals[ i ];
+		const B = frames.binormals[ i ];
 
 		// generate normals and vertices for the current segment
 
-		for ( j = 0; j <= radialSegments; j ++ ) {
+		for ( let j = 0; j <= radialSegments; j ++ ) {
 
-			var v = j / radialSegments * Math.PI * 2;
+			const v = j / radialSegments * Math.PI * 2;
 
-			var sin = Math.sin( v );
-			var cos = - Math.cos( v );
+			const sin = Math.sin( v );
+			const cos = - Math.cos( v );
 
 			// normal
 
@@ -177,14 +175,14 @@ function TubeBufferGeometry( path, tubularSegments, radius, radialSegments, clos
 
 	function generateIndices() {
 
-		for ( j = 1; j <= tubularSegments; j ++ ) {
+		for ( let j = 1; j <= tubularSegments; j ++ ) {
 
-			for ( i = 1; i <= radialSegments; i ++ ) {
+			for ( let i = 1; i <= radialSegments; i ++ ) {
 
-				var a = ( radialSegments + 1 ) * ( j - 1 ) + ( i - 1 );
-				var b = ( radialSegments + 1 ) * j + ( i - 1 );
-				var c = ( radialSegments + 1 ) * j + i;
-				var d = ( radialSegments + 1 ) * ( j - 1 ) + i;
+				const a = ( radialSegments + 1 ) * ( j - 1 ) + ( i - 1 );
+				const b = ( radialSegments + 1 ) * j + ( i - 1 );
+				const c = ( radialSegments + 1 ) * j + i;
+				const d = ( radialSegments + 1 ) * ( j - 1 ) + i;
 
 				// faces
 
@@ -199,9 +197,9 @@ function TubeBufferGeometry( path, tubularSegments, radius, radialSegments, clos
 
 	function generateUVs() {
 
-		for ( i = 0; i <= tubularSegments; i ++ ) {
+		for ( let i = 0; i <= tubularSegments; i ++ ) {
 
-			for ( j = 0; j <= radialSegments; j ++ ) {
+			for ( let j = 0; j <= radialSegments; j ++ ) {
 
 				uv.x = i / tubularSegments;
 				uv.y = j / radialSegments;
@@ -221,7 +219,7 @@ TubeBufferGeometry.prototype.constructor = TubeBufferGeometry;
 
 TubeBufferGeometry.prototype.toJSON = function () {
 
-	var data = BufferGeometry.prototype.toJSON.call( this );
+	const data = BufferGeometry.prototype.toJSON.call( this );
 
 	data.path = this.parameters.path.toJSON();
 

+ 33 - 39
src/geometries/WireframeGeometry.js

@@ -15,14 +15,12 @@ function WireframeGeometry( geometry ) {
 
 	// buffer
 
-	var vertices = [];
+	const vertices = [];
 
 	// helper variables
 
-	var i, j, l, o, ol;
-	var edge = [ 0, 0 ], edges = {}, e, edge1, edge2;
-	var key, keys = [ 'a', 'b', 'c' ];
-	var vertex;
+	const edge = [ 0, 0 ], edges = {};
+	const keys = [ 'a', 'b', 'c' ];
 
 	// different logic for Geometry and BufferGeometry
 
@@ -30,20 +28,20 @@ function WireframeGeometry( geometry ) {
 
 		// create a data structure that contains all edges without duplicates
 
-		var faces = geometry.faces;
+		const faces = geometry.faces;
 
-		for ( i = 0, l = faces.length; i < l; i ++ ) {
+		for ( let i = 0, l = faces.length; i < l; i ++ ) {
 
-			var face = faces[ i ];
+			const face = faces[ i ];
 
-			for ( j = 0; j < 3; j ++ ) {
+			for ( let j = 0; j < 3; j ++ ) {
 
-				edge1 = face[ keys[ j ] ];
-				edge2 = face[ keys[ ( j + 1 ) % 3 ] ];
+				const edge1 = face[ keys[ j ] ];
+				const edge2 = face[ keys[ ( j + 1 ) % 3 ] ];
 				edge[ 0 ] = Math.min( edge1, edge2 ); // sorting prevents duplicates
 				edge[ 1 ] = Math.max( edge1, edge2 );
 
-				key = edge[ 0 ] + ',' + edge[ 1 ];
+				const key = edge[ 0 ] + ',' + edge[ 1 ];
 
 				if ( edges[ key ] === undefined ) {
 
@@ -57,11 +55,11 @@ function WireframeGeometry( geometry ) {
 
 		// generate vertices
 
-		for ( key in edges ) {
+		for ( const key in edges ) {
 
-			e = edges[ key ];
+			const e = edges[ key ];
 
-			vertex = geometry.vertices[ e.index1 ];
+			let vertex = geometry.vertices[ e.index1 ];
 			vertices.push( vertex.x, vertex.y, vertex.z );
 
 			vertex = geometry.vertices[ e.index2 ];
@@ -71,19 +69,15 @@ function WireframeGeometry( geometry ) {
 
 	} else if ( geometry && geometry.isBufferGeometry ) {
 
-		var position, indices, groups;
-		var group, start, count;
-		var index1, index2;
-
-		vertex = new Vector3();
+		let vertex = new Vector3();
 
 		if ( geometry.index !== null ) {
 
 			// indexed BufferGeometry
 
-			position = geometry.attributes.position;
-			indices = geometry.index;
-			groups = geometry.groups;
+			const position = geometry.attributes.position;
+			const indices = geometry.index;
+			let groups = geometry.groups;
 
 			if ( groups.length === 0 ) {
 
@@ -93,23 +87,23 @@ function WireframeGeometry( geometry ) {
 
 			// create a data structure that contains all eges without duplicates
 
-			for ( o = 0, ol = groups.length; o < ol; ++ o ) {
+			for ( let o = 0, ol = groups.length; o < ol; ++ o ) {
 
-				group = groups[ o ];
+				const group = groups[ o ];
 
-				start = group.start;
-				count = group.count;
+				const start = group.start;
+				const count = group.count;
 
-				for ( i = start, l = ( start + count ); i < l; i += 3 ) {
+				for ( let i = start, l = ( start + count ); i < l; i += 3 ) {
 
-					for ( j = 0; j < 3; j ++ ) {
+					for ( let j = 0; j < 3; j ++ ) {
 
-						edge1 = indices.getX( i + j );
-						edge2 = indices.getX( i + ( j + 1 ) % 3 );
+						const edge1 = indices.getX( i + j );
+						const edge2 = indices.getX( i + ( j + 1 ) % 3 );
 						edge[ 0 ] = Math.min( edge1, edge2 ); // sorting prevents duplicates
 						edge[ 1 ] = Math.max( edge1, edge2 );
 
-						key = edge[ 0 ] + ',' + edge[ 1 ];
+						const key = edge[ 0 ] + ',' + edge[ 1 ];
 
 						if ( edges[ key ] === undefined ) {
 
@@ -125,9 +119,9 @@ function WireframeGeometry( geometry ) {
 
 			// generate vertices
 
-			for ( key in edges ) {
+			for ( const key in edges ) {
 
-				e = edges[ key ];
+				const e = edges[ key ];
 
 				vertex.fromBufferAttribute( position, e.index1 );
 				vertices.push( vertex.x, vertex.y, vertex.z );
@@ -141,20 +135,20 @@ function WireframeGeometry( geometry ) {
 
 			// non-indexed BufferGeometry
 
-			position = geometry.attributes.position;
+			const position = geometry.attributes.position;
 
-			for ( i = 0, l = ( position.count / 3 ); i < l; i ++ ) {
+			for ( let i = 0, l = ( position.count / 3 ); i < l; i ++ ) {
 
-				for ( j = 0; j < 3; j ++ ) {
+				for ( let j = 0; j < 3; j ++ ) {
 
 					// three edges per triangle, an edge is represented as (index1, index2)
 					// e.g. the first triangle has the following edges: (0,1),(1,2),(2,0)
 
-					index1 = 3 * i + j;
+					const index1 = 3 * i + j;
 					vertex.fromBufferAttribute( position, index1 );
 					vertices.push( vertex.x, vertex.y, vertex.z );
 
-					index2 = 3 * i + ( ( j + 1 ) % 3 );
+					const index2 = 3 * i + ( ( j + 1 ) % 3 );
 					vertex.fromBufferAttribute( position, index2 );
 					vertices.push( vertex.x, vertex.y, vertex.z );