three.js影子截止 [英] three.js shadow cutoff

查看:175
本文介绍了three.js影子截止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所说。
当我渲染当前场景时,一切正常。
只有白猴子的阴影被切断了。
怎么会发生这种情况,是否有解决方案呢?

As the title says. When i render the current scene everything works fine. Only the shadow of the white monkey gets cut off. How can this happen, and is there a resolution for it?

这是网站: http://hammer.bz/test/
和一个屏幕;)

http://i.stack.imgur.com/6jd0h.png

我想这与相机或灯光有关..
所以这里是:

I guess it has to do with the camera or with the lights.. so here are they:

renderer.shadowMapEnabled   = true;
renderer.sortObjects = false;
renderer.shadowMapWidth = 3072;
renderer.shadowMapHeight = 3072
renderer.shadowCameraNear = 2;
renderer.shadowCameraFar = 40000;
renderer.shadowCameraFov = 50;
renderer.shadowMapBias = -0.00022;
renderer.shadowMapDarkness = 0.55;
renderer.shadowMapSoft      = true;
renderer.physicallyBasedShading = true;
renderer.setClearColorHex( 0x999999, 1 );


camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.1, 40000 );
camera.position.x = x;
camera.position.y = y;
camera.position.z = z;  
camera.rotation.x = -0.8;
scene.add( camera );


var light = new THREE.DirectionalLight( 0xffffff, 1 );
light.position.set( -2, 5, 2 ).normalize();
light.shadowCameraNear  = 0.01;
light.shadowCameraFar   = 1000000;
light.castShadow        = true;
light.shadowDarkness        = 0.5;
light.shadowCameraVisible   = false;
scene.add( light );

提前致谢!

Bram

Thanks in advance!
Bram

编辑:得到它:

只需使用 THREE.SpotLight
这是一个愚蠢的问题。

just use THREE.SpotLight instead. It was a dumb question.

只需加上 shadowCameraVisible = true; 即可看到光线和它会工作。
现在为这个问题感到有点傻哈哈;)

Just put on shadowCameraVisible = true; to see the light and it will work. Feeling a bit dumb now for this question haha ;)

推荐答案

只需使用三。 SpotLight 而不是。

只需加上 shadowCameraVisible = true; 即可看到灯光和它会工作。
当然,您需要设置头寸 position.set(x,y,z);

Just put on shadowCameraVisible = true; to see the light and it will work. Offcourse you are required to set the position position.set(x, y, z);

这篇关于three.js影子截止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆