我很好奇初始化和動畫過程中的某些事情。我們可以改變諸如燈光和陰影之類的東西,並且我注意到如果我在初始點使用大值,開始時的fps就像地獄一樣下降。所以我在動畫過程中用一些代碼進行了測試,當我每次循環逐步設置值時它將如何。我的意思是它就像它無論如何。 「程序」一直在我們的場景中循環所有的東西。Three.js燈光和陰影
但我問過自己是「它是一個場景的設置?真不如」
你說什麼?你是否知道是否有任何複雜的場景發生,像這樣,然後又不更新像這樣的值?我的意思是在創業時,不是像我們只呈現我們所看到的遊戲,而不是那種場景中的東西。
我也很好奇,你怎麼可以/會工作了這一點:在初始化
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;
(); - >
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();