I have a question about the initialization and animation process. When making changes to elements like lights and shadows, I've noticed that using large values during initialization can cause a significant drop in frames per second at the start. So, I decided to test how setting values incrementally in each loop of the animation process would impact the performance. It seems like it doesn't make much of a difference as the program loops through all the elements in the scene continuously.
This got me thinking, is this method really better for setting up a scene?
What are your thoughts on this? Have you encountered any complex scenes that behave similarly, or do you know of any instances where values are updated differently during startup? I'm specifically referring to scenarios where we are not just rendering what is visible on the screen but everything in the entire scene.
I'm also interested in how you would approach this situation:
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();