Sfoglia il codice sorgente

Extras: Move to let/const.

Mugen87 5 anni fa
parent
commit
0411e78abb

+ 36 - 36
src/extras/Earcut.js

@@ -3,20 +3,20 @@
  * Port from https://github.com/mapbox/earcut (v2.2.2)
  */
 
-var Earcut = {
+const Earcut = {
 
 	triangulate: function ( data, holeIndices, dim ) {
 
 		dim = dim || 2;
 
-		var hasHoles = holeIndices && holeIndices.length,
+		let hasHoles = holeIndices && holeIndices.length,
 			outerLen = hasHoles ? holeIndices[ 0 ] * dim : data.length,
 			outerNode = linkedList( data, 0, outerLen, dim, true ),
 			triangles = [];
 
 		if ( ! outerNode || outerNode.next === outerNode.prev ) return triangles;
 
-		var minX, minY, maxX, maxY, x, y, invSize;
+		let minX, minY, maxX, maxY, x, y, invSize;
 
 		if ( hasHoles ) outerNode = eliminateHoles( data, holeIndices, outerNode, dim );
 
@@ -26,7 +26,7 @@ var Earcut = {
 			minX = maxX = data[ 0 ];
 			minY = maxY = data[ 1 ];
 
-			for ( var i = dim; i < outerLen; i += dim ) {
+			for ( let i = dim; i < outerLen; i += dim ) {
 
 				x = data[ i ];
 				y = data[ i + 1 ];
@@ -54,7 +54,7 @@ var Earcut = {
 // create a circular doubly linked list from polygon points in the specified winding order
 function linkedList( data, start, end, dim, clockwise ) {
 
-	var i, last;
+	let i, last;
 
 	if ( clockwise === ( signedArea( data, start, end, dim ) > 0 ) ) {
 
@@ -83,7 +83,7 @@ function filterPoints( start, end ) {
 	if ( ! start ) return start;
 	if ( ! end ) end = start;
 
-	var p = start,
+	let p = start,
 		again;
 	do {
 
@@ -116,7 +116,7 @@ function earcutLinked( ear, triangles, dim, minX, minY, invSize, pass ) {
 	// interlink polygon nodes in z-order
 	if ( ! pass && invSize ) indexCurve( ear, minX, minY, invSize );
 
-	var stop = ear,
+	let stop = ear,
 		prev, next;
 
 	// iterate through ears, slicing them one by one
@@ -178,14 +178,14 @@ function earcutLinked( ear, triangles, dim, minX, minY, invSize, pass ) {
 // check whether a polygon node forms a valid ear with adjacent nodes
 function isEar( ear ) {
 
-	var a = ear.prev,
+	let a = ear.prev,
 		b = ear,
 		c = ear.next;
 
 	if ( area( a, b, c ) >= 0 ) return false; // reflex, can't be an ear
 
 	// now make sure we don't have other points inside the potential ear
-	var p = ear.next.next;
+	let p = ear.next.next;
 
 	while ( p !== ear.prev ) {
 
@@ -201,23 +201,23 @@ function isEar( ear ) {
 
 function isEarHashed( ear, minX, minY, invSize ) {
 
-	var a = ear.prev,
+	let a = ear.prev,
 		b = ear,
 		c = ear.next;
 
 	if ( area( a, b, c ) >= 0 ) return false; // reflex, can't be an ear
 
 	// triangle bbox; min & max are calculated like this for speed
-	var minTX = a.x < b.x ? ( a.x < c.x ? a.x : c.x ) : ( b.x < c.x ? b.x : c.x ),
+	let minTX = a.x < b.x ? ( a.x < c.x ? a.x : c.x ) : ( b.x < c.x ? b.x : c.x ),
 		minTY = a.y < b.y ? ( a.y < c.y ? a.y : c.y ) : ( b.y < c.y ? b.y : c.y ),
 		maxTX = a.x > b.x ? ( a.x > c.x ? a.x : c.x ) : ( b.x > c.x ? b.x : c.x ),
 		maxTY = a.y > b.y ? ( a.y > c.y ? a.y : c.y ) : ( b.y > c.y ? b.y : c.y );
 
 	// z-order range for the current triangle bbox;
-	var minZ = zOrder( minTX, minTY, minX, minY, invSize ),
+	let minZ = zOrder( minTX, minTY, minX, minY, invSize ),
 		maxZ = zOrder( maxTX, maxTY, minX, minY, invSize );
 
-	var p = ear.prevZ,
+	let p = ear.prevZ,
 		n = ear.nextZ;
 
 	// look for points inside the triangle in both directions
@@ -262,10 +262,10 @@ function isEarHashed( ear, minX, minY, invSize ) {
 // go through all polygon nodes and cure small local self-intersections
 function cureLocalIntersections( start, triangles, dim ) {
 
-	var p = start;
+	let p = start;
 	do {
 
-		var a = p.prev,
+		let a = p.prev,
 			b = p.next.next;
 
 		if ( ! equals( a, b ) && intersects( a, p, p.next, b ) && locallyInside( a, b ) && locallyInside( b, a ) ) {
@@ -294,16 +294,16 @@ function cureLocalIntersections( start, triangles, dim ) {
 function splitEarcut( start, triangles, dim, minX, minY, invSize ) {
 
 	// look for a valid diagonal that divides the polygon into two
-	var a = start;
+	let a = start;
 	do {
 
-		var b = a.next.next;
+		let b = a.next.next;
 		while ( b !== a.prev ) {
 
 			if ( a.i !== b.i && isValidDiagonal( a, b ) ) {
 
 				// split the polygon in two by the diagonal
-				var c = splitPolygon( a, b );
+				let c = splitPolygon( a, b );
 
 				// filter colinear points around the cuts
 				a = filterPoints( a, a.next );
@@ -329,7 +329,7 @@ function splitEarcut( start, triangles, dim, minX, minY, invSize ) {
 // link every hole into the outer loop, producing a single-ring polygon without holes
 function eliminateHoles( data, holeIndices, outerNode, dim ) {
 
-	var queue = [],
+	let queue = [],
 		i, len, start, end, list;
 
 	for ( i = 0, len = holeIndices.length; i < len; i ++ ) {
@@ -368,7 +368,7 @@ function eliminateHole( hole, outerNode ) {
 	outerNode = findHoleBridge( hole, outerNode );
 	if ( outerNode ) {
 
-		var b = splitPolygon( outerNode, hole );
+		const b = splitPolygon( outerNode, hole );
 
 		// filter collinear points around the cuts
 		filterPoints( outerNode, outerNode.next );
@@ -381,7 +381,7 @@ function eliminateHole( hole, outerNode ) {
 // David Eberly's algorithm for finding a bridge between hole and outer polygon
 function findHoleBridge( hole, outerNode ) {
 
-	var p = outerNode,
+	let p = outerNode,
 		hx = hole.x,
 		hy = hole.y,
 		qx = - Infinity,
@@ -393,7 +393,7 @@ function findHoleBridge( hole, outerNode ) {
 
 		if ( hy <= p.y && hy >= p.next.y && p.next.y !== p.y ) {
 
-			var x = p.x + ( hy - p.y ) * ( p.next.x - p.x ) / ( p.next.y - p.y );
+			let x = p.x + ( hy - p.y ) * ( p.next.x - p.x ) / ( p.next.y - p.y );
 			if ( x <= hx && x > qx ) {
 
 				qx = x;
@@ -422,7 +422,7 @@ function findHoleBridge( hole, outerNode ) {
 	// if there are no points found, we have a valid connection;
 	// otherwise choose the point of the minimum angle with the ray as connection point
 
-	var stop = m,
+	let stop = m,
 		mx = m.x,
 		my = m.y,
 		tanMin = Infinity,
@@ -464,7 +464,7 @@ function sectorContainsSector( m, p ) {
 // interlink polygon nodes in z-order
 function indexCurve( start, minX, minY, invSize ) {
 
-	var p = start;
+	let p = start;
 	do {
 
 		if ( p.z === null ) p.z = zOrder( p.x, p.y, minX, minY, invSize );
@@ -485,7 +485,7 @@ function indexCurve( start, minX, minY, invSize ) {
 // http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html
 function sortLinked( list ) {
 
-	var i, p, q, e, tail, numMerges, pSize, qSize,
+	let i, p, q, e, tail, numMerges, pSize, qSize,
 		inSize = 1;
 
 	do {
@@ -571,7 +571,7 @@ function zOrder( x, y, minX, minY, invSize ) {
 // find the leftmost node of a polygon ring
 function getLeftmost( start ) {
 
-	var p = start,
+	let p = start,
 		leftmost = start;
 	do {
 
@@ -620,10 +620,10 @@ function equals( p1, p2 ) {
 // check if two segments intersect
 function intersects( p1, q1, p2, q2 ) {
 
-	var o1 = sign( area( p1, q1, p2 ) );
-	var o2 = sign( area( p1, q1, q2 ) );
-	var o3 = sign( area( p2, q2, p1 ) );
-	var o4 = sign( area( p2, q2, q1 ) );
+	const o1 = sign( area( p1, q1, p2 ) );
+	const o2 = sign( area( p1, q1, q2 ) );
+	const o3 = sign( area( p2, q2, p1 ) );
+	const o4 = sign( area( p2, q2, q1 ) );
 
 	if ( o1 !== o2 && o3 !== o4 ) return true; // general case
 
@@ -652,7 +652,7 @@ function sign( num ) {
 // check if a polygon diagonal intersects any polygon segments
 function intersectsPolygon( a, b ) {
 
-	var p = a;
+	let p = a;
 	do {
 
 		if ( p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i &&
@@ -677,7 +677,7 @@ function locallyInside( a, b ) {
 // check if the middle point of a polygon diagonal is inside the polygon
 function middleInside( a, b ) {
 
-	var p = a,
+	let p = a,
 		inside = false,
 		px = ( a.x + b.x ) / 2,
 		py = ( a.y + b.y ) / 2;
@@ -698,7 +698,7 @@ function middleInside( a, b ) {
 // if one belongs to the outer ring and another to a hole, it merges it into a single ring
 function splitPolygon( a, b ) {
 
-	var a2 = new Node( a.i, a.x, a.y ),
+	let a2 = new Node( a.i, a.x, a.y ),
 		b2 = new Node( b.i, b.x, b.y ),
 		an = a.next,
 		bp = b.prev;
@@ -722,7 +722,7 @@ function splitPolygon( a, b ) {
 // create a node and optionally link it with previous one (in a circular doubly linked list)
 function insertNode( i, x, y, last ) {
 
-	var p = new Node( i, x, y );
+	const p = new Node( i, x, y );
 
 	if ( ! last ) {
 
@@ -779,8 +779,8 @@ function Node( i, x, y ) {
 
 function signedArea( data, start, end, dim ) {
 
-	var sum = 0;
-	for ( var i = start, j = end - dim; i < end; i += dim ) {
+	let sum = 0;
+	for ( let i = start, j = end - dim; i < end; i += dim ) {
 
 		sum += ( data[ j ] - data[ i ] ) * ( data[ i + 1 ] + data[ j + 1 ] );
 		j = i;

+ 4 - 4
src/extras/ImageUtils.js

@@ -4,13 +4,13 @@
  * @author szimek / https://github.com/szimek/
  */
 
-var _canvas;
+let _canvas;
 
-var ImageUtils = {
+const ImageUtils = {
 
 	getDataURL: function ( image ) {
 
-		var canvas;
+		let canvas;
 
 		if ( typeof HTMLCanvasElement == 'undefined' ) {
 
@@ -27,7 +27,7 @@ var ImageUtils = {
 			_canvas.width = image.width;
 			_canvas.height = image.height;
 
-			var context = _canvas.getContext( '2d' );
+			const context = _canvas.getContext( '2d' );
 
 			if ( image instanceof ImageData ) {
 

+ 96 - 96
src/extras/PMREMGenerator.js

@@ -38,23 +38,23 @@ import { Vector2 } from "../math/Vector2.js";
 import { Vector3 } from "../math/Vector3.js";
 import { WebGLRenderTarget } from "../renderers/WebGLRenderTarget.js";
 
-var LOD_MIN = 4;
-var LOD_MAX = 8;
-var SIZE_MAX = Math.pow( 2, LOD_MAX );
+const LOD_MIN = 4;
+const LOD_MAX = 8;
+const SIZE_MAX = Math.pow( 2, LOD_MAX );
 
 // The standard deviations (radians) associated with the extra mips. These are
 // chosen to approximate a Trowbridge-Reitz distribution function times the
 // geometric shadowing function. These sigma values squared must match the
 // variance #defines in cube_uv_reflection_fragment.glsl.js.
-var EXTRA_LOD_SIGMA = [ 0.125, 0.215, 0.35, 0.446, 0.526, 0.582 ];
+const EXTRA_LOD_SIGMA = [ 0.125, 0.215, 0.35, 0.446, 0.526, 0.582 ];
 
-var TOTAL_LODS = LOD_MAX - LOD_MIN + 1 + EXTRA_LOD_SIGMA.length;
+const TOTAL_LODS = LOD_MAX - LOD_MIN + 1 + EXTRA_LOD_SIGMA.length;
 
 // The maximum length of the blur for loop. Smaller sigmas will use fewer
 // samples and exit early, but not recompile the shader.
-var MAX_SAMPLES = 20;
+const MAX_SAMPLES = 20;
 
-var ENCODINGS = {
+const ENCODINGS = {
 	[ LinearEncoding ]: 0,
 	[ sRGBEncoding ]: 1,
 	[ RGBEEncoding ]: 2,
@@ -64,17 +64,17 @@ var ENCODINGS = {
 	[ GammaEncoding ]: 6
 };
 
-var _flatCamera = new OrthographicCamera();
-var { _lodPlanes, _sizeLods, _sigmas } = _createPlanes();
-var _oldTarget = null;
+const _flatCamera = new OrthographicCamera();
+const { _lodPlanes, _sizeLods, _sigmas } = _createPlanes();
+let _oldTarget = null;
 
 // Golden Ratio
-var PHI = ( 1 + Math.sqrt( 5 ) ) / 2;
-var INV_PHI = 1 / PHI;
+const PHI = ( 1 + Math.sqrt( 5 ) ) / 2;
+const INV_PHI = 1 / PHI;
 
 // Vertices of a dodecahedron (except the opposites, which represent the
 // same axis), used as axis directions evenly spread on a sphere.
-var _axisDirections = [
+const _axisDirections = [
 	new Vector3( 1, 1, 1 ),
 	new Vector3( - 1, 1, 1 ),
 	new Vector3( 1, 1, - 1 ),
@@ -113,7 +113,7 @@ PMREMGenerator.prototype = {
 	fromScene: function ( scene, sigma = 0, near = 0.1, far = 100 ) {
 
 		_oldTarget = this._renderer.getRenderTarget();
-		var cubeUVRenderTarget = this._allocateTargets();
+		const cubeUVRenderTarget = this._allocateTargets();
 
 		this._sceneToCubeUV( scene, near, far, cubeUVRenderTarget );
 		if ( sigma > 0 ) {
@@ -152,7 +152,7 @@ PMREMGenerator.prototype = {
 	fromCubemap: function ( cubemap ) {
 
 		_oldTarget = this._renderer.getRenderTarget();
-		var cubeUVRenderTarget = this._allocateTargets( cubemap );
+		const cubeUVRenderTarget = this._allocateTargets( cubemap );
 		this._textureToCubeUV( cubemap, cubeUVRenderTarget );
 		this._applyPMREM( cubeUVRenderTarget );
 		this._cleanup( cubeUVRenderTarget );
@@ -203,7 +203,7 @@ PMREMGenerator.prototype = {
 		if ( this._cubemapShader !== null ) this._cubemapShader.dispose();
 		if ( this._equirectShader !== null ) this._equirectShader.dispose();
 
-		for ( var i = 0; i < _lodPlanes.length; i ++ ) {
+		for ( let i = 0; i < _lodPlanes.length; i ++ ) {
 
 			_lodPlanes[ i ].dispose();
 
@@ -225,7 +225,7 @@ PMREMGenerator.prototype = {
 
 	_allocateTargets: function ( equirectangular ) {
 
-		var params = {
+		const params = {
 			magFilter: NearestFilter,
 			minFilter: NearestFilter,
 			generateMipmaps: false,
@@ -236,7 +236,7 @@ PMREMGenerator.prototype = {
 			stencilBuffer: false
 		};
 
-		var cubeUVRenderTarget = _createRenderTarget( params );
+		const cubeUVRenderTarget = _createRenderTarget( params );
 		cubeUVRenderTarget.depthBuffer = equirectangular ? false : true;
 		this._pingPongRenderTarget = _createRenderTarget( params );
 		return cubeUVRenderTarget;
@@ -245,47 +245,47 @@ PMREMGenerator.prototype = {
 
 	_compileMaterial: function ( material ) {
 
-		var tmpMesh = new Mesh( _lodPlanes[ 0 ], material );
+		const tmpMesh = new Mesh( _lodPlanes[ 0 ], material );
 		this._renderer.compile( tmpMesh, _flatCamera );
 
 	},
 
 	_sceneToCubeUV: function ( scene, near, far, cubeUVRenderTarget ) {
 
-		var fov = 90;
-		var aspect = 1;
-		var cubeCamera = new PerspectiveCamera( fov, aspect, near, far );
-		var upSign = [ 1, - 1, 1, 1, 1, 1 ];
-		var forwardSign = [ 1, 1, 1, - 1, - 1, - 1 ];
-		var renderer = this._renderer;
+		const fov = 90;
+		const aspect = 1;
+		const cubeCamera = new PerspectiveCamera( fov, aspect, near, far );
+		const upSign = [ 1, - 1, 1, 1, 1, 1 ];
+		const forwardSign = [ 1, 1, 1, - 1, - 1, - 1 ];
+		const renderer = this._renderer;
 
-		var outputEncoding = renderer.outputEncoding;
-		var toneMapping = renderer.toneMapping;
-		var toneMappingExposure = renderer.toneMappingExposure;
-		var clearColor = renderer.getClearColor();
-		var clearAlpha = renderer.getClearAlpha();
+		const outputEncoding = renderer.outputEncoding;
+		const toneMapping = renderer.toneMapping;
+		const toneMappingExposure = renderer.toneMappingExposure;
+		const clearColor = renderer.getClearColor();
+		const clearAlpha = renderer.getClearAlpha();
 
 		renderer.toneMapping = LinearToneMapping;
 		renderer.toneMappingExposure = 1.0;
 		renderer.outputEncoding = LinearEncoding;
 
-		var background = scene.background;
+		let background = scene.background;
 		if ( background && background.isColor ) {
 
 			background.convertSRGBToLinear();
 			// Convert linear to RGBE
-			var maxComponent = Math.max( background.r, background.g, background.b );
-			var fExp = Math.min( Math.max( Math.ceil( Math.log2( maxComponent ) ), - 128.0 ), 127.0 );
+			const maxComponent = Math.max( background.r, background.g, background.b );
+			const fExp = Math.min( Math.max( Math.ceil( Math.log2( maxComponent ) ), - 128.0 ), 127.0 );
 			background = background.multiplyScalar( Math.pow( 2.0, - fExp ) );
-			var alpha = ( fExp + 128.0 ) / 255.0;
+			const alpha = ( fExp + 128.0 ) / 255.0;
 			renderer.setClearColor( background, alpha );
 			scene.background = null;
 
 		}
 
-		for ( var i = 0; i < 6; i ++ ) {
+		for ( let i = 0; i < 6; i ++ ) {
 
-			var col = i % 3;
+			const col = i % 3;
 			if ( col == 0 ) {
 
 				cubeCamera.up.set( 0, upSign[ i ], 0 );
@@ -319,7 +319,7 @@ PMREMGenerator.prototype = {
 
 	_textureToCubeUV: function ( texture, cubeUVRenderTarget ) {
 
-		var renderer = this._renderer;
+		const renderer = this._renderer;
 
 		if ( texture.isCubeTexture ) {
 
@@ -339,10 +339,10 @@ PMREMGenerator.prototype = {
 
 		}
 
-		var material = texture.isCubeTexture ? this._cubemapShader : this._equirectShader;
-		var mesh = new Mesh( _lodPlanes[ 0 ], material );
+		const material = texture.isCubeTexture ? this._cubemapShader : this._equirectShader;
+		const mesh = new Mesh( _lodPlanes[ 0 ], material );
 
-		var uniforms = material.uniforms;
+		const uniforms = material.uniforms;
 
 		uniforms[ 'envMap' ].value = texture;
 
@@ -364,15 +364,15 @@ PMREMGenerator.prototype = {
 
 	_applyPMREM: function ( cubeUVRenderTarget ) {
 
-		var renderer = this._renderer;
-		var autoClear = renderer.autoClear;
+		const renderer = this._renderer;
+		const autoClear = renderer.autoClear;
 		renderer.autoClear = false;
 
-		for ( var i = 1; i < TOTAL_LODS; i ++ ) {
+		for ( let i = 1; i < TOTAL_LODS; i ++ ) {
 
-			var sigma = Math.sqrt( _sigmas[ i ] * _sigmas[ i ] - _sigmas[ i - 1 ] * _sigmas[ i - 1 ] );
+			const sigma = Math.sqrt( _sigmas[ i ] * _sigmas[ i ] - _sigmas[ i - 1 ] * _sigmas[ i - 1 ] );
 
-			var poleAxis = _axisDirections[ ( i - 1 ) % _axisDirections.length ];
+			const poleAxis = _axisDirections[ ( i - 1 ) % _axisDirections.length ];
 
 			this._blur( cubeUVRenderTarget, i - 1, i, sigma, poleAxis );
 
@@ -391,7 +391,7 @@ PMREMGenerator.prototype = {
 	 */
 	_blur: function ( cubeUVRenderTarget, lodIn, lodOut, sigma, poleAxis ) {
 
-		var pingPongRenderTarget = this._pingPongRenderTarget;
+		const pingPongRenderTarget = this._pingPongRenderTarget;
 
 		this._halfBlur(
 			cubeUVRenderTarget,
@@ -415,8 +415,8 @@ PMREMGenerator.prototype = {
 
 	_halfBlur: function ( targetIn, targetOut, lodIn, lodOut, sigmaRadians, direction, poleAxis ) {
 
-		var renderer = this._renderer;
-		var blurMaterial = this._blurMaterial;
+		const renderer = this._renderer;
+		const blurMaterial = this._blurMaterial;
 
 		if ( direction !== 'latitudinal' && direction !== 'longitudinal' ) {
 
@@ -426,15 +426,15 @@ PMREMGenerator.prototype = {
 		}
 
 		// Number of standard deviations at which to cut off the discrete approximation.
-		var STANDARD_DEVIATIONS = 3;
+		const STANDARD_DEVIATIONS = 3;
 
-		var blurMesh = new Mesh( _lodPlanes[ lodOut ], blurMaterial );
-		var blurUniforms = blurMaterial.uniforms;
+		const blurMesh = new Mesh( _lodPlanes[ lodOut ], blurMaterial );
+		const blurUniforms = blurMaterial.uniforms;
 
-		var pixels = _sizeLods[ lodIn ] - 1;
-		var radiansPerPixel = isFinite( sigmaRadians ) ? Math.PI / ( 2 * pixels ) : 2 * Math.PI / ( 2 * MAX_SAMPLES - 1 );
-		var sigmaPixels = sigmaRadians / radiansPerPixel;
-		var samples = isFinite( sigmaRadians ) ? 1 + Math.floor( STANDARD_DEVIATIONS * sigmaPixels ) : MAX_SAMPLES;
+		const pixels = _sizeLods[ lodIn ] - 1;
+		const radiansPerPixel = isFinite( sigmaRadians ) ? Math.PI / ( 2 * pixels ) : 2 * Math.PI / ( 2 * MAX_SAMPLES - 1 );
+		const sigmaPixels = sigmaRadians / radiansPerPixel;
+		const samples = isFinite( sigmaRadians ) ? 1 + Math.floor( STANDARD_DEVIATIONS * sigmaPixels ) : MAX_SAMPLES;
 
 		if ( samples > MAX_SAMPLES ) {
 
@@ -444,13 +444,13 @@ PMREMGenerator.prototype = {
 
 		}
 
-		var weights = [];
-		var sum = 0;
+		const weights = [];
+		let sum = 0;
 
-		for ( var i = 0; i < MAX_SAMPLES; ++ i ) {
+		for ( let i = 0; i < MAX_SAMPLES; ++ i ) {
 
-			var x = i / sigmaPixels;
-			var weight = Math.exp( - x * x / 2 );
+			const x = i / sigmaPixels;
+			const weight = Math.exp( - x * x / 2 );
 			weights.push( weight );
 
 			if ( i == 0 ) {
@@ -465,7 +465,7 @@ PMREMGenerator.prototype = {
 
 		}
 
-		for ( var i = 0; i < weights.length; i ++ ) {
+		for ( let i = 0; i < weights.length; i ++ ) {
 
 			weights[ i ] = weights[ i ] / sum;
 
@@ -487,9 +487,9 @@ PMREMGenerator.prototype = {
 		blurUniforms[ 'inputEncoding' ].value = ENCODINGS[ targetIn.texture.encoding ];
 		blurUniforms[ 'outputEncoding' ].value = ENCODINGS[ targetIn.texture.encoding ];
 
-		var outputSize = _sizeLods[ lodOut ];
-		var x = 3 * Math.max( 0, SIZE_MAX - 2 * outputSize );
-		var y = ( lodOut === 0 ? 0 : 2 * SIZE_MAX ) + 2 * outputSize * ( lodOut > LOD_MAX - LOD_MIN ? lodOut - LOD_MAX + LOD_MIN : 0 );
+		const outputSize = _sizeLods[ lodOut ];
+		const x = 3 * Math.max( 0, SIZE_MAX - 2 * outputSize );
+		const y = ( lodOut === 0 ? 0 : 2 * SIZE_MAX ) + 2 * outputSize * ( lodOut > LOD_MAX - LOD_MIN ? lodOut - LOD_MAX + LOD_MIN : 0 );
 
 		_setViewport( targetOut, x, y, 3 * outputSize, 2 * outputSize );
 		renderer.setRenderTarget( targetOut );
@@ -509,17 +509,17 @@ function _isLDR( texture ) {
 
 function _createPlanes() {
 
-	var _lodPlanes = [];
-	var _sizeLods = [];
-	var _sigmas = [];
+	const _lodPlanes = [];
+	const _sizeLods = [];
+	const _sigmas = [];
 
-	var lod = LOD_MAX;
+	let lod = LOD_MAX;
 
-	for ( var i = 0; i < TOTAL_LODS; i ++ ) {
+	for ( let i = 0; i < TOTAL_LODS; i ++ ) {
 
-		var sizeLod = Math.pow( 2, lod );
+		const sizeLod = Math.pow( 2, lod );
 		_sizeLods.push( sizeLod );
-		var sigma = 1.0 / sizeLod;
+		let sigma = 1.0 / sizeLod;
 
 		if ( i > LOD_MAX - LOD_MIN ) {
 
@@ -533,26 +533,26 @@ function _createPlanes() {
 
 		_sigmas.push( sigma );
 
-		var texelSize = 1.0 / ( sizeLod - 1 );
-		var min = - texelSize / 2;
-		var max = 1 + texelSize / 2;
-		var uv1 = [ min, min, max, min, max, max, min, min, max, max, min, max ];
+		const texelSize = 1.0 / ( sizeLod - 1 );
+		const min = - texelSize / 2;
+		const max = 1 + texelSize / 2;
+		const uv1 = [ min, min, max, min, max, max, min, min, max, max, min, max ];
 
-		var cubeFaces = 6;
-		var vertices = 6;
-		var positionSize = 3;
-		var uvSize = 2;
-		var faceIndexSize = 1;
+		const cubeFaces = 6;
+		const vertices = 6;
+		const positionSize = 3;
+		const uvSize = 2;
+		const faceIndexSize = 1;
 
-		var position = new Float32Array( positionSize * vertices * cubeFaces );
-		var uv = new Float32Array( uvSize * vertices * cubeFaces );
-		var faceIndex = new Float32Array( faceIndexSize * vertices * cubeFaces );
+		const position = new Float32Array( positionSize * vertices * cubeFaces );
+		const uv = new Float32Array( uvSize * vertices * cubeFaces );
+		const faceIndex = new Float32Array( faceIndexSize * vertices * cubeFaces );
 
-		for ( var face = 0; face < cubeFaces; face ++ ) {
+		for ( let face = 0; face < cubeFaces; face ++ ) {
 
-			var x = ( face % 3 ) * 2 / 3 - 1;
-			var y = face > 2 ? 0 : - 1;
-			var coordinates = [
+			const x = ( face % 3 ) * 2 / 3 - 1;
+			const y = face > 2 ? 0 : - 1;
+			const coordinates = [
 				x, y, 0,
 				x + 2 / 3, y, 0,
 				x + 2 / 3, y + 1, 0,
@@ -562,12 +562,12 @@ function _createPlanes() {
 			];
 			position.set( coordinates, positionSize * vertices * face );
 			uv.set( uv1, uvSize * vertices * face );
-			var fill = [ face, face, face, face, face, face ];
+			const fill = [ face, face, face, face, face, face ];
 			faceIndex.set( fill, faceIndexSize * vertices * face );
 
 		}
 
-		var planes = new BufferGeometry();
+		const planes = new BufferGeometry();
 		planes.setAttribute( 'position', new BufferAttribute( position, positionSize ) );
 		planes.setAttribute( 'uv', new BufferAttribute( uv, uvSize ) );
 		planes.setAttribute( 'faceIndex', new BufferAttribute( faceIndex, faceIndexSize ) );
@@ -587,7 +587,7 @@ function _createPlanes() {
 
 function _createRenderTarget( params ) {
 
-	var cubeUVRenderTarget = new WebGLRenderTarget( 3 * SIZE_MAX, 3 * SIZE_MAX, params );
+	const cubeUVRenderTarget = new WebGLRenderTarget( 3 * SIZE_MAX, 3 * SIZE_MAX, params );
 	cubeUVRenderTarget.texture.mapping = CubeUVReflectionMapping;
 	cubeUVRenderTarget.texture.name = 'PMREM.cubeUv';
 	cubeUVRenderTarget.scissorTest = true;
@@ -604,9 +604,9 @@ function _setViewport( target, x, y, width, height ) {
 
 function _getBlurShader( maxSamples ) {
 
-	var weights = new Float32Array( maxSamples );
-	var poleAxis = new Vector3( 0, 1, 0 );
-	var shaderMaterial = new RawShaderMaterial( {
+	const weights = new Float32Array( maxSamples );
+	const poleAxis = new Vector3( 0, 1, 0 );
+	const shaderMaterial = new RawShaderMaterial( {
 
 		defines: { 'n': maxSamples },
 
@@ -682,8 +682,8 @@ void main() {
 
 function _getEquirectShader() {
 
-	var texelSize = new Vector2( 1, 1 );
-	var shaderMaterial = new RawShaderMaterial( {
+	const texelSize = new Vector2( 1, 1 );
+	const shaderMaterial = new RawShaderMaterial( {
 
 		uniforms: {
 			'envMap': { value: null },
@@ -739,7 +739,7 @@ void main() {
 
 function _getCubemapShader() {
 
-	var shaderMaterial = new RawShaderMaterial( {
+	const shaderMaterial = new RawShaderMaterial( {
 
 		uniforms: {
 			'envMap': { value: null },

+ 13 - 13
src/extras/ShapeUtils.js

@@ -4,16 +4,16 @@
 
 import { Earcut } from './Earcut.js';
 
-var ShapeUtils = {
+const ShapeUtils = {
 
 	// calculate area of the contour polygon
 
 	area: function ( contour ) {
 
-		var n = contour.length;
-		var a = 0.0;
+		const n = contour.length;
+		let a = 0.0;
 
-		for ( var p = n - 1, q = 0; q < n; p = q ++ ) {
+		for ( let p = n - 1, q = 0; q < n; p = q ++ ) {
 
 			a += contour[ p ].x * contour[ q ].y - contour[ q ].x * contour[ p ].y;
 
@@ -31,20 +31,20 @@ var ShapeUtils = {
 
 	triangulateShape: function ( contour, holes ) {
 
-		var vertices = []; // flat array of vertices like [ x0,y0, x1,y1, x2,y2, ... ]
-		var holeIndices = []; // array of hole indices
-		var faces = []; // final array of vertex indices like [ [ a,b,d ], [ b,c,d ] ]
+		const vertices = []; // flat array of vertices like [ x0,y0, x1,y1, x2,y2, ... ]
+		const holeIndices = []; // array of hole indices
+		const faces = []; // final array of vertex indices like [ [ a,b,d ], [ b,c,d ] ]
 
 		removeDupEndPts( contour );
 		addContour( vertices, contour );
 
 		//
 
-		var holeIndex = contour.length;
+		let holeIndex = contour.length;
 
 		holes.forEach( removeDupEndPts );
 
-		for ( var i = 0; i < holes.length; i ++ ) {
+		for ( let i = 0; i < holes.length; i ++ ) {
 
 			holeIndices.push( holeIndex );
 			holeIndex += holes[ i ].length;
@@ -54,11 +54,11 @@ var ShapeUtils = {
 
 		//
 
-		var triangles = Earcut.triangulate( vertices, holeIndices );
+		const triangles = Earcut.triangulate( vertices, holeIndices );
 
 		//
 
-		for ( var i = 0; i < triangles.length; i += 3 ) {
+		for ( let i = 0; i < triangles.length; i += 3 ) {
 
 			faces.push( triangles.slice( i, i + 3 ) );
 
@@ -72,7 +72,7 @@ var ShapeUtils = {
 
 function removeDupEndPts( points ) {
 
-	var l = points.length;
+	const l = points.length;
 
 	if ( l > 2 && points[ l - 1 ].equals( points[ 0 ] ) ) {
 
@@ -84,7 +84,7 @@ function removeDupEndPts( points ) {
 
 function addContour( vertices, contour ) {
 
-	for ( var i = 0; i < contour.length; i ++ ) {
+	for ( let i = 0; i < contour.length; i ++ ) {
 
 		vertices.push( contour[ i ].x );
 		vertices.push( contour[ i ].y );

+ 43 - 45
src/extras/core/Curve.js

@@ -63,7 +63,7 @@ Object.assign( Curve.prototype, {
 
 	getPointAt: function ( u, optionalTarget ) {
 
-		var t = this.getUtoTmapping( u );
+		const t = this.getUtoTmapping( u );
 		return this.getPoint( t, optionalTarget );
 
 	},
@@ -74,9 +74,9 @@ Object.assign( Curve.prototype, {
 
 		if ( divisions === undefined ) divisions = 5;
 
-		var points = [];
+		const points = [];
 
-		for ( var d = 0; d <= divisions; d ++ ) {
+		for ( let d = 0; d <= divisions; d ++ ) {
 
 			points.push( this.getPoint( d / divisions ) );
 
@@ -92,9 +92,9 @@ Object.assign( Curve.prototype, {
 
 		if ( divisions === undefined ) divisions = 5;
 
-		var points = [];
+		const points = [];
 
-		for ( var d = 0; d <= divisions; d ++ ) {
+		for ( let d = 0; d <= divisions; d ++ ) {
 
 			points.push( this.getPointAt( d / divisions ) );
 
@@ -108,7 +108,7 @@ Object.assign( Curve.prototype, {
 
 	getLength: function () {
 
-		var lengths = this.getLengths();
+		const lengths = this.getLengths();
 		return lengths[ lengths.length - 1 ];
 
 	},
@@ -129,13 +129,13 @@ Object.assign( Curve.prototype, {
 
 		this.needsUpdate = false;
 
-		var cache = [];
-		var current, last = this.getPoint( 0 );
-		var p, sum = 0;
+		const cache = [];
+		let current, last = this.getPoint( 0 );
+		let sum = 0;
 
 		cache.push( 0 );
 
-		for ( p = 1; p <= divisions; p ++ ) {
+		for ( let p = 1; p <= divisions; p ++ ) {
 
 			current = this.getPoint( p / divisions );
 			sum += current.distanceTo( last );
@@ -161,11 +161,11 @@ Object.assign( Curve.prototype, {
 
 	getUtoTmapping: function ( u, distance ) {
 
-		var arcLengths = this.getLengths();
+		const arcLengths = this.getLengths();
 
-		var i = 0, il = arcLengths.length;
+		let i = 0, il = arcLengths.length;
 
-		var targetArcLength; // The targeted u distance value to get
+		let targetArcLength; // The targeted u distance value to get
 
 		if ( distance ) {
 
@@ -179,7 +179,7 @@ Object.assign( Curve.prototype, {
 
 		// binary search for the index with largest value smaller than target u distance
 
-		var low = 0, high = il - 1, comparison;
+		let low = 0, high = il - 1, comparison;
 
 		while ( low <= high ) {
 
@@ -216,18 +216,18 @@ Object.assign( Curve.prototype, {
 
 		// we could get finer grain at lengths, or use simple interpolation between two points
 
-		var lengthBefore = arcLengths[ i ];
-		var lengthAfter = arcLengths[ i + 1 ];
+		const lengthBefore = arcLengths[ i ];
+		const lengthAfter = arcLengths[ i + 1 ];
 
-		var segmentLength = lengthAfter - lengthBefore;
+		const segmentLength = lengthAfter - lengthBefore;
 
 		// determine where we are between the 'before' and 'after' points
 
-		var segmentFraction = ( targetArcLength - lengthBefore ) / segmentLength;
+		const segmentFraction = ( targetArcLength - lengthBefore ) / segmentLength;
 
 		// add that fractional amount to t
 
-		var t = ( i + segmentFraction ) / ( il - 1 );
+		const t = ( i + segmentFraction ) / ( il - 1 );
 
 		return t;
 
@@ -240,19 +240,19 @@ Object.assign( Curve.prototype, {
 
 	getTangent: function ( t, optionalTarget ) {
 
-		var delta = 0.0001;
-		var t1 = t - delta;
-		var t2 = t + delta;
+		const delta = 0.0001;
+		let t1 = t - delta;
+		let t2 = t + delta;
 
 		// Capping in case of danger
 
 		if ( t1 < 0 ) t1 = 0;
 		if ( t2 > 1 ) t2 = 1;
 
-		var pt1 = this.getPoint( t1 );
-		var pt2 = this.getPoint( t2 );
+		const pt1 = this.getPoint( t1 );
+		const pt2 = this.getPoint( t2 );
 
-		var tangent = optionalTarget || ( ( pt1.isVector2 ) ? new Vector2() : new Vector3() );
+		const tangent = optionalTarget || ( ( pt1.isVector2 ) ? new Vector2() : new Vector3() );
 
 		tangent.copy( pt2 ).sub( pt1 ).normalize();
 
@@ -262,7 +262,7 @@ Object.assign( Curve.prototype, {
 
 	getTangentAt: function ( u, optionalTarget ) {
 
-		var t = this.getUtoTmapping( u );
+		const t = this.getUtoTmapping( u );
 		return this.getTangent( t, optionalTarget );
 
 	},
@@ -271,22 +271,20 @@ Object.assign( Curve.prototype, {
 
 		// see http://www.cs.indiana.edu/pub/techreports/TR425.pdf
 
-		var normal = new Vector3();
+		const normal = new Vector3();
 
-		var tangents = [];
-		var normals = [];
-		var binormals = [];
+		const tangents = [];
+		const normals = [];
+		const binormals = [];
 
-		var vec = new Vector3();
-		var mat = new Matrix4();
-
-		var i, u, theta;
+		const vec = new Vector3();
+		const mat = new Matrix4();
 
 		// compute the tangent vectors for each segment on the curve
 
-		for ( i = 0; i <= segments; i ++ ) {
+		for ( let i = 0; i <= segments; i ++ ) {
 
-			u = i / segments;
+			const u = i / segments;
 
 			tangents[ i ] = this.getTangentAt( u, new Vector3() );
 			tangents[ i ].normalize();
@@ -298,10 +296,10 @@ Object.assign( Curve.prototype, {
 
 		normals[ 0 ] = new Vector3();
 		binormals[ 0 ] = new Vector3();
-		var min = Number.MAX_VALUE;
-		var tx = Math.abs( tangents[ 0 ].x );
-		var ty = Math.abs( tangents[ 0 ].y );
-		var tz = Math.abs( tangents[ 0 ].z );
+		let min = Number.MAX_VALUE;
+		const tx = Math.abs( tangents[ 0 ].x );
+		const ty = Math.abs( tangents[ 0 ].y );
+		const tz = Math.abs( tangents[ 0 ].z );
 
 		if ( tx <= min ) {
 
@@ -331,7 +329,7 @@ Object.assign( Curve.prototype, {
 
 		// compute the slowly-varying normal and binormal vectors for each segment on the curve
 
-		for ( i = 1; i <= segments; i ++ ) {
+		for ( let i = 1; i <= segments; i ++ ) {
 
 			normals[ i ] = normals[ i - 1 ].clone();
 
@@ -343,7 +341,7 @@ Object.assign( Curve.prototype, {
 
 				vec.normalize();
 
-				theta = Math.acos( MathUtils.clamp( tangents[ i - 1 ].dot( tangents[ i ] ), - 1, 1 ) ); // clamp for floating pt errors
+				const theta = Math.acos( MathUtils.clamp( tangents[ i - 1 ].dot( tangents[ i ] ), - 1, 1 ) ); // clamp for floating pt errors
 
 				normals[ i ].applyMatrix4( mat.makeRotationAxis( vec, theta ) );
 
@@ -357,7 +355,7 @@ Object.assign( Curve.prototype, {
 
 		if ( closed === true ) {
 
-			theta = Math.acos( MathUtils.clamp( normals[ 0 ].dot( normals[ segments ] ), - 1, 1 ) );
+			let theta = Math.acos( MathUtils.clamp( normals[ 0 ].dot( normals[ segments ] ), - 1, 1 ) );
 			theta /= segments;
 
 			if ( tangents[ 0 ].dot( vec.crossVectors( normals[ 0 ], normals[ segments ] ) ) > 0 ) {
@@ -366,7 +364,7 @@ Object.assign( Curve.prototype, {
 
 			}
 
-			for ( i = 1; i <= segments; i ++ ) {
+			for ( let i = 1; i <= segments; i ++ ) {
 
 				// twist a little...
 				normals[ i ].applyMatrix4( mat.makeRotationAxis( tangents[ i ], theta * i ) );
@@ -400,7 +398,7 @@ Object.assign( Curve.prototype, {
 
 	toJSON: function () {
 
-		var data = {
+		const data = {
 			metadata: {
 				version: 4.5,
 				type: 'Curve',

+ 30 - 28
src/extras/core/CurvePath.js

@@ -35,8 +35,8 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), {
 	closePath: function () {
 
 		// Add a line curve if start and end of lines are not connected
-		var startPoint = this.curves[ 0 ].getPoint( 0 );
-		var endPoint = this.curves[ this.curves.length - 1 ].getPoint( 1 );
+		const startPoint = this.curves[ 0 ].getPoint( 0 );
+		const endPoint = this.curves[ this.curves.length - 1 ].getPoint( 1 );
 
 		if ( ! startPoint.equals( endPoint ) ) {
 
@@ -57,9 +57,9 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), {
 
 	getPoint: function ( t ) {
 
-		var d = t * this.getLength();
-		var curveLengths = this.getCurveLengths();
-		var i = 0;
+		const d = t * this.getLength();
+		const curveLengths = this.getCurveLengths();
+		let i = 0;
 
 		// To think about boundaries points.
 
@@ -67,11 +67,11 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), {
 
 			if ( curveLengths[ i ] >= d ) {
 
-				var diff = curveLengths[ i ] - d;
-				var curve = this.curves[ i ];
+				const diff = curveLengths[ i ] - d;
+				const curve = this.curves[ i ];
 
-				var segmentLength = curve.getLength();
-				var u = segmentLength === 0 ? 0 : 1 - diff / segmentLength;
+				const segmentLength = curve.getLength();
+				const u = segmentLength === 0 ? 0 : 1 - diff / segmentLength;
 
 				return curve.getPointAt( u );
 
@@ -93,7 +93,7 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), {
 
 	getLength: function () {
 
-		var lens = this.getCurveLengths();
+		const lens = this.getCurveLengths();
 		return lens[ lens.length - 1 ];
 
 	},
@@ -123,9 +123,10 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), {
 		// Get length of sub-curve
 		// Push sums into cached array
 
-		var lengths = [], sums = 0;
+		const lengths = [];
+		let sums = 0;
 
-		for ( var i = 0, l = this.curves.length; i < l; i ++ ) {
+		for ( let i = 0, l = this.curves.length; i < l; i ++ ) {
 
 			sums += this.curves[ i ].getLength();
 			lengths.push( sums );
@@ -142,9 +143,9 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), {
 
 		if ( divisions === undefined ) divisions = 40;
 
-		var points = [];
+		const points = [];
 
-		for ( var i = 0; i <= divisions; i ++ ) {
+		for ( let i = 0; i <= divisions; i ++ ) {
 
 			points.push( this.getPoint( i / divisions ) );
 
@@ -164,21 +165,22 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), {
 
 		divisions = divisions || 12;
 
-		var points = [], last;
+		const points = [];
+		let last;
 
-		for ( var i = 0, curves = this.curves; i < curves.length; i ++ ) {
+		for ( let i = 0, curves = this.curves; i < curves.length; i ++ ) {
 
-			var curve = curves[ i ];
-			var resolution = ( curve && curve.isEllipseCurve ) ? divisions * 2
+			const curve = curves[ i ];
+			const resolution = ( curve && curve.isEllipseCurve ) ? divisions * 2
 				: ( curve && ( curve.isLineCurve || curve.isLineCurve3 ) ) ? 1
 					: ( curve && curve.isSplineCurve ) ? divisions * curve.points.length
 						: divisions;
 
-			var pts = curve.getPoints( resolution );
+			const pts = curve.getPoints( resolution );
 
-			for ( var j = 0; j < pts.length; j ++ ) {
+			for ( let j = 0; j < pts.length; j ++ ) {
 
-				var point = pts[ j ];
+				const point = pts[ j ];
 
 				if ( last && last.equals( point ) ) continue; // ensures no consecutive points are duplicates
 
@@ -205,9 +207,9 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), {
 
 		this.curves = [];
 
-		for ( var i = 0, l = source.curves.length; i < l; i ++ ) {
+		for ( let i = 0, l = source.curves.length; i < l; i ++ ) {
 
-			var curve = source.curves[ i ];
+			const curve = source.curves[ i ];
 
 			this.curves.push( curve.clone() );
 
@@ -221,14 +223,14 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), {
 
 	toJSON: function () {
 
-		var data = Curve.prototype.toJSON.call( this );
+		const data = Curve.prototype.toJSON.call( this );
 
 		data.autoClose = this.autoClose;
 		data.curves = [];
 
-		for ( var i = 0, l = this.curves.length; i < l; i ++ ) {
+		for ( let i = 0, l = this.curves.length; i < l; i ++ ) {
 
-			var curve = this.curves[ i ];
+			const curve = this.curves[ i ];
 			data.curves.push( curve.toJSON() );
 
 		}
@@ -244,9 +246,9 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), {
 		this.autoClose = json.autoClose;
 		this.curves = [];
 
-		for ( var i = 0, l = json.curves.length; i < l; i ++ ) {
+		for ( let i = 0, l = json.curves.length; i < l; i ++ ) {
 
-			var curve = json.curves[ i ];
+			const curve = json.curves[ i ];
 			this.curves.push( new Curves[ curve.type ]().fromJSON( curve ) );
 
 		}

+ 17 - 17
src/extras/core/Font.js

@@ -22,10 +22,10 @@ Object.assign( Font.prototype, {
 
 		if ( size === undefined ) size = 100;
 
-		var shapes = [];
-		var paths = createPaths( text, size, this.data );
+		const shapes = [];
+		const paths = createPaths( text, size, this.data );
 
-		for ( var p = 0, pl = paths.length; p < pl; p ++ ) {
+		for ( let p = 0, pl = paths.length; p < pl; p ++ ) {
 
 			Array.prototype.push.apply( shapes, paths[ p ].toShapes() );
 
@@ -39,17 +39,17 @@ Object.assign( Font.prototype, {
 
 function createPaths( text, size, data ) {
 
-	var chars = Array.from ? Array.from( text ) : String( text ).split( '' ); // workaround for IE11, see #13988
-	var scale = size / data.resolution;
-	var line_height = ( data.boundingBox.yMax - data.boundingBox.yMin + data.underlineThickness ) * scale;
+	const chars = Array.from ? Array.from( text ) : String( text ).split( '' ); // workaround for IE11, see #13988
+	const scale = size / data.resolution;
+	const line_height = ( data.boundingBox.yMax - data.boundingBox.yMin + data.underlineThickness ) * scale;
 
-	var paths = [];
+	const paths = [];
 
-	var offsetX = 0, offsetY = 0;
+	let offsetX = 0, offsetY = 0;
 
-	for ( var i = 0; i < chars.length; i ++ ) {
+	for ( let i = 0; i < chars.length; i ++ ) {
 
-		var char = chars[ i ];
+		const char = chars[ i ];
 
 		if ( char === '\n' ) {
 
@@ -58,7 +58,7 @@ function createPaths( text, size, data ) {
 
 		} else {
 
-			var ret = createPath( char, scale, offsetX, offsetY, data );
+			const ret = createPath( char, scale, offsetX, offsetY, data );
 			offsetX += ret.offsetX;
 			paths.push( ret.path );
 
@@ -72,7 +72,7 @@ function createPaths( text, size, data ) {
 
 function createPath( char, scale, offsetX, offsetY, data ) {
 
-	var glyph = data.glyphs[ char ] || data.glyphs[ '?' ];
+	const glyph = data.glyphs[ char ] || data.glyphs[ '?' ];
 
 	if ( ! glyph ) {
 
@@ -82,17 +82,17 @@ function createPath( char, scale, offsetX, offsetY, data ) {
 
 	}
 
-	var path = new ShapePath();
+	const path = new ShapePath();
 
-	var x, y, cpx, cpy, cpx1, cpy1, cpx2, cpy2;
+	let x, y, cpx, cpy, cpx1, cpy1, cpx2, cpy2;
 
 	if ( glyph.o ) {
 
-		var outline = glyph._cachedOutline || ( glyph._cachedOutline = glyph.o.split( ' ' ) );
+		const outline = glyph._cachedOutline || ( glyph._cachedOutline = glyph.o.split( ' ' ) );
 
-		for ( var i = 0, l = outline.length; i < l; ) {
+		for ( let i = 0, l = outline.length; i < l; ) {
 
-			var action = outline[ i ++ ];
+			const action = outline[ i ++ ];
 
 			switch ( action ) {
 

+ 7 - 7
src/extras/core/Interpolations.js

@@ -7,10 +7,10 @@
 
 function CatmullRom( t, p0, p1, p2, p3 ) {
 
-	var v0 = ( p2 - p0 ) * 0.5;
-	var v1 = ( p3 - p1 ) * 0.5;
-	var t2 = t * t;
-	var t3 = t * t2;
+	const v0 = ( p2 - p0 ) * 0.5;
+	const v1 = ( p3 - p1 ) * 0.5;
+	const t2 = t * t;
+	const t3 = t * t2;
 	return ( 2 * p1 - 2 * p2 + v0 + v1 ) * t3 + ( - 3 * p1 + 3 * p2 - 2 * v0 - v1 ) * t2 + v0 * t + p1;
 
 }
@@ -19,7 +19,7 @@ function CatmullRom( t, p0, p1, p2, p3 ) {
 
 function QuadraticBezierP0( t, p ) {
 
-	var k = 1 - t;
+	const k = 1 - t;
 	return k * k * p;
 
 }
@@ -47,14 +47,14 @@ function QuadraticBezier( t, p0, p1, p2 ) {
 
 function CubicBezierP0( t, p ) {
 
-	var k = 1 - t;
+	const k = 1 - t;
 	return k * k * k * p;
 
 }
 
 function CubicBezierP1( t, p ) {
 
-	var k = 1 - t;
+	const k = 1 - t;
 	return 3 * k * k * t * p;
 
 }

+ 14 - 14
src/extras/core/Path.js

@@ -35,7 +35,7 @@ Path.prototype = Object.assign( Object.create( CurvePath.prototype ), {
 
 		this.moveTo( points[ 0 ].x, points[ 0 ].y );
 
-		for ( var i = 1, l = points.length; i < l; i ++ ) {
+		for ( let i = 1, l = points.length; i < l; i ++ ) {
 
 			this.lineTo( points[ i ].x, points[ i ].y );
 
@@ -55,7 +55,7 @@ Path.prototype = Object.assign( Object.create( CurvePath.prototype ), {
 
 	lineTo: function ( x, y ) {
 
-		var curve = new LineCurve( this.currentPoint.clone(), new Vector2( x, y ) );
+		const curve = new LineCurve( this.currentPoint.clone(), new Vector2( x, y ) );
 		this.curves.push( curve );
 
 		this.currentPoint.set( x, y );
@@ -66,7 +66,7 @@ Path.prototype = Object.assign( Object.create( CurvePath.prototype ), {
 
 	quadraticCurveTo: function ( aCPx, aCPy, aX, aY ) {
 
-		var curve = new QuadraticBezierCurve(
+		const curve = new QuadraticBezierCurve(
 			this.currentPoint.clone(),
 			new Vector2( aCPx, aCPy ),
 			new Vector2( aX, aY )
@@ -82,7 +82,7 @@ Path.prototype = Object.assign( Object.create( CurvePath.prototype ), {
 
 	bezierCurveTo: function ( aCP1x, aCP1y, aCP2x, aCP2y, aX, aY ) {
 
-		var curve = new CubicBezierCurve(
+		const curve = new CubicBezierCurve(
 			this.currentPoint.clone(),
 			new Vector2( aCP1x, aCP1y ),
 			new Vector2( aCP2x, aCP2y ),
@@ -99,9 +99,9 @@ Path.prototype = Object.assign( Object.create( CurvePath.prototype ), {
 
 	splineThru: function ( pts /*Array of Vector*/ ) {
 
-		var npts = [ this.currentPoint.clone() ].concat( pts );
+		const npts = [ this.currentPoint.clone() ].concat( pts );
 
-		var curve = new SplineCurve( npts );
+		const curve = new SplineCurve( npts );
 		this.curves.push( curve );
 
 		this.currentPoint.copy( pts[ pts.length - 1 ] );
@@ -112,8 +112,8 @@ Path.prototype = Object.assign( Object.create( CurvePath.prototype ), {
 
 	arc: function ( aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise ) {
 
-		var x0 = this.currentPoint.x;
-		var y0 = this.currentPoint.y;
+		const x0 = this.currentPoint.x;
+		const y0 = this.currentPoint.y;
 
 		this.absarc( aX + x0, aY + y0, aRadius,
 			aStartAngle, aEndAngle, aClockwise );
@@ -132,8 +132,8 @@ Path.prototype = Object.assign( Object.create( CurvePath.prototype ), {
 
 	ellipse: function ( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation ) {
 
-		var x0 = this.currentPoint.x;
-		var y0 = this.currentPoint.y;
+		const x0 = this.currentPoint.x;
+		const y0 = this.currentPoint.y;
 
 		this.absellipse( aX + x0, aY + y0, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation );
 
@@ -143,12 +143,12 @@ Path.prototype = Object.assign( Object.create( CurvePath.prototype ), {
 
 	absellipse: function ( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation ) {
 
-		var curve = new EllipseCurve( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation );
+		const curve = new EllipseCurve( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation );
 
 		if ( this.curves.length > 0 ) {
 
 			// if a previous curve is present, attempt to join
-			var firstPoint = curve.getPoint( 0 );
+			const firstPoint = curve.getPoint( 0 );
 
 			if ( ! firstPoint.equals( this.currentPoint ) ) {
 
@@ -160,7 +160,7 @@ Path.prototype = Object.assign( Object.create( CurvePath.prototype ), {
 
 		this.curves.push( curve );
 
-		var lastPoint = curve.getPoint( 1 );
+		const lastPoint = curve.getPoint( 1 );
 		this.currentPoint.copy( lastPoint );
 
 		return this;
@@ -179,7 +179,7 @@ Path.prototype = Object.assign( Object.create( CurvePath.prototype ), {
 
 	toJSON: function () {
 
-		var data = CurvePath.prototype.toJSON.call( this );
+		const data = CurvePath.prototype.toJSON.call( this );
 
 		data.currentPoint = this.currentPoint.toArray();
 

+ 9 - 9
src/extras/core/Shape.js

@@ -30,9 +30,9 @@ Shape.prototype = Object.assign( Object.create( Path.prototype ), {
 
 	getPointsHoles: function ( divisions ) {
 
-		var holesPts = [];
+		const holesPts = [];
 
-		for ( var i = 0, l = this.holes.length; i < l; i ++ ) {
+		for ( let i = 0, l = this.holes.length; i < l; i ++ ) {
 
 			holesPts[ i ] = this.holes[ i ].getPoints( divisions );
 
@@ -61,9 +61,9 @@ Shape.prototype = Object.assign( Object.create( Path.prototype ), {
 
 		this.holes = [];
 
-		for ( var i = 0, l = source.holes.length; i < l; i ++ ) {
+		for ( let i = 0, l = source.holes.length; i < l; i ++ ) {
 
-			var hole = source.holes[ i ];
+			const hole = source.holes[ i ];
 
 			this.holes.push( hole.clone() );
 
@@ -75,14 +75,14 @@ Shape.prototype = Object.assign( Object.create( Path.prototype ), {
 
 	toJSON: function () {
 
-		var data = Path.prototype.toJSON.call( this );
+		const data = Path.prototype.toJSON.call( this );
 
 		data.uuid = this.uuid;
 		data.holes = [];
 
-		for ( var i = 0, l = this.holes.length; i < l; i ++ ) {
+		for ( let i = 0, l = this.holes.length; i < l; i ++ ) {
 
-			var hole = this.holes[ i ];
+			const hole = this.holes[ i ];
 			data.holes.push( hole.toJSON() );
 
 		}
@@ -98,9 +98,9 @@ Shape.prototype = Object.assign( Object.create( Path.prototype ), {
 		this.uuid = json.uuid;
 		this.holes = [];
 
-		for ( var i = 0, l = json.holes.length; i < l; i ++ ) {
+		for ( let i = 0, l = json.holes.length; i < l; i ++ ) {
 
-			var hole = json.holes[ i ];
+			const hole = json.holes[ i ];
 			this.holes.push( new Path().fromJSON( hole ) );
 
 		}

+ 34 - 34
src/extras/core/ShapePath.js

@@ -67,13 +67,13 @@ Object.assign( ShapePath.prototype, {
 
 		function toShapesNoHoles( inSubpaths ) {
 
-			var shapes = [];
+			const shapes = [];
 
-			for ( var i = 0, l = inSubpaths.length; i < l; i ++ ) {
+			for ( let i = 0, l = inSubpaths.length; i < l; i ++ ) {
 
-				var tmpPath = inSubpaths[ i ];
+				const tmpPath = inSubpaths[ i ];
 
-				var tmpShape = new Shape();
+				const tmpShape = new Shape();
 				tmpShape.curves = tmpPath.curves;
 
 				shapes.push( tmpShape );
@@ -86,20 +86,20 @@ Object.assign( ShapePath.prototype, {
 
 		function isPointInsidePolygon( inPt, inPolygon ) {
 
-			var polyLen = inPolygon.length;
+			const polyLen = inPolygon.length;
 
 			// inPt on polygon contour => immediate success    or
 			// toggling of inside/outside at every single! intersection point of an edge
 			//  with the horizontal line through inPt, left of inPt
 			//  not counting lowerY endpoints of edges and whole edges on that line
-			var inside = false;
-			for ( var p = polyLen - 1, q = 0; q < polyLen; p = q ++ ) {
+			let inside = false;
+			for ( let p = polyLen - 1, q = 0; q < polyLen; p = q ++ ) {
 
-				var edgeLowPt = inPolygon[ p ];
-				var edgeHighPt = inPolygon[ q ];
+				let edgeLowPt = inPolygon[ p ];
+				let edgeHighPt = inPolygon[ q ];
 
-				var edgeDx = edgeHighPt.x - edgeLowPt.x;
-				var edgeDy = edgeHighPt.y - edgeLowPt.y;
+				let edgeDx = edgeHighPt.x - edgeLowPt.x;
+				let edgeDy = edgeHighPt.y - edgeLowPt.y;
 
 				if ( Math.abs( edgeDy ) > Number.EPSILON ) {
 
@@ -120,7 +120,7 @@ Object.assign( ShapePath.prototype, {
 
 					} else {
 
-						var perpEdge = edgeDy * ( inPt.x - edgeLowPt.x ) - edgeDx * ( inPt.y - edgeLowPt.y );
+						const perpEdge = edgeDy * ( inPt.x - edgeLowPt.x ) - edgeDx * ( inPt.y - edgeLowPt.y );
 						if ( perpEdge === 0 )				return	true;		// inPt is on contour ?
 						if ( perpEdge < 0 ) 				continue;
 						inside = ! inside;		// true intersection left of inPt
@@ -144,15 +144,15 @@ Object.assign( ShapePath.prototype, {
 
 		}
 
-		var isClockWise = ShapeUtils.isClockWise;
+		const isClockWise = ShapeUtils.isClockWise;
 
-		var subPaths = this.subPaths;
+		const subPaths = this.subPaths;
 		if ( subPaths.length === 0 ) return [];
 
 		if ( noHoles === true )	return	toShapesNoHoles( subPaths );
 
 
-		var solid, tmpPath, tmpShape, shapes = [];
+		let solid, tmpPath, tmpShape, shapes = [];
 
 		if ( subPaths.length === 1 ) {
 
@@ -164,21 +164,21 @@ Object.assign( ShapePath.prototype, {
 
 		}
 
-		var holesFirst = ! isClockWise( subPaths[ 0 ].getPoints() );
+		let holesFirst = ! isClockWise( subPaths[ 0 ].getPoints() );
 		holesFirst = isCCW ? ! holesFirst : holesFirst;
 
 		// console.log("Holes first", holesFirst);
 
-		var betterShapeHoles = [];
-		var newShapes = [];
-		var newShapeHoles = [];
-		var mainIdx = 0;
-		var tmpPoints;
+		const betterShapeHoles = [];
+		const newShapes = [];
+		let newShapeHoles = [];
+		let mainIdx = 0;
+		let tmpPoints;
 
 		newShapes[ mainIdx ] = undefined;
 		newShapeHoles[ mainIdx ] = [];
 
-		for ( var i = 0, l = subPaths.length; i < l; i ++ ) {
+		for ( let i = 0, l = subPaths.length; i < l; i ++ ) {
 
 			tmpPath = subPaths[ i ];
 			tmpPoints = tmpPath.getPoints();
@@ -213,25 +213,25 @@ Object.assign( ShapePath.prototype, {
 
 		if ( newShapes.length > 1 ) {
 
-			var ambiguous = false;
-			var toChange = [];
+			let ambiguous = false;
+			const toChange = [];
 
-			for ( var sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx ++ ) {
+			for ( let sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx ++ ) {
 
 				betterShapeHoles[ sIdx ] = [];
 
 			}
 
-			for ( var sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx ++ ) {
+			for ( let sIdx = 0, sLen = newShapes.length; sIdx < sLen; sIdx ++ ) {
 
-				var sho = newShapeHoles[ sIdx ];
+				const sho = newShapeHoles[ sIdx ];
 
-				for ( var hIdx = 0; hIdx < sho.length; hIdx ++ ) {
+				for ( let hIdx = 0; hIdx < sho.length; hIdx ++ ) {
 
-					var ho = sho[ hIdx ];
-					var hole_unassigned = true;
+					const ho = sho[ hIdx ];
+					let hole_unassigned = true;
 
-					for ( var s2Idx = 0; s2Idx < newShapes.length; s2Idx ++ ) {
+					for ( let s2Idx = 0; s2Idx < newShapes.length; s2Idx ++ ) {
 
 						if ( isPointInsidePolygon( ho.p, newShapes[ s2Idx ].p ) ) {
 
@@ -271,15 +271,15 @@ Object.assign( ShapePath.prototype, {
 
 		}
 
-		var tmpHoles;
+		let tmpHoles;
 
-		for ( var i = 0, il = newShapes.length; i < il; i ++ ) {
+		for ( let i = 0, il = newShapes.length; i < il; i ++ ) {
 
 			tmpShape = newShapes[ i ].s;
 			shapes.push( tmpShape );
 			tmpHoles = newShapeHoles[ i ];
 
-			for ( var j = 0, jl = tmpHoles.length; j < jl; j ++ ) {
+			for ( let j = 0, jl = tmpHoles.length; j < jl; j ++ ) {
 
 				tmpShape.holes.push( tmpHoles[ j ].h );
 

+ 25 - 25
src/extras/curves/CatmullRomCurve3.js

@@ -25,7 +25,7 @@ which can be placed in CurveUtils.
 
 function CubicPoly() {
 
-	var c0 = 0, c1 = 0, c2 = 0, c3 = 0;
+	let c0 = 0, c1 = 0, c2 = 0, c3 = 0;
 
 	/*
 	 * Compute coefficients for a cubic polynomial
@@ -55,8 +55,8 @@ function CubicPoly() {
 		initNonuniformCatmullRom: function ( x0, x1, x2, x3, dt0, dt1, dt2 ) {
 
 			// compute tangents when parameterized in [t1,t2]
-			var t1 = ( x1 - x0 ) / dt0 - ( x2 - x0 ) / ( dt0 + dt1 ) + ( x2 - x1 ) / dt1;
-			var t2 = ( x2 - x1 ) / dt1 - ( x3 - x1 ) / ( dt1 + dt2 ) + ( x3 - x2 ) / dt2;
+			let t1 = ( x1 - x0 ) / dt0 - ( x2 - x0 ) / ( dt0 + dt1 ) + ( x2 - x1 ) / dt1;
+			let t2 = ( x2 - x1 ) / dt1 - ( x3 - x1 ) / ( dt1 + dt2 ) + ( x3 - x2 ) / dt2;
 
 			// rescale tangents for parametrization in [0,1]
 			t1 *= dt1;
@@ -68,8 +68,8 @@ function CubicPoly() {
 
 		calc: function ( t ) {
 
-			var t2 = t * t;
-			var t3 = t2 * t;
+			const t2 = t * t;
+			const t3 = t2 * t;
 			return c0 + c1 * t + c2 * t2 + c3 * t3;
 
 		}
@@ -80,8 +80,8 @@ function CubicPoly() {
 
 //
 
-var tmp = new Vector3();
-var px = new CubicPoly(), py = new CubicPoly(), pz = new CubicPoly();
+const tmp = new Vector3();
+const px = new CubicPoly(), py = new CubicPoly(), pz = new CubicPoly();
 
 function CatmullRomCurve3( points, closed, curveType, tension ) {
 
@@ -103,14 +103,14 @@ CatmullRomCurve3.prototype.isCatmullRomCurve3 = true;
 
 CatmullRomCurve3.prototype.getPoint = function ( t, optionalTarget ) {
 
-	var point = optionalTarget || new Vector3();
+	const point = optionalTarget || new Vector3();
 
-	var points = this.points;
-	var l = points.length;
+	const points = this.points;
+	const l = points.length;
 
-	var p = ( l - ( this.closed ? 0 : 1 ) ) * t;
-	var intPoint = Math.floor( p );
-	var weight = p - intPoint;
+	const p = ( l - ( this.closed ? 0 : 1 ) ) * t;
+	let intPoint = Math.floor( p );
+	let weight = p - intPoint;
 
 	if ( this.closed ) {
 
@@ -123,7 +123,7 @@ CatmullRomCurve3.prototype.getPoint = function ( t, optionalTarget ) {
 
 	}
 
-	var p0, p1, p2, p3; // 4 points
+	let p0, p1, p2, p3; // 4 points
 
 	if ( this.closed || intPoint > 0 ) {
 
@@ -155,10 +155,10 @@ CatmullRomCurve3.prototype.getPoint = function ( t, optionalTarget ) {
 	if ( this.curveType === 'centripetal' || this.curveType === 'chordal' ) {
 
 		// init Centripetal / Chordal Catmull-Rom
-		var pow = this.curveType === 'chordal' ? 0.5 : 0.25;
-		var dt0 = Math.pow( p0.distanceToSquared( p1 ), pow );
-		var dt1 = Math.pow( p1.distanceToSquared( p2 ), pow );
-		var dt2 = Math.pow( p2.distanceToSquared( p3 ), pow );
+		const pow = this.curveType === 'chordal' ? 0.5 : 0.25;
+		let dt0 = Math.pow( p0.distanceToSquared( p1 ), pow );
+		let dt1 = Math.pow( p1.distanceToSquared( p2 ), pow );
+		let dt2 = Math.pow( p2.distanceToSquared( p3 ), pow );
 
 		// safety check for repeated points
 		if ( dt1 < 1e-4 ) dt1 = 1.0;
@@ -193,9 +193,9 @@ CatmullRomCurve3.prototype.copy = function ( source ) {
 
 	this.points = [];
 
-	for ( var i = 0, l = source.points.length; i < l; i ++ ) {
+	for ( let i = 0, l = source.points.length; i < l; i ++ ) {
 
-		var point = source.points[ i ];
+		const point = source.points[ i ];
 
 		this.points.push( point.clone() );
 
@@ -211,13 +211,13 @@ CatmullRomCurve3.prototype.copy = function ( source ) {
 
 CatmullRomCurve3.prototype.toJSON = function () {
 
-	var data = Curve.prototype.toJSON.call( this );
+	const data = Curve.prototype.toJSON.call( this );
 
 	data.points = [];
 
-	for ( var i = 0, l = this.points.length; i < l; i ++ ) {
+	for ( let i = 0, l = this.points.length; i < l; i ++ ) {
 
-		var point = this.points[ i ];
+		const point = this.points[ i ];
 		data.points.push( point.toArray() );
 
 	}
@@ -236,9 +236,9 @@ CatmullRomCurve3.prototype.fromJSON = function ( json ) {
 
 	this.points = [];
 
-	for ( var i = 0, l = json.points.length; i < l; i ++ ) {
+	for ( let i = 0, l = json.points.length; i < l; i ++ ) {
 
-		var point = json.points[ i ];
+		const point = json.points[ i ];
 		this.points.push( new Vector3().fromArray( point ) );
 
 	}

+ 3 - 3
src/extras/curves/CubicBezierCurve.js

@@ -23,9 +23,9 @@ CubicBezierCurve.prototype.isCubicBezierCurve = true;
 
 CubicBezierCurve.prototype.getPoint = function ( t, optionalTarget ) {
 
-	var point = optionalTarget || new Vector2();
+	const point = optionalTarget || new Vector2();
 
-	var v0 = this.v0, v1 = this.v1, v2 = this.v2, v3 = this.v3;
+	const v0 = this.v0, v1 = this.v1, v2 = this.v2, v3 = this.v3;
 
 	point.set(
 		CubicBezier( t, v0.x, v1.x, v2.x, v3.x ),
@@ -51,7 +51,7 @@ CubicBezierCurve.prototype.copy = function ( source ) {
 
 CubicBezierCurve.prototype.toJSON = function () {
 
-	var data = Curve.prototype.toJSON.call( this );
+	const data = Curve.prototype.toJSON.call( this );
 
 	data.v0 = this.v0.toArray();
 	data.v1 = this.v1.toArray();

+ 3 - 3
src/extras/curves/CubicBezierCurve3.js

@@ -23,9 +23,9 @@ CubicBezierCurve3.prototype.isCubicBezierCurve3 = true;
 
 CubicBezierCurve3.prototype.getPoint = function ( t, optionalTarget ) {
 
-	var point = optionalTarget || new Vector3();
+	const point = optionalTarget || new Vector3();
 
-	var v0 = this.v0, v1 = this.v1, v2 = this.v2, v3 = this.v3;
+	const v0 = this.v0, v1 = this.v1, v2 = this.v2, v3 = this.v3;
 
 	point.set(
 		CubicBezier( t, v0.x, v1.x, v2.x, v3.x ),
@@ -52,7 +52,7 @@ CubicBezierCurve3.prototype.copy = function ( source ) {
 
 CubicBezierCurve3.prototype.toJSON = function () {
 
-	var data = Curve.prototype.toJSON.call( this );
+	const data = Curve.prototype.toJSON.call( this );
 
 	data.v0 = this.v0.toArray();
 	data.v1 = this.v1.toArray();

+ 12 - 12
src/extras/curves/EllipseCurve.js

@@ -30,11 +30,11 @@ EllipseCurve.prototype.isEllipseCurve = true;
 
 EllipseCurve.prototype.getPoint = function ( t, optionalTarget ) {
 
-	var point = optionalTarget || new Vector2();
+	const point = optionalTarget || new Vector2();
 
-	var twoPi = Math.PI * 2;
-	var deltaAngle = this.aEndAngle - this.aStartAngle;
-	var samePoints = Math.abs( deltaAngle ) < Number.EPSILON;
+	const twoPi = Math.PI * 2;
+	let deltaAngle = this.aEndAngle - this.aStartAngle;
+	const samePoints = Math.abs( deltaAngle ) < Number.EPSILON;
 
 	// ensures that deltaAngle is 0 .. 2 PI
 	while ( deltaAngle < 0 ) deltaAngle += twoPi;
@@ -68,17 +68,17 @@ EllipseCurve.prototype.getPoint = function ( t, optionalTarget ) {
 
 	}
 
-	var angle = this.aStartAngle + t * deltaAngle;
-	var x = this.aX + this.xRadius * Math.cos( angle );
-	var y = this.aY + this.yRadius * Math.sin( angle );
+	const angle = this.aStartAngle + t * deltaAngle;
+	let x = this.aX + this.xRadius * Math.cos( angle );
+	let y = this.aY + this.yRadius * Math.sin( angle );
 
 	if ( this.aRotation !== 0 ) {
 
-		var cos = Math.cos( this.aRotation );
-		var sin = Math.sin( this.aRotation );
+		const cos = Math.cos( this.aRotation );
+		const sin = Math.sin( this.aRotation );
 
-		var tx = x - this.aX;
-		var ty = y - this.aY;
+		const tx = x - this.aX;
+		const ty = y - this.aY;
 
 		// Rotate the point about the center of the ellipse.
 		x = tx * cos - ty * sin + this.aX;
@@ -114,7 +114,7 @@ EllipseCurve.prototype.copy = function ( source ) {
 
 EllipseCurve.prototype.toJSON = function () {
 
-	var data = Curve.prototype.toJSON.call( this );
+	const data = Curve.prototype.toJSON.call( this );
 
 	data.aX = this.aX;
 	data.aY = this.aY;

+ 4 - 4
src/extras/curves/LineCurve.js

@@ -20,7 +20,7 @@ LineCurve.prototype.isLineCurve = true;
 
 LineCurve.prototype.getPoint = function ( t, optionalTarget ) {
 
-	var point = optionalTarget || new Vector2();
+	const point = optionalTarget || new Vector2();
 
 	if ( t === 1 ) {
 
@@ -47,9 +47,9 @@ LineCurve.prototype.getPointAt = function ( u, optionalTarget ) {
 
 LineCurve.prototype.getTangent = function ( t, optionalTarget ) {
 
-	var tangent = optionalTarget || new Vector2();
+	const tangent = optionalTarget || new Vector2();
 
-	var tangent = tangent.copy( this.v2 ).sub( this.v1 ).normalize();
+	tangent.copy( this.v2 ).sub( this.v1 ).normalize();
 
 	return tangent;
 
@@ -68,7 +68,7 @@ LineCurve.prototype.copy = function ( source ) {
 
 LineCurve.prototype.toJSON = function () {
 
-	var data = Curve.prototype.toJSON.call( this );
+	const data = Curve.prototype.toJSON.call( this );
 
 	data.v1 = this.v1.toArray();
 	data.v2 = this.v2.toArray();

+ 2 - 2
src/extras/curves/LineCurve3.js

@@ -20,7 +20,7 @@ LineCurve3.prototype.isLineCurve3 = true;
 
 LineCurve3.prototype.getPoint = function ( t, optionalTarget ) {
 
-	var point = optionalTarget || new Vector3();
+	const point = optionalTarget || new Vector3();
 
 	if ( t === 1 ) {
 
@@ -58,7 +58,7 @@ LineCurve3.prototype.copy = function ( source ) {
 
 LineCurve3.prototype.toJSON = function () {
 
-	var data = Curve.prototype.toJSON.call( this );
+	const data = Curve.prototype.toJSON.call( this );
 
 	data.v1 = this.v1.toArray();
 	data.v2 = this.v2.toArray();

+ 3 - 3
src/extras/curves/QuadraticBezierCurve.js

@@ -22,9 +22,9 @@ QuadraticBezierCurve.prototype.isQuadraticBezierCurve = true;
 
 QuadraticBezierCurve.prototype.getPoint = function ( t, optionalTarget ) {
 
-	var point = optionalTarget || new Vector2();
+	const point = optionalTarget || new Vector2();
 
-	var v0 = this.v0, v1 = this.v1, v2 = this.v2;
+	const v0 = this.v0, v1 = this.v1, v2 = this.v2;
 
 	point.set(
 		QuadraticBezier( t, v0.x, v1.x, v2.x ),
@@ -49,7 +49,7 @@ QuadraticBezierCurve.prototype.copy = function ( source ) {
 
 QuadraticBezierCurve.prototype.toJSON = function () {
 
-	var data = Curve.prototype.toJSON.call( this );
+	const data = Curve.prototype.toJSON.call( this );
 
 	data.v0 = this.v0.toArray();
 	data.v1 = this.v1.toArray();

+ 3 - 3
src/extras/curves/QuadraticBezierCurve3.js

@@ -22,9 +22,9 @@ QuadraticBezierCurve3.prototype.isQuadraticBezierCurve3 = true;
 
 QuadraticBezierCurve3.prototype.getPoint = function ( t, optionalTarget ) {
 
-	var point = optionalTarget || new Vector3();
+	const point = optionalTarget || new Vector3();
 
-	var v0 = this.v0, v1 = this.v1, v2 = this.v2;
+	const v0 = this.v0, v1 = this.v1, v2 = this.v2;
 
 	point.set(
 		QuadraticBezier( t, v0.x, v1.x, v2.x ),
@@ -50,7 +50,7 @@ QuadraticBezierCurve3.prototype.copy = function ( source ) {
 
 QuadraticBezierCurve3.prototype.toJSON = function () {
 
-	var data = Curve.prototype.toJSON.call( this );
+	const data = Curve.prototype.toJSON.call( this );
 
 	data.v0 = this.v0.toArray();
 	data.v1 = this.v1.toArray();

+ 16 - 16
src/extras/curves/SplineCurve.js

@@ -20,18 +20,18 @@ SplineCurve.prototype.isSplineCurve = true;
 
 SplineCurve.prototype.getPoint = function ( t, optionalTarget ) {
 
-	var point = optionalTarget || new Vector2();
+	const point = optionalTarget || new Vector2();
 
-	var points = this.points;
-	var p = ( points.length - 1 ) * t;
+	const points = this.points;
+	const p = ( points.length - 1 ) * t;
 
-	var intPoint = Math.floor( p );
-	var weight = p - intPoint;
+	const intPoint = Math.floor( p );
+	const weight = p - intPoint;
 
-	var p0 = points[ intPoint === 0 ? intPoint : intPoint - 1 ];
-	var p1 = points[ intPoint ];
-	var p2 = points[ intPoint > points.length - 2 ? points.length - 1 : intPoint + 1 ];
-	var p3 = points[ intPoint > points.length - 3 ? points.length - 1 : intPoint + 2 ];
+	const p0 = points[ intPoint === 0 ? intPoint : intPoint - 1 ];
+	const p1 = points[ intPoint ];
+	const p2 = points[ intPoint > points.length - 2 ? points.length - 1 : intPoint + 1 ];
+	const p3 = points[ intPoint > points.length - 3 ? points.length - 1 : intPoint + 2 ];
 
 	point.set(
 		CatmullRom( weight, p0.x, p1.x, p2.x, p3.x ),
@@ -48,9 +48,9 @@ SplineCurve.prototype.copy = function ( source ) {
 
 	this.points = [];
 
-	for ( var i = 0, l = source.points.length; i < l; i ++ ) {
+	for ( let i = 0, l = source.points.length; i < l; i ++ ) {
 
-		var point = source.points[ i ];
+		const point = source.points[ i ];
 
 		this.points.push( point.clone() );
 
@@ -62,13 +62,13 @@ SplineCurve.prototype.copy = function ( source ) {
 
 SplineCurve.prototype.toJSON = function () {
 
-	var data = Curve.prototype.toJSON.call( this );
+	const data = Curve.prototype.toJSON.call( this );
 
 	data.points = [];
 
-	for ( var i = 0, l = this.points.length; i < l; i ++ ) {
+	for ( let i = 0, l = this.points.length; i < l; i ++ ) {
 
-		var point = this.points[ i ];
+		const point = this.points[ i ];
 		data.points.push( point.toArray() );
 
 	}
@@ -83,9 +83,9 @@ SplineCurve.prototype.fromJSON = function ( json ) {
 
 	this.points = [];
 
-	for ( var i = 0, l = json.points.length; i < l; i ++ ) {
+	for ( let i = 0, l = json.points.length; i < l; i ++ ) {
 
-		var point = json.points[ i ];
+		const point = json.points[ i ];
 		this.points.push( new Vector2().fromArray( point ) );
 
 	}