三个没有阴影铸造

时间:2015-02-05 23:38:55

标签: javascript three.js

所以问题很简单。场景中没有阴影。 起初我以为它是由导入的JSON格式3D模型引起的,所以我在场景中间添加了一个基本的立方体,但仍无效。

centerLight = new THREE.SpotLight('#fff',3);
centerLight.castShadow = true;
centerLight.shadowMapWidth = 1024;
centerLight.shadowMapHeight = 1024;
centerLight.shadowCameraNear = 500;
centerLight.shadowCameraFar = 4000;
centerLight.shadowCameraFov = 30;
centerLight.position.set(0,20,0);
centerLight.add(new THREE.Mesh(new THREE.SphereGeometry(1, 16, 8), new THREE.MeshBasicMaterial({
    color: '#00fa00',
})));
scene.add(centerLight);

立方

var shadowMakerGeo = new THREE.BoxGeometry(1,1,1);
var shadowMakerMar = new THREE.MeshLambertMaterial({color:'#000'});
var shadowMaker = new THREE.Mesh(shadowMakerGeo,shadowMakerMar);
shadowMaker.position.set(0,9,0);
shadowMaker.castShadow = true;
scene.add(shadowMaker);

用于让阴影投射

的平面
var planeGeo = new THREE.PlaneBufferGeometry( 50, 50);
var planeMar = new THREE.MeshLambertMaterial({color:'#fff'});
plane = new THREE.Mesh(planeGeo,planeMar);
plane.receiveShadow = true;
plane.rotation.x = -Math.PI / 2;
scene.add(plane);

我已经这样做了:

renderer.shadowMapEnabled = true;

此处所有代码https://github.com/ZZYW/is_shame_necessary_website/blob/master/static/js/homepage/navigation.js

0 个答案:

没有答案