Skip to content

Commit e2ddbc9

Browse files
committed
LightProbe: Convert to ES6 class.
1 parent fade4fa commit e2ddbc9

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

src/lights/LightProbe.js

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,47 @@
11
import { SphericalHarmonics3 } from '../math/SphericalHarmonics3.js';
22
import { Light } from './Light.js';
33

4-
function LightProbe( sh, intensity ) {
4+
class LightProbe extends Light {
55

6-
Light.call( this, undefined, intensity );
6+
constructor( sh = new SphericalHarmonics3(), intensity = 1 ) {
77

8-
this.type = 'LightProbe';
8+
super( undefined, intensity );
99

10-
this.sh = ( sh !== undefined ) ? sh : new SphericalHarmonics3();
10+
Object.defineProperty( this, 'isLightProbe', { value: true } );
1111

12-
}
13-
14-
LightProbe.prototype = Object.assign( Object.create( Light.prototype ), {
12+
this.sh = sh;
1513

16-
constructor: LightProbe,
17-
18-
isLightProbe: true,
14+
}
1915

20-
copy: function ( source ) {
16+
copy( source ) {
2117

22-
Light.prototype.copy.call( this, source );
18+
super.copy( source );
2319

2420
this.sh.copy( source.sh );
2521

2622
return this;
2723

28-
},
24+
}
2925

30-
fromJSON: function ( json ) {
26+
fromJSON( json ) {
3127

3228
this.intensity = json.intensity; // TODO: Move this bit to Light.fromJSON();
3329
this.sh.fromArray( json.sh );
3430

3531
return this;
3632

37-
},
33+
}
3834

39-
toJSON: function ( meta ) {
35+
toJSON( meta ) {
4036

41-
const data = Light.prototype.toJSON.call( this, meta );
37+
const data = super.toJSON( meta );
4238

4339
data.object.sh = this.sh.toArray();
4440

4541
return data;
4642

4743
}
4844

49-
} );
45+
}
5046

5147
export { LightProbe };

0 commit comments

Comments
 (0)