11import { Light } from './Light.js' ;
22import { PointLightShadow } from './PointLightShadow.js' ;
33
4- function PointLight ( color , intensity , distance , decay ) {
4+ class PointLight extends Light {
55
6- Light . call ( this , color , intensity ) ;
6+ constructor ( color , intensity , distance = 0 , decay = 1 ) {
77
8- this . type = 'PointLight' ;
8+ super ( color , intensity ) ;
99
10- Object . defineProperty ( this , 'power' , {
11- get : function ( ) {
10+ Object . defineProperty ( this , 'isPointLight' , { value : true } ) ;
1211
13- // intensity = power per solid angle.
14- // ref: equation (15) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
15- return this . intensity * 4 * Math . PI ;
12+ this . type = 'PointLight' ;
1613
17- } ,
18- set : function ( power ) {
14+ this . distance = distance ;
15+ this . decay = decay ; // for physically correct lights, should be 2.
1916
20- // intensity = power per solid angle.
21- // ref: equation (15) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
22- this . intensity = power / ( 4 * Math . PI ) ;
17+ this . shadow = new PointLightShadow ( ) ;
2318
24- }
25- } ) ;
19+ }
2620
27- this . distance = ( distance !== undefined ) ? distance : 0 ;
28- this . decay = ( decay !== undefined ) ? decay : 1 ; // for physically correct lights, should be 2.
21+ get power ( ) {
2922
30- this . shadow = new PointLightShadow ( ) ;
23+ // intensity = power per solid angle.
24+ // ref: equation (15) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
25+ return this . intensity * 4 * Math . PI ;
3126
32- }
27+ }
3328
34- PointLight . prototype = Object . assign ( Object . create ( Light . prototype ) , {
29+ set power ( power ) {
3530
36- constructor : PointLight ,
31+ // intensity = power per solid angle.
32+ // ref: equation (15) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
33+ this . intensity = power / ( 4 * Math . PI ) ;
3734
38- isPointLight : true ,
35+ }
3936
40- copy : function ( source ) {
37+ copy ( source ) {
4138
42- Light . prototype . copy . call ( this , source ) ;
39+ super . copy ( source ) ;
4340
4441 this . distance = source . distance ;
4542 this . decay = source . decay ;
@@ -50,7 +47,6 @@ PointLight.prototype = Object.assign( Object.create( Light.prototype ), {
5047
5148 }
5249
53- } ) ;
54-
50+ }
5551
5652export { PointLight } ;
0 commit comments