content/hifi-content/dave/walk-tools/walkTools/libraries/three.js/lights/SpotLight.js
2022-02-13 22:49:05 +01:00

82 lines
1.9 KiB
JavaScript

/**
* @author alteredq / http://alteredqualia.com/
*/
THREE.SpotLight = function ( color, intensity, distance, angle, exponent, decay ) {
THREE.Light.call( this, color );
this.type = 'SpotLight';
this.position.set( 0, 1, 0 );
this.target = new THREE.Object3D();
this.intensity = ( intensity !== undefined ) ? intensity : 1;
this.distance = ( distance !== undefined ) ? distance : 0;
this.angle = ( angle !== undefined ) ? angle : Math.PI / 3;
this.exponent = ( exponent !== undefined ) ? exponent : 10;
this.decay = ( decay !== undefined ) ? decay : 1; // for physically correct lights, should be 2.
this.castShadow = false;
this.onlyShadow = false;
//
this.shadowCameraNear = 50;
this.shadowCameraFar = 5000;
this.shadowCameraFov = 50;
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;
};
THREE.SpotLight.prototype = Object.create( THREE.Light.prototype );
THREE.SpotLight.prototype.constructor = THREE.SpotLight;
THREE.SpotLight.prototype.clone = function () {
var light = new THREE.SpotLight();
THREE.Light.prototype.clone.call( this, light );
light.target = this.target.clone();
light.intensity = this.intensity;
light.distance = this.distance;
light.angle = this.angle;
light.exponent = this.exponent;
light.decay = this.decay;
light.castShadow = this.castShadow;
light.onlyShadow = this.onlyShadow;
//
light.shadowCameraNear = this.shadowCameraNear;
light.shadowCameraFar = this.shadowCameraFar;
light.shadowCameraFov = this.shadowCameraFov;
light.shadowCameraVisible = this.shadowCameraVisible;
light.shadowBias = this.shadowBias;
light.shadowDarkness = this.shadowDarkness;
light.shadowMapWidth = this.shadowMapWidth;
light.shadowMapHeight = this.shadowMapHeight;
return light;
};