My goal is to adjust the lighting in my camera setup. I have implemented the following code:
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(40, windowWidth / windowHeight, 1, 10000);
camera.position.z = 50;
scene.add(camera);
var dirLight = new THREE.DirectionalLight(0xffffff);
**dirLight.position = camera.position;**
dirLight.position.normalize();
scene.add(dirLight);
renderer = new THREE.WebGLRenderer();
renderer.setSize(windowWidth, windowHeight);
i_container.appendChild(renderer.domElement);
controls = new THREE.TrackballControls(camera);
controls.rotateSpeed = 1.0;
controls.zoomSpeed = 1.2;
controls.panSpeed = 0.8;
controls.noZoom = false;
controls.noPan = false;
controls.staticMoving = true;
controls.dynamicDampingFactor = 0.3;
controls.keys = [65, 83, 68];
controls.addEventListener('change', render);
Everything seems to be functioning properly: the light moves with the camera. However, I am encountering an issue where the camera initializes within my object, requiring me to zoom out to view the entire object.
Interestingly, when I remove the line - "dirLight.position = camera.position;", the scene initializes correctly and I can see the entire object.
I would greatly appreciate it if you could provide some insight into what might be causing this issue. I have not altered the camera's position, so why do I find myself inside the object?
Thank you, Zhenya