init 및 animate 프로세스에 대해 궁금합니다. 우리는 조명과 그림자 같은 것을 바꿀 수 있습니다. 그리고 init 값에서 큰 값을 사용하면 처음부터 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();