我對three.js相當陌生。我用r55把幾件東西放在一起,並想添加燈光。根據Mrdoob的文檔,我一直試圖添加DirectionalLight - 沒有運氣...我嘗試添加的燈光沒有出現 - 添加了shadowCameraVisible進行調試,但它不會顯示出來......任何人都知道什麼是什麼我的代碼可能是錯誤的?我感謝任何輸入!directionallight three js
function init() {
container = document.createElement('div');
document.body.appendChild(container);
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 1000);
renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
container.appendChild(renderer.domElement);
//CUBE
var material = new THREE.MeshBasicMaterial({
color: 0xff0000
});
var geometry = new THREE.CubeGeometry(x, y, z);
cube = new THREE.Mesh(geometry, material);
cube.position.z = z/2;
scene.add(cube);
//FLOOR
//floor color:
var floorMaterial = new THREE.MeshBasicMaterial({
color: 0xcccccc
});
//floor size:
var floorGeometry = new THREE.PlaneGeometry(20, 20, 1, 1);
var floor = new THREE.Mesh(floorGeometry, floorMaterial);
floor.position.y = -0.5;
floor.doubleSided = true;
scene.add(floor);
//LIGHTS
var dLight = new THREE.DirectionalLight(0xffffff);
dLight.position.set = (0, 0, 1);
dLight.shadowCameraVisible = true;
dLight.shadowCameraNear = 1;
dLight.shadowCameraFar = 150;
dLight.castshadow = true;
scene.add(dLight);
//CAMERA POSITION
camera.position.z = 50;
controls = new THREE.TrackballControls(camera);
renderer.shadowMapEnabled = true;
renderer.shadowMapType = THREE.PCFShadowMap;
}
確實,這看起來不正確......但是,改變之後,沒有燈光顯示出來......也許是渲染器設置的東西? – NGA 2013-02-11 20:28:53