0
我想用我的相機移動燈光。 我寫道:three.js使用TrackballControls移動光源時錯誤的攝像頭位置
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);
一切工作:光與鏡頭移動。 但有一個問題:當場景正在初始化攝像頭位於我的對象內部時。所以我應該縮小以查看整個對象。
沒有這一行 - 「dirLight.position = camera.position;」場景初始化正常:我看到整個對象。
請問你能解釋我有什麼問題嗎?我不改變相機的位置。爲什麼我在對象內部?
感謝, 振亞