提交 b23a98f8 编写于 作者: M Mr.doob

Added DirectionalLightShadow and SpotLightShadow. Automatically adjust SpotLightShadow. See #7690.

上级 3c836943
......@@ -14,7 +14,7 @@ THREE.DirectionalLight = function ( color, intensity ) {
this.target = new THREE.Object3D();
this.shadow = new THREE.LightShadow( new THREE.OrthographicCamera( - 5, 5, 5, - 5, 0.5, 500 ) );
this.shadow = new THREE.DirectionalLightShadow();
};
......
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE.DirectionalLightShadow = function ( light ) {
THREE.LightShadow.call( this, new THREE.OrthographicCamera( - 5, 5, 5, - 5, 0.5, 500 ) );
};
......@@ -18,7 +18,7 @@ THREE.SpotLight = function ( color, intensity, distance, angle, penumbra, decay
this.penumbra = ( penumbra !== undefined ) ? penumbra : 0;
this.decay = ( decay !== undefined ) ? decay : 1; // for physically correct lights, should be 2.
this.shadow = new THREE.LightShadow( new THREE.PerspectiveCamera( 50, 1, 0.5, 500 ) );
this.shadow = new THREE.SpotLightShadow();
};
......
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE.SpotLightShadow = function () {
THREE.LightShadow.call( this, new THREE.PerspectiveCamera( 50, 1, 0.5, 500 ) );
};
THREE.SpotLightShadow.prototype = {
constructor: THREE.SpotLightShadow,
update: function ( light ) {
var fov = THREE.Math.radToDeg( 2 * light.angle );
var aspect = this.mapSize.width / this.mapSize.height;
var far = light.distance || 500;
var camera = this.camera;
if ( fov !== camera.fov || aspect !== camera.aspect || far !== camera.far ) {
camera.fov = fov;
camera.aspect = aspect;
camera.far = far;
camera.updateProjectionMatrix();
}
}
};
......@@ -171,15 +171,11 @@ THREE.WebGLShadowMap = function ( _renderer, _lights, _objects ) {
shadow.map = new THREE.WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars );
//
if ( light instanceof THREE.SpotLight ) {
shadowCamera.aspect = _shadowMapSize.x / _shadowMapSize.y;
}
}
if ( shadow instanceof THREE.SpotLightShadow ) {
shadowCamera.updateProjectionMatrix();
shadow.update( light );
}
......
......@@ -67,9 +67,11 @@
"src/lights/LightShadow.js",
"src/lights/AmbientLight.js",
"src/lights/DirectionalLight.js",
"src/lights/DirectionalLightShadow.js",
"src/lights/HemisphereLight.js",
"src/lights/PointLight.js",
"src/lights/SpotLight.js",
"src/lights/SpotLightShadow.js",
"src/loaders/AudioLoader.js",
"src/loaders/Cache.js",
"src/loaders/Loader.js",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册