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

5

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

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

10 11
	this.type = 'PointLight';

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

16 17 18 19 20
	this.castShadow = false;
	this.onlyShadow = false;

	//

21 22
	this.shadowCameraNear = 1;
	this.shadowCameraFar = 500;
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
	this.shadowCameraFov = 90;

	this.shadowCameraVisible = false;

	this.shadowBias = 0;
	this.shadowDarkness = 0.5;

	this.shadowMapWidth = 512;
	this.shadowMapHeight = 512;

	//

	this.shadowMap = null;
	this.shadowMapSize = null;
	this.shadowCamera = null;
	this.shadowMatrix = null;

M
Mr.doob 已提交
40 41
};

42
THREE.PointLight.prototype = Object.create( THREE.Light.prototype );
43
THREE.PointLight.prototype.constructor = THREE.PointLight;
44

45
THREE.PointLight.prototype.copy = function ( source ) {
46

47 48 49 50 51 52
	THREE.Light.prototype.copy.call( this, source );

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

53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
	this.castShadow = source.castShadow;
	this.onlyShadow = source.onlyShadow;

	this.shadowCameraNear = source.shadowCameraNear;
	this.shadowCameraFar = source.shadowCameraFar;
	this.shadowCameraFov = source.shadowCameraFov;

	this.shadowCameraVisible = source.shadowCameraVisible;

	this.shadowBias = source.shadowBias;
	this.shadowDarkness = source.shadowDarkness;

	this.shadowMapWidth = source.shadowMapWidth;
	this.shadowMapHeight = source.shadowMapHeight;

68
	return this;
69 70

};
71 72 73

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

74
	var data = THREE.Object3D.prototype.toJSON.call( this, meta );
75 76 77 78 79 80

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

81
	return data;
82

83
};