forked from mrdoob/three.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPointLight.js
More file actions
59 lines (37 loc) · 1.4 KB
/
PointLight.js
File metadata and controls
59 lines (37 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { Light } from './Light';
import { PerspectiveCamera } from '../cameras/PerspectiveCamera';
import { LightShadow } from './LightShadow';
/**
* @author mrdoob / http://mrdoob.com/
*/
function PointLight( color, intensity, distance, decay ) {
Light.call( this, color, intensity );
this.type = 'PointLight';
Object.defineProperty( this, 'power', {
get: function () {
// intensity = power per solid angle.
// ref: equation (15) from http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf
return this.intensity * 4 * Math.PI;
},
set: function ( power ) {
// intensity = power per solid angle.
// ref: equation (15) from http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf
this.intensity = power / ( 4 * Math.PI );
}
} );
this.distance = ( distance !== undefined ) ? distance : 0;
this.decay = ( decay !== undefined ) ? decay : 1; // for physically correct lights, should be 2.
this.shadow = new LightShadow( new PerspectiveCamera( 90, 1, 0.5, 500 ) );
}
PointLight.prototype = Object.assign( Object.create( Light.prototype ), {
constructor: PointLight,
isPointLight: true,
copy: function ( source ) {
Light.prototype.copy.call( this, source );
this.distance = source.distance;
this.decay = source.decay;
this.shadow = source.shadow.clone();
return this;
}
} );
export { PointLight };