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