three.js r75 pointLight shadows in wrong places -
i have jsfiddle containing fixed sun , moons , moving planet earth orbits sun.
here code 2 lights (ambient , point) , example objects.
var light2 = new three.ambientlight(0x444444);//... lighting sun , other meshbasicmaterial meshes. scene.add(light2); //... pointlight // http://threejs.org/docs/#reference/lights/pointlight var light3 = new three.pointlight( 0xffffff, 10, 150000,1); light3.castshadow = true; light3.shadow.camera.near = 1; light3.shadow.camera.far = 5000; light3.shadow.camera.fov = 90; // light3.shadowcameravisible = true; light3.shadow.bias = 0.001; scene.add( light3 ); // spheres var spheregeom = new three.spheregeometry( 40, 32, 16 ); var sunmaterial = new three.meshbasicmaterial( { color: 0xffff00 } ); this.sun01 = new three.mesh( spheregeom.clone(), sunmaterial ); sun01.position.set(-500, 0, 220); scene.add( sun01 ); //sun01.castshadow = false; //sun01.receiveshadow = false; light3.position.set( sun01.position.x, sun01.position.y , sun01.position.z); var moonmaterial = new three.meshphongmaterial( { color: 0xaa00aa } ); var moon02 = new three.mesh( spheregeom.clone(), moonmaterial ); moon02.scale.set( 0.5,0.5,0.5 ); moon02.position.set(-200, 0, 220); scene.add( moon02 ); moon02.castshadow = true; moon02.receiveshadow = false;
there 2 problems.
firstly distant fixed moons not illuminated pointlight though within range.
secondly shadows distant moons appear on (sun-orbitting) earth though earth nearer sun fixed moons.
note inner fixed moon (named moon02, magenta in color) illuminated pointlight , cast shadow on earth.
here renderer set-up code:-
renderer = new three.webglrenderer(); renderer.setclearcolor( 0x000022 ); renderer.setpixelratio( window.devicepixelratio ); renderer.setsize( window.innerwidth, window.innerheight ); //... enable shadows renderer.shadowmap.enabled = true;//.shadowmapenabled = true; //renderer.shadowmap.type = three.basicshadowmap;// //renderer.shadowmap.type = three.pcfshadowmap renderer.shadowmap.type = three.pcfsoftshadowmap;
my question = needs done (a) illuminate outer moons , (b) ensure shadows of outer moons not appear on (inner, nearer-to-sun) planet earth.
simply put, you're spacing things out far.
calculating shadows point light expensive. in fact, three.js added functionality a few months ago. can't find solid in documentation yet, seems there's hard coded limit on how far out shadows calculated point light.
the solution easy: reduce space between objects. there's absolutely no reason objects need thousands of units away each other when dozen suffice. solved both of problems just reducing distances , scales factor of 10. tweaked intensity of pointlight because 10 pretty harsh haha.
// color, intensity, falloff radius, falloff amount // if falloff radius 0 there no falloff var light3 = new three.pointlight( 0xffffff, 1, 0, 0);
Comments
Post a Comment