0
我试图在this jsfiddle(代码如下)的立方体下创建一个阴影,但阴影变得太大了,我也不认为是正确的形状。什么导致这个阴影,我该如何解决它?Three.js阴影不如预期
感谢
var initScene, render,
projector, renderer, scene, ground, light,
camera, box, pointLight;
projector = new THREE.Projector;
scene = new THREE.Scene;
renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColorHex(0x000000, 1);
renderer.shadowMapEnabled = true;
renderer.shadowMapSoft = true;
document.body.appendChild(renderer.domElement);
light = new THREE.DirectionalLight(0xFFFFFF);
light.position.set(20, 80, 0);
light.target.position.copy(scene.position);
light.castShadow = true;
light.shadowCameraLeft = -60;
light.shadowCameraTop = -60;
light.shadowCameraRight = 60;
light.shadowCameraBottom = 60;
light.shadowCameraNear = 1;
light.shadowCameraFar = 2000;
light.shadowBias = 10;
light.shadowMapWidth = light.shadowMapHeight = 2040;
light.shadowDarkness = .7;
scene.add(light);
box = new THREE.Mesh(
new THREE.CubeGeometry(5, 5, 40),
new THREE.MeshLambertMaterial({
color: 0xffffff,
opacity: 0.7,
transparent: true,
depthWrite: false
}));
box.position.set(10, 10, 10);
box.castShadow = true;
scene.add(box);
ground = new THREE.Mesh(
new THREE.CubeGeometry(1000, 1, 1000),
new THREE.MeshLambertMaterial({
color: 0xffffff,
opacity: 0.3,
transparent: true
}));
ground.receiveShadow = true;
scene.add(ground);
camera = new THREE.PerspectiveCamera(
35, window.innerWidth/window.innerHeight, 1, 1000
);
camera.position.set(100, 100, 100);
camera.lookAt(scene.position);
scene.add(camera);
renderer.render(scene, camera);
scene.simulate();
谢谢,遗憾的是没有太多变化,实际上阴影变大了! – Jodes 2013-02-11 10:28:51
看看http://jsfiddle.net/bLgzx/。我将渲染器背景设为蓝色,并将地面设为红色。删除了所有光影参数。 – gaitat 2013-02-11 10:47:30
http://jsfiddle.net/aSt8c/ – gaitat 2013-02-11 11:11:53