[英]ThreeJS won't cast any shadows
我在ThreeJS上遇到了麻煩。 我有一些立方體,應該在下面的平面上投射陰影,但它們卻不能-我已經使用Google搜索了一個解決方案幾個小時,並嘗試了我能找到的一切,但我無法工作。
我用MeshPhongMaterial
上的所有對象,我已經加入.castShadow
和.receiveShadow
所有適當的對象。 我使用一個指向地面的SpotLight
它照亮了立方體和地面,但是立方體沒有投射陰影。 這是一個立方體和地面的示例:
var cubeGeometry = new THREE.CubeGeometry(20, 20, 20);
cube1 = new THREE.Mesh(cubeGeometry, material);
cube1.shading = THREE.FlatShading;
cube1.castShadow = true;
cube1.receiveShadow = true;
var groundGeometry = new THREE.PlaneGeometry(200, 200);
var groundMaterial = new THREE.MeshPhongMaterial({color: 0xf0dc3f});
ground = new THREE.Mesh(groundGeometry, groundMaterial);
ground.shading = THREE.FlatShading;
ground.position.y = -30;
ground.rotation.x = Math.PI / 2;
ground.rotation.z = Math.PI / 4;
ground.receiveShadow = true;
和我的JsFiddle: https ://jsfiddle.net/fggjp2n9/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.