Browse Source

Light: Move to let/const.

Mugen87 5 years ago
parent
commit
51d397c7b9

+ 2 - 2
src/lights/AmbientLightProbe.js

@@ -9,7 +9,7 @@ function AmbientLightProbe( color, intensity ) {
 
 
 	LightProbe.call( this, undefined, 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 );
 	// 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 ) );
 	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 ) {
 	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
 		// data.sh = this.sh.toArray(); // todo
 
 

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

@@ -6,7 +6,7 @@ import { Light } from './Light';
 /**
 /**
  * @example
  * @example
  * // White directional light at half intensity shining from the top.
  * // 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 );
  * directionalLight.position.set( 0, 1, 0 );
  * scene.add( directionalLight );
  * scene.add( directionalLight );
  *
  *

+ 7 - 7
src/lights/HemisphereLightProbe.js

@@ -10,15 +10,15 @@ function HemisphereLightProbe( skyColor, groundColor, intensity ) {
 
 
 	LightProbe.call( this, undefined, 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 );
 	// 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[ 0 ].copy( sky ).add( ground ).multiplyScalar( c0 );
 	this.sh.coefficients[ 1 ].copy( sky ).sub( ground ).multiplyScalar( c1 );
 	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 ) {
 	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
 		// 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 ) {
 	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.color = this.color.getHex();
 		data.object.intensity = this.intensity;
 		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 ) {
 	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();
 		data.object.sh = this.sh.toArray();
 
 

+ 2 - 2
src/lights/LightShadow.js

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

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

@@ -4,7 +4,7 @@ import { PointLightShadow } from './PointLightShadow';
 
 
 /**
 /**
  * @example
  * @example
- * var light = new THREE.PointLight( 0xff0000, 1, 100 );
+ * const light = new THREE.PointLight( 0xff0000, 1, 100 );
  * light.position.set( 50, 50, 50 );
  * light.position.set( 50, 50, 50 );
  * scene.add( light );
  * 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;
 		if ( viewportIndex === undefined ) viewportIndex = 0;
 
 
-		var camera = this.camera,
+		const camera = this.camera,
 			shadowMatrix = this.matrix,
 			shadowMatrix = this.matrix,
 			lightPositionWorld = this._lightPositionWorld,
 			lightPositionWorld = this._lightPositionWorld,
 			lookTarget = this._lookTarget,
 			lookTarget = this._lookTarget,

+ 1 - 1
src/lights/RectAreaLight.js

@@ -34,7 +34,7 @@ RectAreaLight.prototype = Object.assign( Object.create( Light.prototype ), {
 
 
 	toJSON: function ( meta ) {
 	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.width = this.width;
 		data.object.height = this.height;
 		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 ) {
 	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 ) {
 		if ( fov !== camera.fov || aspect !== camera.aspect || far !== camera.far ) {