Skip to content

Commit 6e08be5

Browse files
committed
RectAreaLight: Convert to ES6 class
1 parent c7d3c71 commit 6e08be5

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

src/lights/RectAreaLight.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,34 @@
11
import { Light } from './Light.js';
22

3-
function RectAreaLight( color, intensity, width, height ) {
3+
class RectAreaLight extends Light {
44

5-
Light.call( this, color, intensity );
5+
constructor( color, intensity, width = 10, height = 10 ) {
66

7-
this.type = 'RectAreaLight';
7+
super( color, intensity );
88

9-
this.width = ( width !== undefined ) ? width : 10;
10-
this.height = ( height !== undefined ) ? height : 10;
9+
Object.defineProperty( this, 'isRectAreaLight', { value: true } );
1110

12-
}
13-
14-
RectAreaLight.prototype = Object.assign( Object.create( Light.prototype ), {
11+
this.type = 'RectAreaLight';
1512

16-
constructor: RectAreaLight,
13+
this.width = width;
14+
this.height = height;
1715

18-
isRectAreaLight: true,
16+
}
1917

20-
copy: function ( source ) {
18+
copy( source ) {
2119

22-
Light.prototype.copy.call( this, source );
20+
super.copy( source );
2321

2422
this.width = source.width;
2523
this.height = source.height;
2624

2725
return this;
2826

29-
},
27+
}
3028

31-
toJSON: function ( meta ) {
29+
toJSON( meta ) {
3230

33-
const data = Light.prototype.toJSON.call( this, meta );
31+
const data = super.toJSON( meta );
3432

3533
data.object.width = this.width;
3634
data.object.height = this.height;
@@ -39,6 +37,6 @@ RectAreaLight.prototype = Object.assign( Object.create( Light.prototype ), {
3937

4038
}
4139

42-
} );
40+
}
4341

4442
export { RectAreaLight };

0 commit comments

Comments
 (0)