我有这个代码:
var other_phongMaterial = new THREE.MeshPhongMaterial({ color: 0xf455f4 });
var other_sphere = new THREE.Mesh(new THREE.SphereGeometry(50, 50, 50), other_phongMaterial );
var other_cube = new THREE.Mesh(new THREE.CubeGeometry(200, 200, 200), other_phongMaterial );
var phongMaterial = new THREE.MeshPhongMaterial({ color: 0xcccccc });
var sphere = new THREE.Mesh(new THREE.SphereGeometry(50, 50, 50), phongMaterial );
var cube = new THREE.Mesh(new THREE.CubeGeometry(200, 200, 200), phongMaterial );
sphere.castShadow = true;
cube.receiveShadow = true;
other_sphere.castShadow = true;
other_cube.receiveShadow = true;
sphere.position.set(0,250,-130);
other_cube.position.set(0,50,-150);
other_sphere.position.set(0,250,130);
cube.position.set(0,50,150);
scene.add(cube);
scene.add(sphere);
scene.add(other_sphere);
scene.add(other_cube);
var spotLight = new THREE.SpotLight( 0xffffff );
spotLight.position.set( 100, 1000, 100 );
spotLight.castShadow = true;
spotLight.shadowMapWidth = 1024;
spotLight.shadowMapHeight = 1024;
spotLight.shadowCameraNear = 500;
spotLight.shadowCameraFar = 4000;
spotLight.shadowCameraFov = 30;
scene.add( spotLight );
而且,我不明白为什么阴影投射只适用于一个。我注意到以下几点:
- 如果我尝试交换立方体,阴影会投射到一个上,但仍然不会投射到另一个上。
- 如果我使用与 other_cube 相同的材料,它会起作用,这意味着就像现在这样写的那样对我有用,相反,如果我使用两种不同的材料,它只会投射在 other_cube 上。
但是这些形状的设置是完全相等的!所以..我不知道,真的..提前谢谢!
编辑:可能还有其他我不记得提出的异常情况,所以请在每种情况下告诉我。