|
1 | 1 | import { SphericalHarmonics3 } from '../math/SphericalHarmonics3.js'; |
2 | 2 | import { Light } from './Light.js'; |
3 | 3 |
|
4 | | -function LightProbe( sh, intensity ) { |
| 4 | +class LightProbe extends Light { |
5 | 5 |
|
6 | | - Light.call( this, undefined, intensity ); |
| 6 | + constructor( sh = new SphericalHarmonics3(), intensity = 1 ) { |
7 | 7 |
|
8 | | - this.type = 'LightProbe'; |
| 8 | + super( undefined, intensity ); |
9 | 9 |
|
10 | | - this.sh = ( sh !== undefined ) ? sh : new SphericalHarmonics3(); |
| 10 | + Object.defineProperty( this, 'isLightProbe', { value: true } ); |
11 | 11 |
|
12 | | -} |
13 | | - |
14 | | -LightProbe.prototype = Object.assign( Object.create( Light.prototype ), { |
| 12 | + this.sh = sh; |
15 | 13 |
|
16 | | - constructor: LightProbe, |
17 | | - |
18 | | - isLightProbe: true, |
| 14 | + } |
19 | 15 |
|
20 | | - copy: function ( source ) { |
| 16 | + copy( source ) { |
21 | 17 |
|
22 | | - Light.prototype.copy.call( this, source ); |
| 18 | + super.copy( source ); |
23 | 19 |
|
24 | 20 | this.sh.copy( source.sh ); |
25 | 21 |
|
26 | 22 | return this; |
27 | 23 |
|
28 | | - }, |
| 24 | + } |
29 | 25 |
|
30 | | - fromJSON: function ( json ) { |
| 26 | + fromJSON( json ) { |
31 | 27 |
|
32 | 28 | this.intensity = json.intensity; // TODO: Move this bit to Light.fromJSON(); |
33 | 29 | this.sh.fromArray( json.sh ); |
34 | 30 |
|
35 | 31 | return this; |
36 | 32 |
|
37 | | - }, |
| 33 | + } |
38 | 34 |
|
39 | | - toJSON: function ( meta ) { |
| 35 | + toJSON( meta ) { |
40 | 36 |
|
41 | | - const data = Light.prototype.toJSON.call( this, meta ); |
| 37 | + const data = super.toJSON( meta ); |
42 | 38 |
|
43 | 39 | data.object.sh = this.sh.toArray(); |
44 | 40 |
|
45 | 41 | return data; |
46 | 42 |
|
47 | 43 | } |
48 | 44 |
|
49 | | -} ); |
| 45 | +} |
50 | 46 |
|
51 | 47 | export { LightProbe }; |
0 commit comments