I'm curious about something on the init and animate process. We can change things like lights and shadows and i've noticed if I use to big values at the init point, the fps at the start are dropping like hell. So I tested with some code in the animate process how it would be when I just set the values step by step each loop. I mean it's just like it is anyway. The “program” loops all the time all things in our scene.
But what i've asked myself was “Is it really better for a scene setup?!”
What do you say?! And do you know if there is any complex scene out there where it happens like this and then again without updating the values like this?! And I mean at startup, not like a game where we just render what we see, not what there is all over the scene.
I'm also curious how you could/would work this out:
var cam, light, d, rend;
var ambLone = 0x444444,
ambLoneI = 0.2,
ambLtwo = 0x666666,
ambLtwoI = 0.5,
lC = 0xdfebff,
lN = 2.75,
lF = 1000,
lightPx = 700,
lightPy = 500,
lightPz = 500,
lightSCmin = 1,
lightSCmax = 1000,
lightSCF = 100,
lightSCN = lightSCmin;
in init(); ->
scenes.add( new THREE.AmbientLight( ambLone, ambLoneI ) );
scenes.add( new THREE.AmbientLight( ambLtwo, ambLtwoI ) );
light = new THREE.DirectionalLight( lC, lN, lF );
light.position.set( lightPx, lightPy, lightPz );
light.position.multiplyScalar( 1.3 );
light.castShadow = true;
light.shadow.mapSize.width = 1024;
light.shadow.mapSize.height = 1024;
d = 1000;
light.shadow.camera.left = - d;
light.shadow.camera.right = d;
light.shadow.camera.top = d;
light.shadow.camera.bottom = - d;
light.shadow.camera.far = lightSCF;
light.shadow.camera.near = lightSCN;
var helper = new THREE.CameraHelper( light.shadow.camera );
scenes.add( light, helper );
in animate(); ->
requestAnimationFrame( animate );
if (lightSCF === lightSCmax) {
lightSCF = 1000;
light.shadow.mapSize.width = 5120;
light.shadow.mapSize.height = 5120;
console.log( 'Light is set to: ' + lightSCF + light.shadow.mapSize.width);
} else if(lightSCF < lightSCmax){
lightSCF = lightSCF + 1;
light.shadow.mapSize.width = light.shadow.mapSize.width + 4.5;
light.shadow.mapSize.height = light.shadow.mapSize.width + 4.5;
light.shadow.camera.far = lightSCF;
light.shadow.camera.updateProjectionMatrix();
console.log( 'Light is now: ' + lightSCF + ' ' + light.shadow.mapSize.width );
} else {
console.log( 'whatever... ');
}
render();