Casting shadow on MeshPhongMaterial or MeshLambertMaterial in Three.js

坚强是说给别人听的谎言 提交于 2019-12-09 17:23:38

问题


I feel like I'm missing something simple here.

I used JSFiddle by @WestLangley, which demonstrates how to cast a shadow from an object onto a plane.

Everything works as expected when the plane is filled with just color:

var groundMaterial = new THREE.MeshLambertMaterial({
  color: 0xFF0000
});

Then I change it to use texture instead:

var groundMaterial = new THREE.MeshLambertMaterial({
  // color: 0xFF0000,
  map: texture
});

..all of a sudden, shadow is gone:

This happens with both MeshPhongMaterial and MeshLambertMaterial.

Note that neither camera position nor shadow configuration is changed. Everything stays the same, yet shadow is gone.

Should texture be "told" to receive light or is this something else?

Tested on r61, r66, r67.


回答1:


This is a pretty old question, but just to provide some closure, I'd like to point out that the version that was having this issue has since been fixed. The fiddle used Three.js r66, but the most recent (r107 as of this writing) no longer has this problem:



来源:https://stackoverflow.com/questions/24744246/casting-shadow-on-meshphongmaterial-or-meshlambertmaterial-in-three-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!