Browse Source

RectAreaLight: Convert to ES6 class

Mr.doob 4 years ago
parent
commit
6e08be5f06
1 changed files with 14 additions and 16 deletions
  1. 14 16
      src/lights/RectAreaLight.js

+ 14 - 16
src/lights/RectAreaLight.js

@@ -1,36 +1,34 @@
 import { Light } from './Light.js';
 
-function RectAreaLight( color, intensity, width, height ) {
+class RectAreaLight extends Light {
 
-	Light.call( this, color, intensity );
+	constructor( color, intensity, width = 10, height = 10 ) {
 
-	this.type = 'RectAreaLight';
+		super( color, intensity );
 
-	this.width = ( width !== undefined ) ? width : 10;
-	this.height = ( height !== undefined ) ? height : 10;
+		Object.defineProperty( this, 'isRectAreaLight', { value: true } );
 
-}
-
-RectAreaLight.prototype = Object.assign( Object.create( Light.prototype ), {
+		this.type = 'RectAreaLight';
 
-	constructor: RectAreaLight,
+		this.width = width;
+		this.height = height;
 
-	isRectAreaLight: true,
+	}
 
-	copy: function ( source ) {
+	copy( source ) {
 
-		Light.prototype.copy.call( this, source );
+		super.copy( source );
 
 		this.width = source.width;
 		this.height = source.height;
 
 		return this;
 
-	},
+	}
 
-	toJSON: function ( meta ) {
+	toJSON( meta ) {
 
-		const data = Light.prototype.toJSON.call( this, meta );
+		const data = super.toJSON( meta );
 
 		data.object.width = this.width;
 		data.object.height = this.height;
@@ -39,6 +37,6 @@ RectAreaLight.prototype = Object.assign( Object.create( Light.prototype ), {
 
 	}
 
-} );
+}
 
 export { RectAreaLight };