113 lines
2.7 KiB
JavaScript
113 lines
2.7 KiB
JavaScript
/**
|
|
* @author mrdoob / http://mrdoob.com/
|
|
* @author alteredq / http://alteredqualia.com/
|
|
*/
|
|
|
|
THREE.DirectionalLight = function ( color, intensity ) {
|
|
|
|
THREE.Light.call( this, color );
|
|
|
|
this.type = 'DirectionalLight';
|
|
|
|
this.position.set( 0, 1, 0 );
|
|
this.target = new THREE.Object3D();
|
|
|
|
this.intensity = ( intensity !== undefined ) ? intensity : 1;
|
|
|
|
this.castShadow = false;
|
|
this.onlyShadow = false;
|
|
|
|
//
|
|
|
|
this.shadowCameraNear = 50;
|
|
this.shadowCameraFar = 5000;
|
|
|
|
this.shadowCameraLeft = - 500;
|
|
this.shadowCameraRight = 500;
|
|
this.shadowCameraTop = 500;
|
|
this.shadowCameraBottom = - 500;
|
|
|
|
this.shadowCameraVisible = false;
|
|
|
|
this.shadowBias = 0;
|
|
this.shadowDarkness = 0.5;
|
|
|
|
this.shadowMapWidth = 512;
|
|
this.shadowMapHeight = 512;
|
|
|
|
//
|
|
|
|
this.shadowCascade = false;
|
|
|
|
this.shadowCascadeOffset = new THREE.Vector3( 0, 0, - 1000 );
|
|
this.shadowCascadeCount = 2;
|
|
|
|
this.shadowCascadeBias = [ 0, 0, 0 ];
|
|
this.shadowCascadeWidth = [ 512, 512, 512 ];
|
|
this.shadowCascadeHeight = [ 512, 512, 512 ];
|
|
|
|
this.shadowCascadeNearZ = [ - 1.000, 0.990, 0.998 ];
|
|
this.shadowCascadeFarZ = [ 0.990, 0.998, 1.000 ];
|
|
|
|
this.shadowCascadeArray = [];
|
|
|
|
//
|
|
|
|
this.shadowMap = null;
|
|
this.shadowMapSize = null;
|
|
this.shadowCamera = null;
|
|
this.shadowMatrix = null;
|
|
|
|
};
|
|
|
|
THREE.DirectionalLight.prototype = Object.create( THREE.Light.prototype );
|
|
THREE.DirectionalLight.prototype.constructor = THREE.DirectionalLight;
|
|
|
|
THREE.DirectionalLight.prototype.clone = function () {
|
|
|
|
var light = new THREE.DirectionalLight();
|
|
|
|
THREE.Light.prototype.clone.call( this, light );
|
|
|
|
light.target = this.target.clone();
|
|
|
|
light.intensity = this.intensity;
|
|
|
|
light.castShadow = this.castShadow;
|
|
light.onlyShadow = this.onlyShadow;
|
|
|
|
//
|
|
|
|
light.shadowCameraNear = this.shadowCameraNear;
|
|
light.shadowCameraFar = this.shadowCameraFar;
|
|
|
|
light.shadowCameraLeft = this.shadowCameraLeft;
|
|
light.shadowCameraRight = this.shadowCameraRight;
|
|
light.shadowCameraTop = this.shadowCameraTop;
|
|
light.shadowCameraBottom = this.shadowCameraBottom;
|
|
|
|
light.shadowCameraVisible = this.shadowCameraVisible;
|
|
|
|
light.shadowBias = this.shadowBias;
|
|
light.shadowDarkness = this.shadowDarkness;
|
|
|
|
light.shadowMapWidth = this.shadowMapWidth;
|
|
light.shadowMapHeight = this.shadowMapHeight;
|
|
|
|
//
|
|
|
|
light.shadowCascade = this.shadowCascade;
|
|
|
|
light.shadowCascadeOffset.copy( this.shadowCascadeOffset );
|
|
light.shadowCascadeCount = this.shadowCascadeCount;
|
|
|
|
light.shadowCascadeBias = this.shadowCascadeBias.slice( 0 );
|
|
light.shadowCascadeWidth = this.shadowCascadeWidth.slice( 0 );
|
|
light.shadowCascadeHeight = this.shadowCascadeHeight.slice( 0 );
|
|
|
|
light.shadowCascadeNearZ = this.shadowCascadeNearZ.slice( 0 );
|
|
light.shadowCascadeFarZ = this.shadowCascadeFarZ.slice( 0 );
|
|
|
|
return light;
|
|
|
|
};
|