0
我今天开始使用THREE.js并设法渲染一个带有太空船和一些框的场景。太空船应该在箱子上投下阴影,但阴影仅在我使用OrbitControls时显示。如果我用我自己的相机,一切都很好,但不是影子。我如何设置我的PerspectiveCamera以显示阴影?THREE.js阴影只能使用OrbitControls显示
我是一个初学者,不能让我的jsfiddle代码工作,但代码是here
var spotLight = new THREE.SpotLight(0xffffff);
spotLight.position.copy(ship.position);
spotLight.position.z += 5;
spotLight.shadowDarkness = 0.7;
spotLight.target = ship;
spotLight.castShadow = true;
spotLight.shadowMapWidth = 1024;
spotLight.shadowMapHeight = 1024;
spotLight.shadowCameraNear = 1;
spotLight.shadowCameraFar = 20;
spotLight.intensity = 0.2;
spotLight.shadowCameraFov = 30;
spotLight.shadowCameraNear = true;
scene.add(spotLight);
if (useOrbitControls) {
controls = new THREE.OrbitControls(camera);
controls.center.clone(ship.position);
controls.addEventListener('change', render);
}
根据您的世界的大小,shadowCameraFar参数值可能太低。 – gaitat