PointLight.js 1.0 KB
Newer Older
M
Mr.doob 已提交
1
/**
M
Mr.doob 已提交
2
 * @author mrdoob / http://mrdoob.com/
M
Mr.doob 已提交
3 4
 */

M
Mr.doob 已提交
5
THREE.PointLight = function ( color, intensity, distance, decay ) {
M
Mr.doob 已提交
6

7
	THREE.Light.call( this, color );
M
Mr.doob 已提交
8

9 10
	this.type = 'PointLight';

11 12
	this.intensity = ( intensity !== undefined ) ? intensity : 1;
	this.distance = ( distance !== undefined ) ? distance : 0;
M
Mr.doob 已提交
13
	this.decay = ( decay !== undefined ) ? decay : 1;	// for physically correct lights, should be 2.
M
Mr.doob 已提交
14 15 16

};

17
THREE.PointLight.prototype = Object.create( THREE.Light.prototype );
18
THREE.PointLight.prototype.constructor = THREE.PointLight;
19

20
THREE.PointLight.prototype.copy = function ( source ) {
21

22 23 24 25 26 27 28
	THREE.Light.prototype.copy.call( this, source );

	this.intensity = source.intensity;
	this.distance = source.distance;
	this.decay = source.decay;

	return this;
29 30

};
31 32 33

THREE.PointLight.prototype.toJSON = function ( meta ) {

34
	var data = THREE.Object3D.prototype.toJSON.call( this, meta );
35 36 37 38 39 40

	data.object.color = this.color.getHex();
	data.object.intensity = this.intensity;
	data.object.distance = this.distance;
	data.object.decay = this.decay;

41
	return data;
42

43
};