Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Casting shadow on MeshPhongMaterial or MeshLambertMaterial in Three.js

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
});

enter image description here

Then I change it to use texture instead:

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

..all of a sudden, shadow is gone:

enter image description here

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.

like image 304
kangax Avatar asked Jul 14 '14 19:07

kangax


1 Answers

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:

enter image description here

like image 132
Marquizzo Avatar answered Oct 16 '22 00:10

Marquizzo