0
votes

Just discovered three.js and I'm hoping to use it to display personalized product previews. Simple shadows would be nice but I can't get 'em to work .... Whenever I recreate the examples they work fine, but i just can't get it to work with my set up.

Please see this fiddle

If i comment out the renderer.shadowMap.enabled = true; part (fiddle) - the scene renders as i would like it.

Debugging with Firefox shows that the shadow property of lightis undefined but when i console.dir the light (replace 8 with a 9 in the fiddle url to see) that's supposed to make a shadowcamera i can see that the directional light has a shadow property.

Would truly, truly appreciate any help. I know i must be missing something...

1

1 Answers

2
votes

Ambient Lights dont cast shadows in Three.js:

ambLight.castShadow = true;

That fixes: TypeError: shadow is undefined

You still wont see a shadow cast because the shadowCamera frustum of your DirectionalLight doesnt hit the floor.

Fixed: http://jsfiddle.net/dj23x1hj/14/