Derek 朕會功夫 Derek 朕會功夫 - 6 months ago 27
Javascript Question

How to make COLLADA models cast shadow on its own in three.js?

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.

Answer

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;

} );