我想用我的相机移动光线。我写:
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;” 场景初始化正常:我看到了整个对象。
你能解释一下有什么问题吗?我不改变相机的位置。为什么我在物体里面?
谢谢,振亚