4

I tried this:

dae.castShadow = true;
dae.receiveShadow = true;
scene.add(dae);

//spotLight is defined already.
spotLight.castShadow = true;

renderer.shadowMapEnabled = true;

But the model still does not have shadows? Did I do anything wrong? Please help.

Łukasz
  • 2,131
  • 1
  • 13
  • 28
Derek 朕會功夫
  • 92,235
  • 44
  • 185
  • 247

2 Answers2

3

There was change in three.js (see three.js migration r51--r52):

Replaced SceneUtils.traverseHierarchy with object.traverse.

Due to that, now proper way for setting castShadow and receiveShadow for all objects in hierarchy is:

dae.traverse(function(child) {
    child.castShadow = true;
    child.receiveShadow = true;
});
Łukasz
  • 2,131
  • 1
  • 13
  • 28
0

You need to set castShadow and receiveShadow to true for all the objects in the hierarchy.

THREE.SceneUtils.traverseHierarchy( dae, function ( child ) {

    child.castShadow = true;
    child.receiveShadow = true;

} );
mrdoob
  • 19,334
  • 4
  • 63
  • 62