Reputation: 257
I am trying to create a solar system in WebGL. However i have no idea to set up the lighting. I want to put a light in my sun and have it cast light 360 degrees. My planets should cast and receive shadows. To achieve that , my light would need to cast shadows 360 degrees. Is it possible to do something like that? If so, how? Which type of light should i use?
My sun has a meshBasicMaterial, my planets have a meshShaderMaterial. Could anyone be so kind to provide me some example code?
Thank you!
Upvotes: 2
Views: 5051
Reputation: 3456
You should add a THREE.PointLight
for the sun - it will cast light to all directions.
The shadows are trickier as the point light in Three.js does not support shadow casting. You have a few less than ideal options:
Note that with a custom ShaderMaterial
on a shadow-receiving object, you need to implement shadows yourself in the shader (or include three.js' shadowing code chunks).
Upvotes: 5