Browse Source

Merge pull request #19490 from Mugen87/dev49

Core: More let/const usage.
Mr.doob 5 years ago
parent
commit
da15af60c9
47 changed files with 484 additions and 486 deletions
  1. 3 3
      src/audio/Audio.js
  2. 3 2
      src/audio/AudioAnalyser.js
  3. 1 1
      src/audio/AudioContext.js
  4. 7 7
      src/audio/AudioListener.js
  5. 6 6
      src/audio/PositionalAudio.js
  6. 1 1
      src/cameras/Camera.js
  7. 12 12
      src/cameras/CubeCamera.js
  8. 1 1
      src/cameras/OrthographicCamera.d.ts
  9. 11 11
      src/cameras/OrthographicCamera.js
  10. 4 4
      src/cameras/PerspectiveCamera.d.ts
  11. 10 10
      src/cameras/PerspectiveCamera.js
  12. 9 9
      src/cameras/StereoCamera.js
  13. 3 3
      src/helpers/ArrowHelper.js
  14. 4 4
      src/helpers/AxesHelper.js
  15. 4 4
      src/helpers/Box3Helper.js
  16. 8 8
      src/helpers/BoxHelper.js
  17. 18 18
      src/helpers/CameraHelper.js
  18. 5 5
      src/helpers/DirectionalLightHelper.js
  19. 8 8
      src/helpers/GridHelper.js
  20. 10 10
      src/helpers/HemisphereLightHelper.js
  21. 6 6
      src/helpers/PlaneHelper.js
  22. 6 6
      src/helpers/PointLightHelper.js
  23. 16 19
      src/helpers/PolarGridHelper.js
  24. 19 19
      src/helpers/SkeletonHelper.js
  25. 9 9
      src/helpers/SpotLightHelper.js
  26. 2 2
      src/lights/AmbientLightProbe.js
  27. 1 1
      src/lights/DirectionalLight.d.ts
  28. 7 7
      src/lights/HemisphereLightProbe.js
  29. 1 1
      src/lights/Light.js
  30. 1 1
      src/lights/LightProbe.js
  31. 2 2
      src/lights/LightShadow.js
  32. 1 1
      src/lights/PointLight.d.ts
  33. 1 1
      src/lights/PointLightShadow.js
  34. 1 1
      src/lights/RectAreaLight.js
  35. 4 4
      src/lights/SpotLightShadow.js
  36. 18 15
      src/materials/Material.js
  37. 6 6
      src/materials/ShaderMaterial.js
  38. 9 9
      src/objects/InstancedMesh.js
  39. 24 18
      src/objects/LOD.js
  40. 46 47
      src/objects/Line.js
  41. 9 9
      src/objects/LineSegments.js
  42. 86 92
      src/objects/Mesh.js
  43. 28 29
      src/objects/Points.js
  44. 17 19
      src/objects/Skeleton.js
  45. 14 14
      src/objects/SkinnedMesh.js
  46. 21 20
      src/objects/Sprite.js
  47. 1 1
      src/scenes/Scene.js

+ 3 - 3
src/audio/Audio.js

@@ -112,7 +112,7 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 		this._startedAt = this.context.currentTime + delay;
 
-		var source = this.context.createBufferSource();
+		const source = this.context.createBufferSource();
 		source.buffer = this.buffer;
 		source.loop = this.loop;
 		source.loopStart = this.loopStart;
@@ -190,7 +190,7 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 			this.source.connect( this.filters[ 0 ] );
 
-			for ( var i = 1, l = this.filters.length; i < l; i ++ ) {
+			for ( let i = 1, l = this.filters.length; i < l; i ++ ) {
 
 				this.filters[ i - 1 ].connect( this.filters[ i ] );
 
@@ -214,7 +214,7 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 			this.source.disconnect( this.filters[ 0 ] );
 
-			for ( var i = 1, l = this.filters.length; i < l; i ++ ) {
+			for ( let i = 1, l = this.filters.length; i < l; i ++ ) {
 
 				this.filters[ i - 1 ].disconnect( this.filters[ i ] );
 

+ 3 - 2
src/audio/AudioAnalyser.js

@@ -25,9 +25,10 @@ Object.assign( AudioAnalyser.prototype, {
 
 	getAverageFrequency: function () {
 
-		var value = 0, data = this.getFrequencyData();
+		let value = 0;
+		const data = this.getFrequencyData();
 
-		for ( var i = 0; i < data.length; i ++ ) {
+		for ( let i = 0; i < data.length; i ++ ) {
 
 			value += data[ i ];
 

+ 1 - 1
src/audio/AudioContext.js

@@ -2,7 +2,7 @@
  * @author mrdoob / http://mrdoob.com/
  */
 
-var _context;
+let _context;
 
 var AudioContext = {
 

+ 7 - 7
src/audio/AudioListener.js

@@ -8,10 +8,10 @@ import { Clock } from '../core/Clock.js';
 import { Object3D } from '../core/Object3D.js';
 import { AudioContext } from './AudioContext.js';
 
-var _position = new Vector3();
-var _quaternion = new Quaternion();
-var _scale = new Vector3();
-var _orientation = new Vector3();
+const _position = new Vector3();
+const _quaternion = new Quaternion();
+const _scale = new Vector3();
+const _orientation = new Vector3();
 
 function AudioListener() {
 
@@ -104,8 +104,8 @@ AudioListener.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 		Object3D.prototype.updateMatrixWorld.call( this, force );
 
-		var listener = this.context.listener;
-		var up = this.up;
+		const listener = this.context.listener;
+		const up = this.up;
 
 		this.timeDelta = this._clock.getDelta();
 
@@ -117,7 +117,7 @@ AudioListener.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 			// code path for Chrome (see #14393)
 
-			var endTime = this.context.currentTime + this.timeDelta;
+			const endTime = this.context.currentTime + this.timeDelta;
 
 			listener.positionX.linearRampToValueAtTime( _position.x, endTime );
 			listener.positionY.linearRampToValueAtTime( _position.y, endTime );

+ 6 - 6
src/audio/PositionalAudio.js

@@ -7,10 +7,10 @@ import { Quaternion } from '../math/Quaternion.js';
 import { Audio } from './Audio.js';
 import { Object3D } from '../core/Object3D.js';
 
-var _position = new Vector3();
-var _quaternion = new Quaternion();
-var _scale = new Vector3();
-var _orientation = new Vector3();
+const _position = new Vector3();
+const _quaternion = new Quaternion();
+const _scale = new Vector3();
+const _orientation = new Vector3();
 
 function PositionalAudio( listener ) {
 
@@ -108,13 +108,13 @@ PositionalAudio.prototype = Object.assign( Object.create( Audio.prototype ), {
 
 		_orientation.set( 0, 0, 1 ).applyQuaternion( _quaternion );
 
-		var panner = this.panner;
+		const panner = this.panner;
 
 		if ( panner.positionX ) {
 
 			// code path for Chrome and Firefox (see #14393)
 
-			var endTime = this.context.currentTime + this.listener.timeDelta;
+			const endTime = this.context.currentTime + this.listener.timeDelta;
 
 			panner.positionX.linearRampToValueAtTime( _position.x, endTime );
 			panner.positionY.linearRampToValueAtTime( _position.y, endTime );

+ 1 - 1
src/cameras/Camera.js

@@ -51,7 +51,7 @@ Camera.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 		this.updateMatrixWorld( true );
 
-		var e = this.matrixWorld.elements;
+		const e = this.matrixWorld.elements;
 
 		return target.set( - e[ 8 ], - e[ 9 ], - e[ 10 ] ).normalize();
 

+ 12 - 12
src/cameras/CubeCamera.js

@@ -9,7 +9,7 @@ import { PerspectiveCamera } from './PerspectiveCamera.js';
  * @author alteredq / http://alteredqualia.com/
  */
 
-var fov = 90, aspect = 1;
+const fov = 90, aspect = 1;
 
 function CubeCamera( near, far, renderTarget ) {
 
@@ -26,37 +26,37 @@ function CubeCamera( near, far, renderTarget ) {
 
 	this.renderTarget = renderTarget;
 
-	var cameraPX = new PerspectiveCamera( fov, aspect, near, far );
+	const cameraPX = new PerspectiveCamera( fov, aspect, near, far );
 	cameraPX.layers = this.layers;
 	cameraPX.up.set( 0, - 1, 0 );
 	cameraPX.lookAt( new Vector3( 1, 0, 0 ) );
 	this.add( cameraPX );
 
-	var cameraNX = new PerspectiveCamera( fov, aspect, near, far );
+	const cameraNX = new PerspectiveCamera( fov, aspect, near, far );
 	cameraNX.layers = this.layers;
 	cameraNX.up.set( 0, - 1, 0 );
 	cameraNX.lookAt( new Vector3( - 1, 0, 0 ) );
 	this.add( cameraNX );
 
-	var cameraPY = new PerspectiveCamera( fov, aspect, near, far );
+	const cameraPY = new PerspectiveCamera( fov, aspect, near, far );
 	cameraPY.layers = this.layers;
 	cameraPY.up.set( 0, 0, 1 );
 	cameraPY.lookAt( new Vector3( 0, 1, 0 ) );
 	this.add( cameraPY );
 
-	var cameraNY = new PerspectiveCamera( fov, aspect, near, far );
+	const cameraNY = new PerspectiveCamera( fov, aspect, near, far );
 	cameraNY.layers = this.layers;
 	cameraNY.up.set( 0, 0, - 1 );
 	cameraNY.lookAt( new Vector3( 0, - 1, 0 ) );
 	this.add( cameraNY );
 
-	var cameraPZ = new PerspectiveCamera( fov, aspect, near, far );
+	const cameraPZ = new PerspectiveCamera( fov, aspect, near, far );
 	cameraPZ.layers = this.layers;
 	cameraPZ.up.set( 0, - 1, 0 );
 	cameraPZ.lookAt( new Vector3( 0, 0, 1 ) );
 	this.add( cameraPZ );
 
-	var cameraNZ = new PerspectiveCamera( fov, aspect, near, far );
+	const cameraNZ = new PerspectiveCamera( fov, aspect, near, far );
 	cameraNZ.layers = this.layers;
 	cameraNZ.up.set( 0, - 1, 0 );
 	cameraNZ.lookAt( new Vector3( 0, 0, - 1 ) );
@@ -66,12 +66,12 @@ function CubeCamera( near, far, renderTarget ) {
 
 		if ( this.parent === null ) this.updateMatrixWorld();
 
-		var currentXrEnabled = renderer.xr.enabled;
-		var currentRenderTarget = renderer.getRenderTarget();
+		const currentXrEnabled = renderer.xr.enabled;
+		const currentRenderTarget = renderer.getRenderTarget();
 
 		renderer.xr.enabled = false;
 
-		var generateMipmaps = renderTarget.texture.generateMipmaps;
+		const generateMipmaps = renderTarget.texture.generateMipmaps;
 
 		renderTarget.texture.generateMipmaps = false;
 
@@ -103,9 +103,9 @@ function CubeCamera( near, far, renderTarget ) {
 
 	this.clear = function ( renderer, color, depth, stencil ) {
 
-		var currentRenderTarget = renderer.getRenderTarget();
+		const currentRenderTarget = renderer.getRenderTarget();
 
-		for ( var i = 0; i < 6; i ++ ) {
+		for ( let i = 0; i < 6; i ++ ) {
 
 			renderer.setRenderTarget( renderTarget, i );
 

+ 1 - 1
src/cameras/OrthographicCamera.d.ts

@@ -4,7 +4,7 @@ import { Camera } from './Camera';
  * Camera with orthographic projection
  *
  * @example
- * var camera = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, 1, 1000 );
+ * const camera = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, 1, 1000 );
  * scene.add( camera );
  *
  * @see {@link https://github.com/mrdoob/three.js/blob/master/src/cameras/OrthographicCamera.js|src/cameras/OrthographicCamera.js}

+ 11 - 11
src/cameras/OrthographicCamera.js

@@ -93,20 +93,20 @@ OrthographicCamera.prototype = Object.assign( Object.create( Camera.prototype ),
 
 	updateProjectionMatrix: function () {
 
-		var dx = ( this.right - this.left ) / ( 2 * this.zoom );
-		var dy = ( this.top - this.bottom ) / ( 2 * this.zoom );
-		var cx = ( this.right + this.left ) / 2;
-		var cy = ( this.top + this.bottom ) / 2;
+		const dx = ( this.right - this.left ) / ( 2 * this.zoom );
+		const dy = ( this.top - this.bottom ) / ( 2 * this.zoom );
+		const cx = ( this.right + this.left ) / 2;
+		const cy = ( this.top + this.bottom ) / 2;
 
-		var left = cx - dx;
-		var right = cx + dx;
-		var top = cy + dy;
-		var bottom = cy - dy;
+		let left = cx - dx;
+		let right = cx + dx;
+		let top = cy + dy;
+		let bottom = cy - dy;
 
 		if ( this.view !== null && this.view.enabled ) {
 
-			var scaleW = ( this.right - this.left ) / this.view.fullWidth / this.zoom;
-			var scaleH = ( this.top - this.bottom ) / this.view.fullHeight / this.zoom;
+			const scaleW = ( this.right - this.left ) / this.view.fullWidth / this.zoom;
+			const scaleH = ( this.top - this.bottom ) / this.view.fullHeight / this.zoom;
 
 			left += scaleW * this.view.offsetX;
 			right = left + scaleW * this.view.width;
@@ -123,7 +123,7 @@ OrthographicCamera.prototype = Object.assign( Object.create( Camera.prototype ),
 
 	toJSON: function ( meta ) {
 
-		var data = Object3D.prototype.toJSON.call( this, meta );
+		const data = Object3D.prototype.toJSON.call( this, meta );
 
 		data.object.zoom = this.zoom;
 		data.object.left = this.left;

+ 4 - 4
src/cameras/PerspectiveCamera.d.ts

@@ -72,10 +72,10 @@ export class PerspectiveCamera extends Camera {
 	 *
 	 * then for each monitor you would call it like this:
 	 *
-	 *		 var w = 1920;
-	 *		 var h = 1080;
-	 *		 var fullWidth = w * 3;
-	 *		 var fullHeight = h * 2;
+	 *		 const w = 1920;
+	 *		 const h = 1080;
+	 *		 const fullWidth = w * 3;
+	 *		 const fullHeight = h * 2;
 	 *
 	 *		 // A
 	 *		 camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );

+ 10 - 10
src/cameras/PerspectiveCamera.js

@@ -70,7 +70,7 @@ PerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ),
 	setFocalLength: function ( focalLength ) {
 
 		// see http://www.bobatkins.com/photography/technical/field_of_view.html
-		var vExtentSlope = 0.5 * this.getFilmHeight() / focalLength;
+		const vExtentSlope = 0.5 * this.getFilmHeight() / focalLength;
 
 		this.fov = MathUtils.RAD2DEG * 2 * Math.atan( vExtentSlope );
 		this.updateProjectionMatrix();
@@ -82,7 +82,7 @@ PerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ),
 	 */
 	getFocalLength: function () {
 
-		var vExtentSlope = Math.tan( MathUtils.DEG2RAD * 0.5 * this.fov );
+		const vExtentSlope = Math.tan( MathUtils.DEG2RAD * 0.5 * this.fov );
 
 		return 0.5 * this.getFilmHeight() / vExtentSlope;
 
@@ -124,10 +124,10 @@ PerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ),
 	 *
 	 * then for each monitor you would call it like this
 	 *
-	 *   var w = 1920;
-	 *   var h = 1080;
-	 *   var fullWidth = w * 3;
-	 *   var fullHeight = h * 2;
+	 *   const w = 1920;
+	 *   const h = 1080;
+	 *   const fullWidth = w * 3;
+	 *   const fullHeight = h * 2;
 	 *
 	 *   --A--
 	 *   camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );
@@ -188,7 +188,7 @@ PerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ),
 
 	updateProjectionMatrix: function () {
 
-		var near = this.near,
+		let near = this.near,
 			top = near * Math.tan( MathUtils.DEG2RAD * 0.5 * this.fov ) / this.zoom,
 			height = 2 * top,
 			width = this.aspect * height,
@@ -197,7 +197,7 @@ PerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ),
 
 		if ( this.view !== null && this.view.enabled ) {
 
-			var fullWidth = view.fullWidth,
+			const fullWidth = view.fullWidth,
 				fullHeight = view.fullHeight;
 
 			left += view.offsetX * width / fullWidth;
@@ -207,7 +207,7 @@ PerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ),
 
 		}
 
-		var skew = this.filmOffset;
+		const skew = this.filmOffset;
 		if ( skew !== 0 ) left += near * skew / this.getFilmWidth();
 
 		this.projectionMatrix.makePerspective( left, left + width, top, top - height, near, this.far );
@@ -218,7 +218,7 @@ PerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ),
 
 	toJSON: function ( meta ) {
 
-		var data = Object3D.prototype.toJSON.call( this, meta );
+		const data = Object3D.prototype.toJSON.call( this, meta );
 
 		data.object.fov = this.fov;
 		data.object.zoom = this.zoom;

+ 9 - 9
src/cameras/StereoCamera.js

@@ -2,8 +2,8 @@ import { Matrix4 } from '../math/Matrix4.js';
 import { MathUtils } from '../math/MathUtils.js';
 import { PerspectiveCamera } from './PerspectiveCamera.js';
 
-var _eyeRight = new Matrix4();
-var _eyeLeft = new Matrix4();
+const _eyeRight = new Matrix4();
+const _eyeLeft = new Matrix4();
 
 /**
  * @author mrdoob / http://mrdoob.com/
@@ -41,9 +41,9 @@ Object.assign( StereoCamera.prototype, {
 
 	update: function ( camera ) {
 
-		var cache = this._cache;
+		const cache = this._cache;
 
-		var needsUpdate = cache.focus !== camera.focus || cache.fov !== camera.fov ||
+		const needsUpdate = cache.focus !== camera.focus || cache.fov !== camera.fov ||
 			cache.aspect !== camera.aspect * this.aspect || cache.near !== camera.near ||
 			cache.far !== camera.far || cache.zoom !== camera.zoom || cache.eyeSep !== this.eyeSep;
 
@@ -60,11 +60,11 @@ Object.assign( StereoCamera.prototype, {
 			// Off-axis stereoscopic effect based on
 			// http://paulbourke.net/stereographics/stereorender/
 
-			var projectionMatrix = camera.projectionMatrix.clone();
-			var eyeSepHalf = cache.eyeSep / 2;
-			var eyeSepOnProjection = eyeSepHalf * cache.near / cache.focus;
-			var ymax = ( cache.near * Math.tan( MathUtils.DEG2RAD * cache.fov * 0.5 ) ) / cache.zoom;
-			var xmin, xmax;
+			const projectionMatrix = camera.projectionMatrix.clone();
+			const eyeSepHalf = cache.eyeSep / 2;
+			const eyeSepOnProjection = eyeSepHalf * cache.near / cache.focus;
+			const ymax = ( cache.near * Math.tan( MathUtils.DEG2RAD * cache.fov * 0.5 ) ) / cache.zoom;
+			let xmin, xmax;
 
 			// translate xOffset
 

+ 3 - 3
src/helpers/ArrowHelper.js

@@ -24,8 +24,8 @@ import { Mesh } from '../objects/Mesh.js';
 import { Line } from '../objects/Line.js';
 import { Vector3 } from '../math/Vector3.js';
 
-var _axis = new Vector3();
-var _lineGeometry, _coneGeometry;
+const _axis = new Vector3();
+let _lineGeometry, _coneGeometry;
 
 function ArrowHelper( dir, origin, length, color, headLength, headWidth ) {
 
@@ -86,7 +86,7 @@ ArrowHelper.prototype.setDirection = function ( dir ) {
 
 		_axis.set( dir.z, 0, - dir.x ).normalize();
 
-		var radians = Math.acos( dir.y );
+		const radians = Math.acos( dir.y );
 
 		this.quaternion.setFromAxisAngle( _axis, radians );
 

+ 4 - 4
src/helpers/AxesHelper.js

@@ -12,23 +12,23 @@ function AxesHelper( size ) {
 
 	size = size || 1;
 
-	var vertices = [
+	const vertices = [
 		0, 0, 0,	size, 0, 0,
 		0, 0, 0,	0, size, 0,
 		0, 0, 0,	0, 0, size
 	];
 
-	var colors = [
+	const colors = [
 		1, 0, 0,	1, 0.6, 0,
 		0, 1, 0,	0.6, 1, 0,
 		0, 0, 1,	0, 0.6, 1
 	];
 
-	var geometry = new BufferGeometry();
+	const geometry = new BufferGeometry();
 	geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) );
 
-	var material = new LineBasicMaterial( { vertexColors: true, toneMapped: false } );
+	const material = new LineBasicMaterial( { vertexColors: true, toneMapped: false } );
 
 	LineSegments.call( this, geometry, material );
 

+ 4 - 4
src/helpers/Box3Helper.js

@@ -17,11 +17,11 @@ function Box3Helper( box, color ) {
 
 	color = color || 0xffff00;
 
-	var indices = new Uint16Array( [ 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 ] );
+	const indices = new Uint16Array( [ 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 ] );
 
-	var positions = [ 1, 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, - 1, 1, 1, 1, - 1, - 1, 1, - 1, - 1, - 1, - 1, 1, - 1, - 1 ];
+	const positions = [ 1, 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, - 1, 1, 1, 1, - 1, - 1, 1, - 1, - 1, - 1, - 1, 1, - 1, - 1 ];
 
-	var geometry = new BufferGeometry();
+	const geometry = new BufferGeometry();
 
 	geometry.setIndex( new BufferAttribute( indices, 1 ) );
 
@@ -40,7 +40,7 @@ Box3Helper.prototype.constructor = Box3Helper;
 
 Box3Helper.prototype.updateMatrixWorld = function ( force ) {
 
-	var box = this.box;
+	const box = this.box;
 
 	if ( box.isEmpty() ) return;
 

+ 8 - 8
src/helpers/BoxHelper.js

@@ -9,7 +9,7 @@ import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
 import { BufferAttribute } from '../core/BufferAttribute.js';
 import { BufferGeometry } from '../core/BufferGeometry.js';
 
-var _box = new Box3();
+const _box = new Box3();
 
 function BoxHelper( object, color ) {
 
@@ -17,10 +17,10 @@ function BoxHelper( object, color ) {
 
 	if ( color === undefined ) color = 0xffff00;
 
-	var indices = new Uint16Array( [ 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 ] );
-	var positions = new Float32Array( 8 * 3 );
+	const indices = new Uint16Array( [ 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 ] );
+	const positions = new Float32Array( 8 * 3 );
 
-	var geometry = new BufferGeometry();
+	const geometry = new BufferGeometry();
 	geometry.setIndex( new BufferAttribute( indices, 1 ) );
 	geometry.setAttribute( 'position', new BufferAttribute( positions, 3 ) );
 
@@ -53,8 +53,8 @@ BoxHelper.prototype.update = function ( object ) {
 
 	if ( _box.isEmpty() ) return;
 
-	var min = _box.min;
-	var max = _box.max;
+	const min = _box.min;
+	const max = _box.max;
 
 	/*
 	  5____4
@@ -72,8 +72,8 @@ BoxHelper.prototype.update = function ( object ) {
 	7: max.x, min.y, min.z
 	*/
 
-	var position = this.geometry.attributes.position;
-	var array = position.array;
+	const position = this.geometry.attributes.position;
+	const array = position.array;
 
 	array[ 0 ] = max.x; array[ 1 ] = max.y; array[ 2 ] = max.z;
 	array[ 3 ] = min.x; array[ 4 ] = max.y; array[ 5 ] = max.z;

+ 18 - 18
src/helpers/CameraHelper.js

@@ -16,26 +16,26 @@ import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
 import { BufferGeometry } from '../core/BufferGeometry.js';
 import { Float32BufferAttribute } from '../core/BufferAttribute.js';
 
-var _vector = new Vector3();
-var _camera = new Camera();
+const _vector = new Vector3();
+const _camera = new Camera();
 
 function CameraHelper( camera ) {
 
-	var geometry = new BufferGeometry();
-	var material = new LineBasicMaterial( { color: 0xffffff, vertexColors: true, toneMapped: false } );
+	const geometry = new BufferGeometry();
+	const material = new LineBasicMaterial( { color: 0xffffff, vertexColors: true, toneMapped: false } );
 
-	var vertices = [];
-	var colors = [];
+	const vertices = [];
+	const colors = [];
 
-	var pointMap = {};
+	const pointMap = {};
 
 	// colors
 
-	var colorFrustum = new Color( 0xffaa00 );
-	var colorCone = new Color( 0xff0000 );
-	var colorUp = new Color( 0x00aaff );
-	var colorTarget = new Color( 0xffffff );
-	var colorCross = new Color( 0x333333 );
+	const colorFrustum = new Color( 0xffaa00 );
+	const colorCone = new Color( 0xff0000 );
+	const colorUp = new Color( 0x00aaff );
+	const colorTarget = new Color( 0xffffff );
+	const colorCross = new Color( 0x333333 );
 
 	// near
 
@@ -130,10 +130,10 @@ CameraHelper.prototype.constructor = CameraHelper;
 
 CameraHelper.prototype.update = function () {
 
-	var geometry = this.geometry;
-	var pointMap = this.pointMap;
+	const geometry = this.geometry;
+	const pointMap = this.pointMap;
 
-	var w = 1, h = 1;
+	const w = 1, h = 1;
 
 	// we need just camera projection matrix inverse
 	// world matrix must be identity
@@ -185,13 +185,13 @@ function setPoint( point, pointMap, geometry, camera, x, y, z ) {
 
 	_vector.set( x, y, z ).unproject( camera );
 
-	var points = pointMap[ point ];
+	const points = pointMap[ point ];
 
 	if ( points !== undefined ) {
 
-		var position = geometry.getAttribute( 'position' );
+		const position = geometry.getAttribute( 'position' );
 
-		for ( var i = 0, l = points.length; i < l; i ++ ) {
+		for ( let i = 0, l = points.length; i < l; i ++ ) {
 
 			position.setXYZ( points[ i ], _vector.x, _vector.y, _vector.z );
 

+ 5 - 5
src/helpers/DirectionalLightHelper.js

@@ -11,9 +11,9 @@ import { Float32BufferAttribute } from '../core/BufferAttribute.js';
 import { BufferGeometry } from '../core/BufferGeometry.js';
 import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
 
-var _v1 = new Vector3();
-var _v2 = new Vector3();
-var _v3 = new Vector3();
+const _v1 = new Vector3();
+const _v2 = new Vector3();
+const _v3 = new Vector3();
 
 function DirectionalLightHelper( light, size, color ) {
 
@@ -29,7 +29,7 @@ function DirectionalLightHelper( light, size, color ) {
 
 	if ( size === undefined ) size = 1;
 
-	var geometry = new BufferGeometry();
+	let geometry = new BufferGeometry();
 	geometry.setAttribute( 'position', new Float32BufferAttribute( [
 		- size, size, 0,
 		size, size, 0,
@@ -38,7 +38,7 @@ function DirectionalLightHelper( light, size, color ) {
 		- size, size, 0
 	], 3 ) );
 
-	var material = new LineBasicMaterial( { fog: false, toneMapped: false } );
+	const material = new LineBasicMaterial( { fog: false, toneMapped: false } );
 
 	this.lightPlane = new Line( geometry, material );
 	this.add( this.lightPlane );

+ 8 - 8
src/helpers/GridHelper.js

@@ -15,18 +15,18 @@ function GridHelper( size, divisions, color1, color2 ) {
 	color1 = new Color( color1 !== undefined ? color1 : 0x444444 );
 	color2 = new Color( color2 !== undefined ? color2 : 0x888888 );
 
-	var center = divisions / 2;
-	var step = size / divisions;
-	var halfSize = size / 2;
+	const center = divisions / 2;
+	const step = size / divisions;
+	const halfSize = size / 2;
 
-	var vertices = [], colors = [];
+	const vertices = [], colors = [];
 
-	for ( var i = 0, j = 0, k = - halfSize; i <= divisions; i ++, k += step ) {
+	for ( let i = 0, j = 0, k = - halfSize; i <= divisions; i ++, k += step ) {
 
 		vertices.push( - halfSize, 0, k, halfSize, 0, k );
 		vertices.push( k, 0, - halfSize, k, 0, halfSize );
 
-		var color = i === center ? color1 : color2;
+		const color = i === center ? color1 : color2;
 
 		color.toArray( colors, j ); j += 3;
 		color.toArray( colors, j ); j += 3;
@@ -35,11 +35,11 @@ function GridHelper( size, divisions, color1, color2 ) {
 
 	}
 
-	var geometry = new BufferGeometry();
+	const geometry = new BufferGeometry();
 	geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) );
 
-	var material = new LineBasicMaterial( { vertexColors: true, toneMapped: false } );
+	const material = new LineBasicMaterial( { vertexColors: true, toneMapped: false } );
 
 	LineSegments.call( this, geometry, material );
 

+ 10 - 10
src/helpers/HemisphereLightHelper.js

@@ -12,9 +12,9 @@ import { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js';
 import { OctahedronBufferGeometry } from '../geometries/OctahedronGeometry.js';
 import { BufferAttribute } from '../core/BufferAttribute.js';
 
-var _vector = new Vector3();
-var _color1 = new Color();
-var _color2 = new Color();
+const _vector = new Vector3();
+const _color1 = new Color();
+const _color2 = new Color();
 
 function HemisphereLightHelper( light, size, color ) {
 
@@ -28,14 +28,14 @@ function HemisphereLightHelper( light, size, color ) {
 
 	this.color = color;
 
-	var geometry = new OctahedronBufferGeometry( size );
+	const geometry = new OctahedronBufferGeometry( size );
 	geometry.rotateY( Math.PI * 0.5 );
 
 	this.material = new MeshBasicMaterial( { wireframe: true, fog: false, toneMapped: false } );
 	if ( this.color === undefined ) this.material.vertexColors = true;
 
-	var position = geometry.getAttribute( 'position' );
-	var colors = new Float32Array( position.count * 3 );
+	const position = geometry.getAttribute( 'position' );
+	const colors = new Float32Array( position.count * 3 );
 
 	geometry.setAttribute( 'color', new BufferAttribute( colors, 3 ) );
 
@@ -57,7 +57,7 @@ HemisphereLightHelper.prototype.dispose = function () {
 
 HemisphereLightHelper.prototype.update = function () {
 
-	var mesh = this.children[ 0 ];
+	const mesh = this.children[ 0 ];
 
 	if ( this.color !== undefined ) {
 
@@ -65,14 +65,14 @@ HemisphereLightHelper.prototype.update = function () {
 
 	} else {
 
-		var colors = mesh.geometry.getAttribute( 'color' );
+		const colors = mesh.geometry.getAttribute( 'color' );
 
 		_color1.copy( this.light.color );
 		_color2.copy( this.light.groundColor );
 
-		for ( var i = 0, l = colors.count; i < l; i ++ ) {
+		for ( let i = 0, l = colors.count; i < l; i ++ ) {
 
-			var color = ( i < ( l / 2 ) ) ? _color1 : _color2;
+			const color = ( i < ( l / 2 ) ) ? _color1 : _color2;
 
 			colors.setXYZ( i, color.r, color.g, color.b );
 

+ 6 - 6
src/helpers/PlaneHelper.js

@@ -17,11 +17,11 @@ function PlaneHelper( plane, size, hex ) {
 
 	this.size = ( size === undefined ) ? 1 : size;
 
-	var color = ( hex !== undefined ) ? hex : 0xffff00;
+	const color = ( hex !== undefined ) ? hex : 0xffff00;
 
-	var positions = [ 1, - 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, - 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0 ];
+	const positions = [ 1, - 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, - 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0 ];
 
-	var geometry = new BufferGeometry();
+	const geometry = new BufferGeometry();
 	geometry.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );
 	geometry.computeBoundingSphere();
 
@@ -31,9 +31,9 @@ function PlaneHelper( plane, size, hex ) {
 
 	//
 
-	var positions2 = [ 1, 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, 1, 1, - 1, - 1, 1, 1, - 1, 1 ];
+	const positions2 = [ 1, 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, 1, 1, - 1, - 1, 1, 1, - 1, 1 ];
 
-	var geometry2 = new BufferGeometry();
+	const geometry2 = new BufferGeometry();
 	geometry2.setAttribute( 'position', new Float32BufferAttribute( positions2, 3 ) );
 	geometry2.computeBoundingSphere();
 
@@ -46,7 +46,7 @@ PlaneHelper.prototype.constructor = PlaneHelper;
 
 PlaneHelper.prototype.updateMatrixWorld = function ( force ) {
 
-	var scale = - this.plane.constant;
+	let scale = - this.plane.constant;
 
 	if ( Math.abs( scale ) < 1e-8 ) scale = 1e-8; // sign does not matter
 

+ 6 - 6
src/helpers/PointLightHelper.js

@@ -14,8 +14,8 @@ function PointLightHelper( light, sphereSize, color ) {
 
 	this.color = color;
 
-	var geometry = new SphereBufferGeometry( sphereSize, 4, 2 );
-	var material = new MeshBasicMaterial( { wireframe: true, fog: false, toneMapped: false } );
+	const geometry = new SphereBufferGeometry( sphereSize, 4, 2 );
+	const material = new MeshBasicMaterial( { wireframe: true, fog: false, toneMapped: false } );
 
 	Mesh.call( this, geometry, material );
 
@@ -28,13 +28,13 @@ function PointLightHelper( light, sphereSize, color ) {
 
 
 	/*
-	var distanceGeometry = new THREE.IcosahedronBufferGeometry( 1, 2 );
-	var distanceMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false, wireframe: true, opacity: 0.1, transparent: true } );
+	const distanceGeometry = new THREE.IcosahedronBufferGeometry( 1, 2 );
+	const distanceMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false, wireframe: true, opacity: 0.1, transparent: true } );
 
 	this.lightSphere = new THREE.Mesh( bulbGeometry, bulbMaterial );
 	this.lightDistance = new THREE.Mesh( distanceGeometry, distanceMaterial );
 
-	var d = light.distance;
+	const d = light.distance;
 
 	if ( d === 0.0 ) {
 
@@ -74,7 +74,7 @@ PointLightHelper.prototype.update = function () {
 	}
 
 	/*
-	var d = this.light.distance;
+	const d = this.light.distance;
 
 	if ( d === 0.0 ) {
 

+ 16 - 19
src/helpers/PolarGridHelper.js

@@ -19,25 +19,22 @@ function PolarGridHelper( radius, radials, circles, divisions, color1, color2 )
 	color1 = new Color( color1 !== undefined ? color1 : 0x444444 );
 	color2 = new Color( color2 !== undefined ? color2 : 0x888888 );
 
-	var vertices = [];
-	var colors = [];
-
-	var x, z;
-	var v, i, j, r, color;
+	const vertices = [];
+	const colors = [];
 
 	// create the radials
 
-	for ( i = 0; i <= radials; i ++ ) {
+	for ( let i = 0; i <= radials; i ++ ) {
 
-		v = ( i / radials ) * ( Math.PI * 2 );
+		const v = ( i / radials ) * ( Math.PI * 2 );
 
-		x = Math.sin( v ) * radius;
-		z = Math.cos( v ) * radius;
+		const x = Math.sin( v ) * radius;
+		const z = Math.cos( v ) * radius;
 
 		vertices.push( 0, 0, 0 );
 		vertices.push( x, 0, z );
 
-		color = ( i & 1 ) ? color1 : color2;
+		const color = ( i & 1 ) ? color1 : color2;
 
 		colors.push( color.r, color.g, color.b );
 		colors.push( color.r, color.g, color.b );
@@ -46,20 +43,20 @@ function PolarGridHelper( radius, radials, circles, divisions, color1, color2 )
 
 	// create the circles
 
-	for ( i = 0; i <= circles; i ++ ) {
+	for ( let i = 0; i <= circles; i ++ ) {
 
-		color = ( i & 1 ) ? color1 : color2;
+		const color = ( i & 1 ) ? color1 : color2;
 
-		r = radius - ( radius / circles * i );
+		const r = radius - ( radius / circles * i );
 
-		for ( j = 0; j < divisions; j ++ ) {
+		for ( let j = 0; j < divisions; j ++ ) {
 
 			// first vertex
 
-			v = ( j / divisions ) * ( Math.PI * 2 );
+			let v = ( j / divisions ) * ( Math.PI * 2 );
 
-			x = Math.sin( v ) * r;
-			z = Math.cos( v ) * r;
+			let x = Math.sin( v ) * r;
+			let z = Math.cos( v ) * r;
 
 			vertices.push( x, 0, z );
 			colors.push( color.r, color.g, color.b );
@@ -78,11 +75,11 @@ function PolarGridHelper( radius, radials, circles, divisions, color1, color2 )
 
 	}
 
-	var geometry = new BufferGeometry();
+	const geometry = new BufferGeometry();
 	geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) );
 
-	var material = new LineBasicMaterial( { vertexColors: true, toneMapped: false } );
+	const material = new LineBasicMaterial( { vertexColors: true, toneMapped: false } );
 
 	LineSegments.call( this, geometry, material );
 

+ 19 - 19
src/helpers/SkeletonHelper.js

@@ -15,13 +15,13 @@ import { BufferGeometry } from '../core/BufferGeometry.js';
 import { Float32BufferAttribute } from '../core/BufferAttribute.js';
 import { Object3D } from '../core/Object3D.js';
 
-var _vector = new Vector3();
-var _boneMatrix = new Matrix4();
-var _matrixWorldInv = new Matrix4();
+const _vector = new Vector3();
+const _boneMatrix = new Matrix4();
+const _matrixWorldInv = new Matrix4();
 
 function getBoneList( object ) {
 
-	var boneList = [];
+	const boneList = [];
 
 	if ( object && object.isBone ) {
 
@@ -29,7 +29,7 @@ function getBoneList( object ) {
 
 	}
 
-	for ( var i = 0; i < object.children.length; i ++ ) {
+	for ( let i = 0; i < object.children.length; i ++ ) {
 
 		boneList.push.apply( boneList, getBoneList( object.children[ i ] ) );
 
@@ -41,19 +41,19 @@ function getBoneList( object ) {
 
 function SkeletonHelper( object ) {
 
-	var bones = getBoneList( object );
+	const bones = getBoneList( object );
 
-	var geometry = new BufferGeometry();
+	const geometry = new BufferGeometry();
 
-	var vertices = [];
-	var colors = [];
+	const vertices = [];
+	const colors = [];
 
-	var color1 = new Color( 0, 0, 1 );
-	var color2 = new Color( 0, 1, 0 );
+	const color1 = new Color( 0, 0, 1 );
+	const color2 = new Color( 0, 1, 0 );
 
-	for ( var i = 0; i < bones.length; i ++ ) {
+	for ( let i = 0; i < bones.length; i ++ ) {
 
-		var bone = bones[ i ];
+		const bone = bones[ i ];
 
 		if ( bone.parent && bone.parent.isBone ) {
 
@@ -69,7 +69,7 @@ function SkeletonHelper( object ) {
 	geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
 	geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) );
 
-	var material = new LineBasicMaterial( { vertexColors: true, depthTest: false, depthWrite: false, toneMapped: false, transparent: true } );
+	const material = new LineBasicMaterial( { vertexColors: true, depthTest: false, depthWrite: false, toneMapped: false, transparent: true } );
 
 	LineSegments.call( this, geometry, material );
 
@@ -90,16 +90,16 @@ SkeletonHelper.prototype.isSkeletonHelper = true;
 
 SkeletonHelper.prototype.updateMatrixWorld = function ( force ) {
 
-	var bones = this.bones;
+	const bones = this.bones;
 
-	var geometry = this.geometry;
-	var position = geometry.getAttribute( 'position' );
+	const geometry = this.geometry;
+	const position = geometry.getAttribute( 'position' );
 
 	_matrixWorldInv.getInverse( this.root.matrixWorld );
 
-	for ( var i = 0, j = 0; i < bones.length; i ++ ) {
+	for ( let i = 0, j = 0; i < bones.length; i ++ ) {
 
-		var bone = bones[ i ];
+		const bone = bones[ i ];
 
 		if ( bone.parent && bone.parent.isBone ) {
 

+ 9 - 9
src/helpers/SpotLightHelper.js

@@ -11,7 +11,7 @@ import { LineBasicMaterial } from '../materials/LineBasicMaterial.js';
 import { Float32BufferAttribute } from '../core/BufferAttribute.js';
 import { BufferGeometry } from '../core/BufferGeometry.js';
 
-var _vector = new Vector3();
+const _vector = new Vector3();
 
 function SpotLightHelper( light, color ) {
 
@@ -25,9 +25,9 @@ function SpotLightHelper( light, color ) {
 
 	this.color = color;
 
-	var geometry = new BufferGeometry();
+	const geometry = new BufferGeometry();
 
-	var positions = [
+	const positions = [
 		0, 0, 0, 	0, 0, 1,
 		0, 0, 0, 	1, 0, 1,
 		0, 0, 0,	- 1, 0, 1,
@@ -35,10 +35,10 @@ function SpotLightHelper( light, color ) {
 		0, 0, 0, 	0, - 1, 1
 	];
 
-	for ( var i = 0, j = 1, l = 32; i < l; i ++, j ++ ) {
+	for ( let i = 0, j = 1, l = 32; i < l; i ++, j ++ ) {
 
-		var p1 = ( i / l ) * Math.PI * 2;
-		var p2 = ( j / l ) * Math.PI * 2;
+		const p1 = ( i / l ) * Math.PI * 2;
+		const p2 = ( j / l ) * Math.PI * 2;
 
 		positions.push(
 			Math.cos( p1 ), Math.sin( p1 ), 1,
@@ -49,7 +49,7 @@ function SpotLightHelper( light, color ) {
 
 	geometry.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );
 
-	var material = new LineBasicMaterial( { fog: false, toneMapped: false } );
+	const material = new LineBasicMaterial( { fog: false, toneMapped: false } );
 
 	this.cone = new LineSegments( geometry, material );
 	this.add( this.cone );
@@ -72,8 +72,8 @@ SpotLightHelper.prototype.update = function () {
 
 	this.light.updateMatrixWorld();
 
-	var coneLength = this.light.distance ? this.light.distance : 1000;
-	var coneWidth = coneLength * Math.tan( this.light.angle );
+	const coneLength = this.light.distance ? this.light.distance : 1000;
+	const coneWidth = coneLength * Math.tan( this.light.angle );
 
 	this.cone.scale.set( coneWidth, coneWidth, coneLength );
 

+ 2 - 2
src/lights/AmbientLightProbe.js

@@ -9,7 +9,7 @@ function AmbientLightProbe( color, intensity ) {
 
 	LightProbe.call( this, undefined, intensity );
 
-	var color1 = new Color().set( color );
+	const color1 = new Color().set( color );
 
 	// without extra factor of PI in the shader, would be 2 / Math.sqrt( Math.PI );
 	this.sh.coefficients[ 0 ].set( color1.r, color1.g, color1.b ).multiplyScalar( 2 * Math.sqrt( Math.PI ) );
@@ -32,7 +32,7 @@ AmbientLightProbe.prototype = Object.assign( Object.create( LightProbe.prototype
 
 	toJSON: function ( meta ) {
 
-		var data = LightProbe.prototype.toJSON.call( this, meta );
+		const data = LightProbe.prototype.toJSON.call( this, meta );
 
 		// data.sh = this.sh.toArray(); // todo
 

+ 1 - 1
src/lights/DirectionalLight.d.ts

@@ -6,7 +6,7 @@ import { Light } from './Light';
 /**
  * @example
  * // White directional light at half intensity shining from the top.
- * var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 );
+ * const directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 );
  * directionalLight.position.set( 0, 1, 0 );
  * scene.add( directionalLight );
  *

+ 7 - 7
src/lights/HemisphereLightProbe.js

@@ -10,15 +10,15 @@ function HemisphereLightProbe( skyColor, groundColor, intensity ) {
 
 	LightProbe.call( this, undefined, intensity );
 
-	var color1 = new Color().set( skyColor );
-	var color2 = new Color().set( groundColor );
+	const color1 = new Color().set( skyColor );
+	const color2 = new Color().set( groundColor );
 
-	var sky = new Vector3( color1.r, color1.g, color1.b );
-	var ground = new Vector3( color2.r, color2.g, color2.b );
+	const sky = new Vector3( color1.r, color1.g, color1.b );
+	const ground = new Vector3( color2.r, color2.g, color2.b );
 
 	// without extra factor of PI in the shader, should = 1 / Math.sqrt( Math.PI );
-	var c0 = Math.sqrt( Math.PI );
-	var c1 = c0 * Math.sqrt( 0.75 );
+	const c0 = Math.sqrt( Math.PI );
+	const c1 = c0 * Math.sqrt( 0.75 );
 
 	this.sh.coefficients[ 0 ].copy( sky ).add( ground ).multiplyScalar( c0 );
 	this.sh.coefficients[ 1 ].copy( sky ).sub( ground ).multiplyScalar( c1 );
@@ -41,7 +41,7 @@ HemisphereLightProbe.prototype = Object.assign( Object.create( LightProbe.protot
 
 	toJSON: function ( meta ) {
 
-		var data = LightProbe.prototype.toJSON.call( this, meta );
+		const data = LightProbe.prototype.toJSON.call( this, meta );
 
 		// data.sh = this.sh.toArray(); // todo
 

+ 1 - 1
src/lights/Light.js

@@ -38,7 +38,7 @@ Light.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 	toJSON: function ( meta ) {
 
-		var data = Object3D.prototype.toJSON.call( this, meta );
+		const data = Object3D.prototype.toJSON.call( this, meta );
 
 		data.object.color = this.color.getHex();
 		data.object.intensity = this.intensity;

+ 1 - 1
src/lights/LightProbe.js

@@ -44,7 +44,7 @@ LightProbe.prototype = Object.assign( Object.create( Light.prototype ), {
 
 	toJSON: function ( meta ) {
 
-		var data = Light.prototype.toJSON.call( this, meta );
+		const data = Light.prototype.toJSON.call( this, meta );
 
 		data.object.sh = this.sh.toArray();
 

+ 2 - 2
src/lights/LightShadow.js

@@ -56,7 +56,7 @@ Object.assign( LightShadow.prototype, {
 
 	updateMatrices: function ( light ) {
 
-		var shadowCamera = this.camera,
+		const shadowCamera = this.camera,
 			shadowMatrix = this.matrix,
 			projScreenMatrix = this._projScreenMatrix,
 			lookTarget = this._lookTarget,
@@ -117,7 +117,7 @@ Object.assign( LightShadow.prototype, {
 
 	toJSON: function () {
 
-		var object = {};
+		const object = {};
 
 		if ( this.bias !== 0 ) object.bias = this.bias;
 		if ( this.radius !== 1 ) object.radius = this.radius;

+ 1 - 1
src/lights/PointLight.d.ts

@@ -4,7 +4,7 @@ import { PointLightShadow } from './PointLightShadow';
 
 /**
  * @example
- * var light = new THREE.PointLight( 0xff0000, 1, 100 );
+ * const light = new THREE.PointLight( 0xff0000, 1, 100 );
  * light.position.set( 50, 50, 50 );
  * scene.add( light );
  */

+ 1 - 1
src/lights/PointLightShadow.js

@@ -62,7 +62,7 @@ PointLightShadow.prototype = Object.assign( Object.create( LightShadow.prototype
 
 		if ( viewportIndex === undefined ) viewportIndex = 0;
 
-		var camera = this.camera,
+		const camera = this.camera,
 			shadowMatrix = this.matrix,
 			lightPositionWorld = this._lightPositionWorld,
 			lookTarget = this._lookTarget,

+ 1 - 1
src/lights/RectAreaLight.js

@@ -34,7 +34,7 @@ RectAreaLight.prototype = Object.assign( Object.create( Light.prototype ), {
 
 	toJSON: function ( meta ) {
 
-		var data = Light.prototype.toJSON.call( this, meta );
+		const data = Light.prototype.toJSON.call( this, meta );
 
 		data.object.width = this.width;
 		data.object.height = this.height;

+ 4 - 4
src/lights/SpotLightShadow.js

@@ -20,11 +20,11 @@ SpotLightShadow.prototype = Object.assign( Object.create( LightShadow.prototype
 
 	updateMatrices: function ( light ) {
 
-		var camera = this.camera;
+		const camera = this.camera;
 
-		var fov = MathUtils.RAD2DEG * 2 * light.angle;
-		var aspect = this.mapSize.width / this.mapSize.height;
-		var far = light.distance || camera.far;
+		const fov = MathUtils.RAD2DEG * 2 * light.angle;
+		const aspect = this.mapSize.width / this.mapSize.height;
+		const far = light.distance || camera.far;
 
 		if ( fov !== camera.fov || aspect !== camera.aspect || far !== camera.far ) {
 

+ 18 - 15
src/materials/Material.js

@@ -7,7 +7,7 @@ import { MathUtils } from '../math/MathUtils.js';
  * @author alteredq / http://alteredqualia.com/
  */
 
-var materialId = 0;
+let materialId = 0;
 
 function Material() {
 
@@ -89,9 +89,9 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 
 		if ( values === undefined ) return;
 
-		for ( var key in values ) {
+		for ( const key in values ) {
 
-			var newValue = values[ key ];
+			const newValue = values[ key ];
 
 			if ( newValue === undefined ) {
 
@@ -109,7 +109,7 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 
 			}
 
-			var currentValue = this[ key ];
+			const currentValue = this[ key ];
 
 			if ( currentValue === undefined ) {
 
@@ -138,7 +138,7 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 
 	toJSON: function ( meta ) {
 
-		var isRoot = ( meta === undefined || typeof meta === 'string' );
+		const isRoot = ( meta === undefined || typeof meta === 'string' );
 
 		if ( isRoot ) {
 
@@ -149,7 +149,7 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 
 		}
 
-		var data = {
+		const data = {
 			metadata: {
 				version: 4.5,
 				type: 'Material',
@@ -314,11 +314,11 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 
 		function extractFromCache( cache ) {
 
-			var values = [];
+			const values = [];
 
-			for ( var key in cache ) {
+			for ( const key in cache ) {
 
-				var data = cache[ key ];
+				const data = cache[ key ];
 				delete data.metadata;
 				values.push( data );
 
@@ -330,8 +330,8 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 
 		if ( isRoot ) {
 
-			var textures = extractFromCache( meta.textures );
-			var images = extractFromCache( meta.images );
+			const textures = extractFromCache( meta.textures );
+			const images = extractFromCache( meta.images );
 
 			if ( textures.length > 0 ) data.textures = textures;
 			if ( images.length > 0 ) data.images = images;
@@ -382,17 +382,20 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 		this.stencilZPass = source.stencilZPass;
 		this.stencilWrite = source.stencilWrite;
 
-		var srcPlanes = source.clippingPlanes,
-			dstPlanes = null;
+		const srcPlanes = source.clippingPlanes;
+		let dstPlanes = null;
 
 		if ( srcPlanes !== null ) {
 
-			var n = srcPlanes.length;
+			const n = srcPlanes.length;
 			dstPlanes = new Array( n );
 
-			for ( var i = 0; i !== n; ++ i )
+			for ( let i = 0; i !== n; ++ i ) {
+
 				dstPlanes[ i ] = srcPlanes[ i ].clone();
 
+			}
+
 		}
 
 		this.clippingPlanes = dstPlanes;

+ 6 - 6
src/materials/ShaderMaterial.js

@@ -117,14 +117,14 @@ ShaderMaterial.prototype.copy = function ( source ) {
 
 ShaderMaterial.prototype.toJSON = function ( meta ) {
 
-	var data = Material.prototype.toJSON.call( this, meta );
+	const data = Material.prototype.toJSON.call( this, meta );
 
 	data.uniforms = {};
 
-	for ( var name in this.uniforms ) {
+	for ( const name in this.uniforms ) {
 
-		var uniform = this.uniforms[ name ];
-		var value = uniform.value;
+		const uniform = this.uniforms[ name ];
+		const value = uniform.value;
 
 		if ( value && value.isTexture ) {
 
@@ -192,9 +192,9 @@ ShaderMaterial.prototype.toJSON = function ( meta ) {
 	data.vertexShader = this.vertexShader;
 	data.fragmentShader = this.fragmentShader;
 
-	var extensions = {};
+	const extensions = {};
 
-	for ( var key in this.extensions ) {
+	for ( const key in this.extensions ) {
 
 		if ( this.extensions[ key ] === true ) extensions[ key ] = true;
 

+ 9 - 9
src/objects/InstancedMesh.js

@@ -5,12 +5,12 @@ import { BufferAttribute } from '../core/BufferAttribute.js';
 import { Mesh } from './Mesh.js';
 import { Matrix4 } from '../math/Matrix4.js';
 
-var _instanceLocalMatrix = new Matrix4();
-var _instanceWorldMatrix = new Matrix4();
+const _instanceLocalMatrix = new Matrix4();
+const _instanceWorldMatrix = new Matrix4();
 
-var _instanceIntersects = [];
+const _instanceIntersects = [];
 
-var _mesh = new Mesh();
+const _mesh = new Mesh();
 
 function InstancedMesh( geometry, material, count ) {
 
@@ -38,15 +38,15 @@ InstancedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), {
 
 	raycast: function ( raycaster, intersects ) {
 
-		var matrixWorld = this.matrixWorld;
-		var raycastTimes = this.count;
+		const matrixWorld = this.matrixWorld;
+		const raycastTimes = this.count;
 
 		_mesh.geometry = this.geometry;
 		_mesh.material = this.material;
 
 		if ( _mesh.material === undefined ) return;
 
-		for ( var instanceId = 0; instanceId < raycastTimes; instanceId ++ ) {
+		for ( let instanceId = 0; instanceId < raycastTimes; instanceId ++ ) {
 
 			// calculate the world matrix for each instance
 
@@ -62,9 +62,9 @@ InstancedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), {
 
 			// process the result of raycast
 
-			for ( var i = 0, l = _instanceIntersects.length; i < l; i ++ ) {
+			for ( let i = 0, l = _instanceIntersects.length; i < l; i ++ ) {
 
-				var intersect = _instanceIntersects[ i ];
+				const intersect = _instanceIntersects[ i ];
 				intersect.instanceId = instanceId;
 				intersect.object = this;
 				intersects.push( intersect );

+ 24 - 18
src/objects/LOD.js

@@ -7,8 +7,8 @@ import { Object3D } from '../core/Object3D.js';
  * @author mrdoob / http://mrdoob.com/
  */
 
-var _v1 = new Vector3();
-var _v2 = new Vector3();
+const _v1 = new Vector3();
+const _v2 = new Vector3();
 
 function LOD() {
 
@@ -39,11 +39,11 @@ LOD.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 		Object3D.prototype.copy.call( this, source, false );
 
-		var levels = source.levels;
+		const levels = source.levels;
 
-		for ( var i = 0, l = levels.length; i < l; i ++ ) {
+		for ( let i = 0, l = levels.length; i < l; i ++ ) {
 
-			var level = levels[ i ];
+			const level = levels[ i ];
 
 			this.addLevel( level.object.clone(), level.distance );
 
@@ -61,9 +61,11 @@ LOD.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 		distance = Math.abs( distance );
 
-		var levels = this.levels;
+		const levels = this.levels;
 
-		for ( var l = 0; l < levels.length; l ++ ) {
+		let l;
+
+		for ( l = 0; l < levels.length; l ++ ) {
 
 			if ( distance < levels[ l ].distance ) {
 
@@ -89,11 +91,13 @@ LOD.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 	getObjectForDistance: function ( distance ) {
 
-		var levels = this.levels;
+		const levels = this.levels;
 
 		if ( levels.length > 0 ) {
 
-			for ( var i = 1, l = levels.length; i < l; i ++ ) {
+			let i, l;
+
+			for ( i = 1, l = levels.length; i < l; i ++ ) {
 
 				if ( distance < levels[ i ].distance ) {
 
@@ -113,13 +117,13 @@ LOD.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 	raycast: function ( raycaster, intersects ) {
 
-		var levels = this.levels;
+		const levels = this.levels;
 
 		if ( levels.length > 0 ) {
 
 			_v1.setFromMatrixPosition( this.matrixWorld );
 
-			var distance = raycaster.ray.origin.distanceTo( _v1 );
+			const distance = raycaster.ray.origin.distanceTo( _v1 );
 
 			this.getObjectForDistance( distance ).raycast( raycaster, intersects );
 
@@ -129,18 +133,20 @@ LOD.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 	update: function ( camera ) {
 
-		var levels = this.levels;
+		const levels = this.levels;
 
 		if ( levels.length > 1 ) {
 
 			_v1.setFromMatrixPosition( camera.matrixWorld );
 			_v2.setFromMatrixPosition( this.matrixWorld );
 
-			var distance = _v1.distanceTo( _v2 ) / camera.zoom;
+			const distance = _v1.distanceTo( _v2 ) / camera.zoom;
 
 			levels[ 0 ].object.visible = true;
 
-			for ( var i = 1, l = levels.length; i < l; i ++ ) {
+			let i, l;
+
+			for ( i = 1, l = levels.length; i < l; i ++ ) {
 
 				if ( distance >= levels[ i ].distance ) {
 
@@ -169,17 +175,17 @@ LOD.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 	toJSON: function ( meta ) {
 
-		var data = Object3D.prototype.toJSON.call( this, meta );
+		const data = Object3D.prototype.toJSON.call( this, meta );
 
 		if ( this.autoUpdate === false ) data.object.autoUpdate = false;
 
 		data.object.levels = [];
 
-		var levels = this.levels;
+		const levels = this.levels;
 
-		for ( var i = 0, l = levels.length; i < l; i ++ ) {
+		for ( let i = 0, l = levels.length; i < l; i ++ ) {
 
-			var level = levels[ i ];
+			const level = levels[ i ];
 
 			data.object.levels.push( {
 				object: level.object.uuid,

+ 46 - 47
src/objects/Line.js

@@ -11,11 +11,11 @@ import { Float32BufferAttribute } from '../core/BufferAttribute.js';
  * @author mrdoob / http://mrdoob.com/
  */
 
-var _start = new Vector3();
-var _end = new Vector3();
-var _inverseMatrix = new Matrix4();
-var _ray = new Ray();
-var _sphere = new Sphere();
+const _start = new Vector3();
+const _end = new Vector3();
+const _inverseMatrix = new Matrix4();
+const _ray = new Ray();
+const _sphere = new Sphere();
 
 function Line( geometry, material, mode ) {
 
@@ -44,7 +44,7 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 	computeLineDistances: function () {
 
-		var geometry = this.geometry;
+		const geometry = this.geometry;
 
 		if ( geometry.isBufferGeometry ) {
 
@@ -52,10 +52,10 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 			if ( geometry.index === null ) {
 
-				var positionAttribute = geometry.attributes.position;
-				var lineDistances = [ 0 ];
+				const positionAttribute = geometry.attributes.position;
+				const lineDistances = [ 0 ];
 
-				for ( var i = 1, l = positionAttribute.count; i < l; i ++ ) {
+				for ( let i = 1, l = positionAttribute.count; i < l; i ++ ) {
 
 					_start.fromBufferAttribute( positionAttribute, i - 1 );
 					_end.fromBufferAttribute( positionAttribute, i );
@@ -75,12 +75,12 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 		} else if ( geometry.isGeometry ) {
 
-			var vertices = geometry.vertices;
-			var lineDistances = geometry.lineDistances;
+			const vertices = geometry.vertices;
+			const lineDistances = geometry.lineDistances;
 
 			lineDistances[ 0 ] = 0;
 
-			for ( var i = 1, l = vertices.length; i < l; i ++ ) {
+			for ( let i = 1, l = vertices.length; i < l; i ++ ) {
 
 				lineDistances[ i ] = lineDistances[ i - 1 ];
 				lineDistances[ i ] += vertices[ i - 1 ].distanceTo( vertices[ i ] );
@@ -95,9 +95,9 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 	raycast: function ( raycaster, intersects ) {
 
-		var geometry = this.geometry;
-		var matrixWorld = this.matrixWorld;
-		var threshold = raycaster.params.Line.threshold;
+		const geometry = this.geometry;
+		const matrixWorld = this.matrixWorld;
+		const threshold = raycaster.params.Line.threshold;
 
 		// Checking boundingSphere distance to ray
 
@@ -114,40 +114,40 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), {
 		_inverseMatrix.getInverse( matrixWorld );
 		_ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix );
 
-		var localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );
-		var localThresholdSq = localThreshold * localThreshold;
+		const localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );
+		const localThresholdSq = localThreshold * localThreshold;
 
-		var vStart = new Vector3();
-		var vEnd = new Vector3();
-		var interSegment = new Vector3();
-		var interRay = new Vector3();
-		var step = ( this && this.isLineSegments ) ? 2 : 1;
+		const vStart = new Vector3();
+		const vEnd = new Vector3();
+		const interSegment = new Vector3();
+		const interRay = new Vector3();
+		const step = ( this && this.isLineSegments ) ? 2 : 1;
 
 		if ( geometry.isBufferGeometry ) {
 
-			var index = geometry.index;
-			var attributes = geometry.attributes;
-			var positions = attributes.position.array;
+			const index = geometry.index;
+			const attributes = geometry.attributes;
+			const positions = attributes.position.array;
 
 			if ( index !== null ) {
 
-				var indices = index.array;
+				const indices = index.array;
 
-				for ( var i = 0, l = indices.length - 1; i < l; i += step ) {
+				for ( let i = 0, l = indices.length - 1; i < l; i += step ) {
 
-					var a = indices[ i ];
-					var b = indices[ i + 1 ];
+					const a = indices[ i ];
+					const b = indices[ i + 1 ];
 
 					vStart.fromArray( positions, a * 3 );
 					vEnd.fromArray( positions, b * 3 );
 
-					var distSq = _ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment );
+					const distSq = _ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment );
 
 					if ( distSq > localThresholdSq ) continue;
 
 					interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation
 
-					var distance = raycaster.ray.origin.distanceTo( interRay );
+					const distance = raycaster.ray.origin.distanceTo( interRay );
 
 					if ( distance < raycaster.near || distance > raycaster.far ) continue;
 
@@ -168,18 +168,18 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 			} else {
 
-				for ( var i = 0, l = positions.length / 3 - 1; i < l; i += step ) {
+				for ( let i = 0, l = positions.length / 3 - 1; i < l; i += step ) {
 
 					vStart.fromArray( positions, 3 * i );
 					vEnd.fromArray( positions, 3 * i + 3 );
 
-					var distSq = _ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment );
+					const distSq = _ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment );
 
 					if ( distSq > localThresholdSq ) continue;
 
 					interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation
 
-					var distance = raycaster.ray.origin.distanceTo( interRay );
+					const distance = raycaster.ray.origin.distanceTo( interRay );
 
 					if ( distance < raycaster.near || distance > raycaster.far ) continue;
 
@@ -202,18 +202,18 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 		} else if ( geometry.isGeometry ) {
 
-			var vertices = geometry.vertices;
-			var nbVertices = vertices.length;
+			const vertices = geometry.vertices;
+			const nbVertices = vertices.length;
 
-			for ( var i = 0; i < nbVertices - 1; i += step ) {
+			for ( let i = 0; i < nbVertices - 1; i += step ) {
 
-				var distSq = _ray.distanceSqToSegment( vertices[ i ], vertices[ i + 1 ], interRay, interSegment );
+				const distSq = _ray.distanceSqToSegment( vertices[ i ], vertices[ i + 1 ], interRay, interSegment );
 
 				if ( distSq > localThresholdSq ) continue;
 
 				interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation
 
-				var distance = raycaster.ray.origin.distanceTo( interRay );
+				const distance = raycaster.ray.origin.distanceTo( interRay );
 
 				if ( distance < raycaster.near || distance > raycaster.far ) continue;
 
@@ -238,26 +238,25 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 	updateMorphTargets: function () {
 
-		var geometry = this.geometry;
-		var m, ml, name;
+		const geometry = this.geometry;
 
 		if ( geometry.isBufferGeometry ) {
 
-			var morphAttributes = geometry.morphAttributes;
-			var keys = Object.keys( morphAttributes );
+			const morphAttributes = geometry.morphAttributes;
+			const keys = Object.keys( morphAttributes );
 
 			if ( keys.length > 0 ) {
 
-				var morphAttribute = morphAttributes[ keys[ 0 ] ];
+				const morphAttribute = morphAttributes[ keys[ 0 ] ];
 
 				if ( morphAttribute !== undefined ) {
 
 					this.morphTargetInfluences = [];
 					this.morphTargetDictionary = {};
 
-					for ( m = 0, ml = morphAttribute.length; m < ml; m ++ ) {
+					for ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) {
 
-						name = morphAttribute[ m ].name || String( m );
+						const name = morphAttribute[ m ].name || String( m );
 
 						this.morphTargetInfluences.push( 0 );
 						this.morphTargetDictionary[ name ] = m;
@@ -270,7 +269,7 @@ Line.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 		} else {
 
-			var morphTargets = geometry.morphTargets;
+			const morphTargets = geometry.morphTargets;
 
 			if ( morphTargets !== undefined && morphTargets.length > 0 ) {
 

+ 9 - 9
src/objects/LineSegments.js

@@ -6,8 +6,8 @@ import { Float32BufferAttribute } from '../core/BufferAttribute.js';
  * @author mrdoob / http://mrdoob.com/
  */
 
-var _start = new Vector3();
-var _end = new Vector3();
+const _start = new Vector3();
+const _end = new Vector3();
 
 function LineSegments( geometry, material ) {
 
@@ -25,7 +25,7 @@ LineSegments.prototype = Object.assign( Object.create( Line.prototype ), {
 
 	computeLineDistances: function () {
 
-		var geometry = this.geometry;
+		const geometry = this.geometry;
 
 		if ( geometry.isBufferGeometry ) {
 
@@ -33,10 +33,10 @@ LineSegments.prototype = Object.assign( Object.create( Line.prototype ), {
 
 			if ( geometry.index === null ) {
 
-				var positionAttribute = geometry.attributes.position;
-				var lineDistances = [];
+				const positionAttribute = geometry.attributes.position;
+				const lineDistances = [];
 
-				for ( var i = 0, l = positionAttribute.count; i < l; i += 2 ) {
+				for ( let i = 0, l = positionAttribute.count; i < l; i += 2 ) {
 
 					_start.fromBufferAttribute( positionAttribute, i );
 					_end.fromBufferAttribute( positionAttribute, i + 1 );
@@ -56,10 +56,10 @@ LineSegments.prototype = Object.assign( Object.create( Line.prototype ), {
 
 		} else if ( geometry.isGeometry ) {
 
-			var vertices = geometry.vertices;
-			var lineDistances = geometry.lineDistances;
+			const vertices = geometry.vertices;
+			const lineDistances = geometry.lineDistances;
 
-			for ( var i = 0, l = vertices.length; i < l; i += 2 ) {
+			for ( let i = 0, l = vertices.length; i < l; i += 2 ) {
 
 				_start.copy( vertices[ i ] );
 				_end.copy( vertices[ i + 1 ] );

+ 86 - 92
src/objects/Mesh.js

@@ -17,28 +17,28 @@ import { BufferGeometry } from '../core/BufferGeometry.js';
  * @author jonobr1 / http://jonobr1.com/
  */
 
-var _inverseMatrix = new Matrix4();
-var _ray = new Ray();
-var _sphere = new Sphere();
+const _inverseMatrix = new Matrix4();
+const _ray = new Ray();
+const _sphere = new Sphere();
 
-var _vA = new Vector3();
-var _vB = new Vector3();
-var _vC = new Vector3();
+const _vA = new Vector3();
+const _vB = new Vector3();
+const _vC = new Vector3();
 
-var _tempA = new Vector3();
-var _tempB = new Vector3();
-var _tempC = new Vector3();
+const _tempA = new Vector3();
+const _tempB = new Vector3();
+const _tempC = new Vector3();
 
-var _morphA = new Vector3();
-var _morphB = new Vector3();
-var _morphC = new Vector3();
+const _morphA = new Vector3();
+const _morphB = new Vector3();
+const _morphC = 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();
 
-var _intersectionPoint = new Vector3();
-var _intersectionPointWorld = new Vector3();
+const _intersectionPoint = new Vector3();
+const _intersectionPointWorld = new Vector3();
 
 function Mesh( geometry, material ) {
 
@@ -81,26 +81,25 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 	updateMorphTargets: function () {
 
-		var geometry = this.geometry;
-		var m, ml, name;
+		const geometry = this.geometry;
 
 		if ( geometry.isBufferGeometry ) {
 
-			var morphAttributes = geometry.morphAttributes;
-			var keys = Object.keys( morphAttributes );
+			const morphAttributes = geometry.morphAttributes;
+			const keys = Object.keys( morphAttributes );
 
 			if ( keys.length > 0 ) {
 
-				var morphAttribute = morphAttributes[ keys[ 0 ] ];
+				const morphAttribute = morphAttributes[ keys[ 0 ] ];
 
 				if ( morphAttribute !== undefined ) {
 
 					this.morphTargetInfluences = [];
 					this.morphTargetDictionary = {};
 
-					for ( m = 0, ml = morphAttribute.length; m < ml; m ++ ) {
+					for ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) {
 
-						name = morphAttribute[ m ].name || String( m );
+						const name = morphAttribute[ m ].name || String( m );
 
 						this.morphTargetInfluences.push( 0 );
 						this.morphTargetDictionary[ name ] = m;
@@ -113,7 +112,7 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 		} else {
 
-			var morphTargets = geometry.morphTargets;
+			const morphTargets = geometry.morphTargets;
 
 			if ( morphTargets !== undefined && morphTargets.length > 0 ) {
 
@@ -127,9 +126,9 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 	raycast: function ( raycaster, intersects ) {
 
-		var geometry = this.geometry;
-		var material = this.material;
-		var matrixWorld = this.matrixWorld;
+		const geometry = this.geometry;
+		const material = this.material;
+		const matrixWorld = this.matrixWorld;
 
 		if ( material === undefined ) return;
 
@@ -155,22 +154,18 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 		}
 
-		var intersection;
+		let intersection;
 
 		if ( geometry.isBufferGeometry ) {
 
-			var a, b, c;
-			var index = geometry.index;
-			var position = geometry.attributes.position;
-			var morphPosition = geometry.morphAttributes.position;
-			var morphTargetsRelative = geometry.morphTargetsRelative;
-			var uv = geometry.attributes.uv;
-			var uv2 = geometry.attributes.uv2;
-			var groups = geometry.groups;
-			var drawRange = geometry.drawRange;
-			var i, j, il, jl;
-			var group, groupMaterial;
-			var start, end;
+			const index = geometry.index;
+			const position = geometry.attributes.position;
+			const morphPosition = geometry.morphAttributes.position;
+			const morphTargetsRelative = geometry.morphTargetsRelative;
+			const uv = geometry.attributes.uv;
+			const uv2 = geometry.attributes.uv2;
+			const groups = geometry.groups;
+			const drawRange = geometry.drawRange;
 
 			if ( index !== null ) {
 
@@ -178,19 +173,19 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 				if ( Array.isArray( material ) ) {
 
-					for ( i = 0, il = groups.length; i < il; i ++ ) {
+					for ( let i = 0, il = groups.length; i < il; i ++ ) {
 
-						group = groups[ i ];
-						groupMaterial = material[ group.materialIndex ];
+						const group = groups[ i ];
+						const groupMaterial = material[ group.materialIndex ];
 
-						start = Math.max( group.start, drawRange.start );
-						end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );
+						const start = Math.max( group.start, drawRange.start );
+						const end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );
 
-						for ( j = start, jl = end; j < jl; j += 3 ) {
+						for ( let j = start, jl = end; j < jl; j += 3 ) {
 
-							a = index.getX( j );
-							b = index.getX( j + 1 );
-							c = index.getX( j + 2 );
+							const a = index.getX( j );
+							const b = index.getX( j + 1 );
+							const c = index.getX( j + 2 );
 
 							intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );
 
@@ -208,14 +203,14 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 				} else {
 
-					start = Math.max( 0, drawRange.start );
-					end = Math.min( index.count, ( drawRange.start + drawRange.count ) );
+					const start = Math.max( 0, drawRange.start );
+					const end = Math.min( index.count, ( drawRange.start + drawRange.count ) );
 
-					for ( i = start, il = end; i < il; i += 3 ) {
+					for ( let i = start, il = end; i < il; i += 3 ) {
 
-						a = index.getX( i );
-						b = index.getX( i + 1 );
-						c = index.getX( i + 2 );
+						const a = index.getX( i );
+						const b = index.getX( i + 1 );
+						const c = index.getX( i + 2 );
 
 						intersection = checkBufferGeometryIntersection( this, material, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );
 
@@ -236,19 +231,19 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 				if ( Array.isArray( material ) ) {
 
-					for ( i = 0, il = groups.length; i < il; i ++ ) {
+					for ( let i = 0, il = groups.length; i < il; i ++ ) {
 
-						group = groups[ i ];
-						groupMaterial = material[ group.materialIndex ];
+						const group = groups[ i ];
+						const groupMaterial = material[ group.materialIndex ];
 
-						start = Math.max( group.start, drawRange.start );
-						end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );
+						const start = Math.max( group.start, drawRange.start );
+						const end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );
 
-						for ( j = start, jl = end; j < jl; j += 3 ) {
+						for ( let j = start, jl = end; j < jl; j += 3 ) {
 
-							a = j;
-							b = j + 1;
-							c = j + 2;
+							const a = j;
+							const b = j + 1;
+							const c = j + 2;
 
 							intersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );
 
@@ -266,14 +261,14 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 				} else {
 
-					start = Math.max( 0, drawRange.start );
-					end = Math.min( position.count, ( drawRange.start + drawRange.count ) );
+					const start = Math.max( 0, drawRange.start );
+					const end = Math.min( position.count, ( drawRange.start + drawRange.count ) );
 
-					for ( i = start, il = end; i < il; i += 3 ) {
+					for ( let i = start, il = end; i < il; i += 3 ) {
 
-						a = i;
-						b = i + 1;
-						c = i + 2;
+						const a = i;
+						const b = i + 1;
+						const c = i + 2;
 
 						intersection = checkBufferGeometryIntersection( this, material, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );
 
@@ -292,26 +287,25 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 		} else if ( geometry.isGeometry ) {
 
-			var fvA, fvB, fvC;
-			var isMultiMaterial = Array.isArray( material );
+			const isMultiMaterial = Array.isArray( material );
 
-			var vertices = geometry.vertices;
-			var faces = geometry.faces;
-			var uvs;
+			const vertices = geometry.vertices;
+			const faces = geometry.faces;
+			let uvs;
 
-			var faceVertexUvs = geometry.faceVertexUvs[ 0 ];
+			const faceVertexUvs = geometry.faceVertexUvs[ 0 ];
 			if ( faceVertexUvs.length > 0 ) uvs = faceVertexUvs;
 
-			for ( var f = 0, fl = faces.length; f < fl; f ++ ) {
+			for ( let f = 0, fl = faces.length; f < fl; f ++ ) {
 
-				var face = faces[ f ];
-				var faceMaterial = isMultiMaterial ? material[ face.materialIndex ] : material;
+				const face = faces[ f ];
+				const faceMaterial = isMultiMaterial ? material[ face.materialIndex ] : material;
 
 				if ( faceMaterial === undefined ) continue;
 
-				fvA = vertices[ face.a ];
-				fvB = vertices[ face.b ];
-				fvC = vertices[ face.c ];
+				const fvA = vertices[ face.a ];
+				const fvB = vertices[ face.b ];
+				const fvC = vertices[ face.c ];
 
 				intersection = checkIntersection( this, faceMaterial, raycaster, _ray, fvA, fvB, fvC, _intersectionPoint );
 
@@ -319,7 +313,7 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 					if ( uvs && uvs[ f ] ) {
 
-						var uvs_f = uvs[ f ];
+						const uvs_f = uvs[ f ];
 						_uvA.copy( uvs_f[ 0 ] );
 						_uvB.copy( uvs_f[ 1 ] );
 						_uvC.copy( uvs_f[ 2 ] );
@@ -350,7 +344,7 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 function checkIntersection( object, material, raycaster, ray, pA, pB, pC, point ) {
 
-	var intersect;
+	let intersect;
 
 	if ( material.side === BackSide ) {
 
@@ -367,7 +361,7 @@ function checkIntersection( object, material, raycaster, ray, pA, pB, pC, point
 	_intersectionPointWorld.copy( point );
 	_intersectionPointWorld.applyMatrix4( object.matrixWorld );
 
-	var distance = raycaster.ray.origin.distanceTo( _intersectionPointWorld );
+	const distance = raycaster.ray.origin.distanceTo( _intersectionPointWorld );
 
 	if ( distance < raycaster.near || distance > raycaster.far ) return null;
 
@@ -385,7 +379,7 @@ function checkBufferGeometryIntersection( object, material, raycaster, ray, posi
 	_vB.fromBufferAttribute( position, b );
 	_vC.fromBufferAttribute( position, c );
 
-	var morphInfluences = object.morphTargetInfluences;
+	const morphInfluences = object.morphTargetInfluences;
 
 	if ( material.morphTargets && morphPosition && morphInfluences ) {
 
@@ -393,10 +387,10 @@ function checkBufferGeometryIntersection( object, material, raycaster, ray, posi
 		_morphB.set( 0, 0, 0 );
 		_morphC.set( 0, 0, 0 );
 
-		for ( var i = 0, il = morphPosition.length; i < il; i ++ ) {
+		for ( let i = 0, il = morphPosition.length; i < il; i ++ ) {
 
-			var influence = morphInfluences[ i ];
-			var morphAttribute = morphPosition[ i ];
+			const influence = morphInfluences[ i ];
+			const morphAttribute = morphPosition[ i ];
 
 			if ( influence === 0 ) continue;
 
@@ -434,7 +428,7 @@ function checkBufferGeometryIntersection( object, material, raycaster, ray, posi
 
 	}
 
-	var intersection = checkIntersection( object, material, raycaster, ray, _vA, _vB, _vC, _intersectionPoint );
+	const intersection = checkIntersection( object, material, raycaster, ray, _vA, _vB, _vC, _intersectionPoint );
 
 	if ( intersection ) {
 
@@ -458,7 +452,7 @@ function checkBufferGeometryIntersection( object, material, raycaster, ray, posi
 
 		}
 
-		var face = new Face3( a, b, c );
+		const face = new Face3( a, b, c );
 		Triangle.getNormal( _vA, _vB, _vC, face.normal );
 
 		intersection.face = face;

+ 28 - 29
src/objects/Points.js

@@ -10,10 +10,10 @@ import { BufferGeometry } from '../core/BufferGeometry.js';
  * @author alteredq / http://alteredqualia.com/
  */
 
-var _inverseMatrix = new Matrix4();
-var _ray = new Ray();
-var _sphere = new Sphere();
-var _position = new Vector3();
+const _inverseMatrix = new Matrix4();
+const _ray = new Ray();
+const _sphere = new Sphere();
+const _position = new Vector3();
 
 function Points( geometry, material ) {
 
@@ -36,9 +36,9 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 	raycast: function ( raycaster, intersects ) {
 
-		var geometry = this.geometry;
-		var matrixWorld = this.matrixWorld;
-		var threshold = raycaster.params.Points.threshold;
+		const geometry = this.geometry;
+		const matrixWorld = this.matrixWorld;
+		const threshold = raycaster.params.Points.threshold;
 
 		// Checking boundingSphere distance to ray
 
@@ -55,22 +55,22 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), {
 		_inverseMatrix.getInverse( matrixWorld );
 		_ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix );
 
-		var localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );
-		var localThresholdSq = localThreshold * localThreshold;
+		const localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );
+		const localThresholdSq = localThreshold * localThreshold;
 
 		if ( geometry.isBufferGeometry ) {
 
-			var index = geometry.index;
-			var attributes = geometry.attributes;
-			var positions = attributes.position.array;
+			const index = geometry.index;
+			const attributes = geometry.attributes;
+			const positions = attributes.position.array;
 
 			if ( index !== null ) {
 
-				var indices = index.array;
+				const indices = index.array;
 
-				for ( var i = 0, il = indices.length; i < il; i ++ ) {
+				for ( let i = 0, il = indices.length; i < il; i ++ ) {
 
-					var a = indices[ i ];
+					const a = indices[ i ];
 
 					_position.fromArray( positions, a * 3 );
 
@@ -80,7 +80,7 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 			} else {
 
-				for ( var i = 0, l = positions.length / 3; i < l; i ++ ) {
+				for ( let i = 0, l = positions.length / 3; i < l; i ++ ) {
 
 					_position.fromArray( positions, i * 3 );
 
@@ -92,9 +92,9 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 		} else {
 
-			var vertices = geometry.vertices;
+			const vertices = geometry.vertices;
 
-			for ( var i = 0, l = vertices.length; i < l; i ++ ) {
+			for ( let i = 0, l = vertices.length; i < l; i ++ ) {
 
 				testPoint( vertices[ i ], i, localThresholdSq, matrixWorld, raycaster, intersects, this );
 
@@ -106,26 +106,25 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 	updateMorphTargets: function () {
 
-		var geometry = this.geometry;
-		var m, ml, name;
+		const geometry = this.geometry;
 
 		if ( geometry.isBufferGeometry ) {
 
-			var morphAttributes = geometry.morphAttributes;
-			var keys = Object.keys( morphAttributes );
+			const morphAttributes = geometry.morphAttributes;
+			const keys = Object.keys( morphAttributes );
 
 			if ( keys.length > 0 ) {
 
-				var morphAttribute = morphAttributes[ keys[ 0 ] ];
+				const morphAttribute = morphAttributes[ keys[ 0 ] ];
 
 				if ( morphAttribute !== undefined ) {
 
 					this.morphTargetInfluences = [];
 					this.morphTargetDictionary = {};
 
-					for ( m = 0, ml = morphAttribute.length; m < ml; m ++ ) {
+					for ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) {
 
-						name = morphAttribute[ m ].name || String( m );
+						const name = morphAttribute[ m ].name || String( m );
 
 						this.morphTargetInfluences.push( 0 );
 						this.morphTargetDictionary[ name ] = m;
@@ -138,7 +137,7 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 		} else {
 
-			var morphTargets = geometry.morphTargets;
+			const morphTargets = geometry.morphTargets;
 
 			if ( morphTargets !== undefined && morphTargets.length > 0 ) {
 
@@ -160,16 +159,16 @@ Points.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 function testPoint( point, index, localThresholdSq, matrixWorld, raycaster, intersects, object ) {
 
-	var rayPointDistanceSq = _ray.distanceSqToPoint( point );
+	const rayPointDistanceSq = _ray.distanceSqToPoint( point );
 
 	if ( rayPointDistanceSq < localThresholdSq ) {
 
-		var intersectPoint = new Vector3();
+		const intersectPoint = new Vector3();
 
 		_ray.closestPointToPoint( point, intersectPoint );
 		intersectPoint.applyMatrix4( matrixWorld );
 
-		var distance = raycaster.ray.origin.distanceTo( intersectPoint );
+		const distance = raycaster.ray.origin.distanceTo( intersectPoint );
 
 		if ( distance < raycaster.near || distance > raycaster.far ) return;
 

+ 17 - 19
src/objects/Skeleton.js

@@ -7,8 +7,8 @@ import { Matrix4 } from '../math/Matrix4.js';
  * @author ikerr / http://verold.com
  */
 
-var _offsetMatrix = new Matrix4();
-var _identityMatrix = new Matrix4();
+const _offsetMatrix = new Matrix4();
+const _identityMatrix = new Matrix4();
 
 function Skeleton( bones, boneInverses ) {
 
@@ -39,7 +39,7 @@ function Skeleton( bones, boneInverses ) {
 
 			this.boneInverses = [];
 
-			for ( var i = 0, il = this.bones.length; i < il; i ++ ) {
+			for ( let i = 0, il = this.bones.length; i < il; i ++ ) {
 
 				this.boneInverses.push( new Matrix4() );
 
@@ -57,9 +57,9 @@ Object.assign( Skeleton.prototype, {
 
 		this.boneInverses = [];
 
-		for ( var i = 0, il = this.bones.length; i < il; i ++ ) {
+		for ( let i = 0, il = this.bones.length; i < il; i ++ ) {
 
-			var inverse = new Matrix4();
+			const inverse = new Matrix4();
 
 			if ( this.bones[ i ] ) {
 
@@ -75,13 +75,11 @@ Object.assign( Skeleton.prototype, {
 
 	pose: function () {
 
-		var bone, i, il;
-
 		// recover the bind-time world matrices
 
-		for ( i = 0, il = this.bones.length; i < il; i ++ ) {
+		for ( let i = 0, il = this.bones.length; i < il; i ++ ) {
 
-			bone = this.bones[ i ];
+			const bone = this.bones[ i ];
 
 			if ( bone ) {
 
@@ -93,9 +91,9 @@ Object.assign( Skeleton.prototype, {
 
 		// compute the local matrices, positions, rotations and scales
 
-		for ( i = 0, il = this.bones.length; i < il; i ++ ) {
+		for ( let i = 0, il = this.bones.length; i < il; i ++ ) {
 
-			bone = this.bones[ i ];
+			const bone = this.bones[ i ];
 
 			if ( bone ) {
 
@@ -120,18 +118,18 @@ Object.assign( Skeleton.prototype, {
 
 	update: function () {
 
-		var bones = this.bones;
-		var boneInverses = this.boneInverses;
-		var boneMatrices = this.boneMatrices;
-		var boneTexture = this.boneTexture;
+		const bones = this.bones;
+		const boneInverses = this.boneInverses;
+		const boneMatrices = this.boneMatrices;
+		const boneTexture = this.boneTexture;
 
 		// flatten bone matrices to array
 
-		for ( var i = 0, il = bones.length; i < il; i ++ ) {
+		for ( let i = 0, il = bones.length; i < il; i ++ ) {
 
 			// compute the offset between the current and the original transform
 
-			var matrix = bones[ i ] ? bones[ i ].matrixWorld : _identityMatrix;
+			const matrix = bones[ i ] ? bones[ i ].matrixWorld : _identityMatrix;
 
 			_offsetMatrix.multiplyMatrices( matrix, boneInverses[ i ] );
 			_offsetMatrix.toArray( boneMatrices, i * 16 );
@@ -154,9 +152,9 @@ Object.assign( Skeleton.prototype, {
 
 	getBoneByName: function ( name ) {
 
-		for ( var i = 0, il = this.bones.length; i < il; i ++ ) {
+		for ( let i = 0, il = this.bones.length; i < il; i ++ ) {
 
-			var bone = this.bones[ i ];
+			const bone = this.bones[ i ];
 
 			if ( bone.name === name ) {
 

+ 14 - 14
src/objects/SkinnedMesh.js

@@ -60,18 +60,18 @@ SkinnedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), {
 
 	normalizeSkinWeights: function () {
 
-		var vector = new Vector4();
+		const vector = new Vector4();
 
-		var skinWeight = this.geometry.attributes.skinWeight;
+		const skinWeight = this.geometry.attributes.skinWeight;
 
-		for ( var i = 0, l = skinWeight.count; i < l; i ++ ) {
+		for ( let i = 0, l = skinWeight.count; i < l; i ++ ) {
 
 			vector.x = skinWeight.getX( i );
 			vector.y = skinWeight.getY( i );
 			vector.z = skinWeight.getZ( i );
 			vector.w = skinWeight.getW( i );
 
-			var scale = 1.0 / vector.manhattanLength();
+			const scale = 1.0 / vector.manhattanLength();
 
 			if ( scale !== Infinity ) {
 
@@ -117,18 +117,18 @@ SkinnedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), {
 
 	boneTransform: ( function () {
 
-		var basePosition = new Vector3();
+		const basePosition = new Vector3();
 
-		var skinIndex = new Vector4();
-		var skinWeight = new Vector4();
+		const skinIndex = new Vector4();
+		const skinWeight = new Vector4();
 
-		var vector = new Vector3();
-		var matrix = new Matrix4();
+		const vector = new Vector3();
+		const matrix = new Matrix4();
 
 		return function ( index, target ) {
 
-			var skeleton = this.skeleton;
-			var geometry = this.geometry;
+			const skeleton = this.skeleton;
+			const geometry = this.geometry;
 
 			skinIndex.fromBufferAttribute( geometry.attributes.skinIndex, index );
 			skinWeight.fromBufferAttribute( geometry.attributes.skinWeight, index );
@@ -137,13 +137,13 @@ SkinnedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), {
 
 			target.set( 0, 0, 0 );
 
-			for ( var i = 0; i < 4; i ++ ) {
+			for ( let i = 0; i < 4; i ++ ) {
 
-				var weight = skinWeight.getComponent( i );
+				const weight = skinWeight.getComponent( i );
 
 				if ( weight !== 0 ) {
 
-					var boneIndex = skinIndex.getComponent( i );
+					const boneIndex = skinIndex.getComponent( i );
 
 					matrix.multiplyMatrices( skeleton.bones[ boneIndex ].matrixWorld, skeleton.boneInverses[ boneIndex ] );
 

+ 21 - 20
src/objects/Sprite.js

@@ -13,23 +13,23 @@ import { InterleavedBuffer } from '../core/InterleavedBuffer.js';
 import { InterleavedBufferAttribute } from '../core/InterleavedBufferAttribute.js';
 import { SpriteMaterial } from '../materials/SpriteMaterial.js';
 
-var _geometry;
+let _geometry;
 
-var _intersectPoint = new Vector3();
-var _worldScale = new Vector3();
-var _mvPosition = new Vector3();
+const _intersectPoint = new Vector3();
+const _worldScale = new Vector3();
+const _mvPosition = new Vector3();
 
-var _alignedPosition = new Vector2();
-var _rotatedPosition = new Vector2();
-var _viewWorldMatrix = new Matrix4();
+const _alignedPosition = new Vector2();
+const _rotatedPosition = new Vector2();
+const _viewWorldMatrix = new Matrix4();
 
-var _vA = new Vector3();
-var _vB = new Vector3();
-var _vC = new Vector3();
+const _vA = new Vector3();
+const _vB = new Vector3();
+const _vC = 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();
 
 function Sprite( material ) {
 
@@ -41,14 +41,14 @@ function Sprite( material ) {
 
 		_geometry = new BufferGeometry();
 
-		var float32Array = new Float32Array( [
+		const float32Array = new Float32Array( [
 			- 0.5, - 0.5, 0, 0, 0,
 			0.5, - 0.5, 0, 1, 0,
 			0.5, 0.5, 0, 1, 1,
 			- 0.5, 0.5, 0, 0, 1
 		] );
 
-		var interleavedBuffer = new InterleavedBuffer( float32Array, 5 );
+		const interleavedBuffer = new InterleavedBuffer( float32Array, 5 );
 
 		_geometry.setIndex( [ 0, 1, 2,	0, 2, 3 ] );
 		_geometry.setAttribute( 'position', new InterleavedBufferAttribute( interleavedBuffer, 3, 0, false ) );
@@ -90,8 +90,9 @@ Sprite.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 		}
 
-		var rotation = this.material.rotation;
-		var sin, cos;
+		const rotation = this.material.rotation;
+		let sin, cos;
+
 		if ( rotation !== 0 ) {
 
 			cos = Math.cos( rotation );
@@ -99,7 +100,7 @@ Sprite.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 		}
 
-		var center = this.center;
+		const center = this.center;
 
 		transformVertex( _vA.set( - 0.5, - 0.5, 0 ), _mvPosition, center, _worldScale, sin, cos );
 		transformVertex( _vB.set( 0.5, - 0.5, 0 ), _mvPosition, center, _worldScale, sin, cos );
@@ -110,7 +111,7 @@ Sprite.prototype = Object.assign( Object.create( Object3D.prototype ), {
 		_uvC.set( 1, 1 );
 
 		// check first triangle
-		var intersect = raycaster.ray.intersectTriangle( _vA, _vB, _vC, false, _intersectPoint );
+		let intersect = raycaster.ray.intersectTriangle( _vA, _vB, _vC, false, _intersectPoint );
 
 		if ( intersect === null ) {
 
@@ -127,7 +128,7 @@ Sprite.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 		}
 
-		var distance = raycaster.ray.origin.distanceTo( _intersectPoint );
+		const distance = raycaster.ray.origin.distanceTo( _intersectPoint );
 
 		if ( distance < raycaster.near || distance > raycaster.far ) return;
 

+ 1 - 1
src/scenes/Scene.js

@@ -51,7 +51,7 @@ Scene.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 	toJSON: function ( meta ) {
 
-		var data = Object3D.prototype.toJSON.call( this, meta );
+		const data = Object3D.prototype.toJSON.call( this, meta );
 
 		if ( this.background !== null ) data.object.background = this.background.toJSON( meta );
 		if ( this.environment !== null ) data.object.environment = this.environment.toJSON( meta );