kangax
kangax

Reputation: 39188

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.

Upvotes: 9

Views: 4448

Answers (1)

M -
M -

Reputation: 28502

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

Upvotes: 1

Related Questions