Three.js的材料都是黑色的

时间:2014-04-29 11:06:50

标签: three.js

我的物品都是黑色的。我认为这可能与光有关,但我不确定。 Here's显示问题的图片,这是我的代码:

var scene = new THREE.Scene(); 
var camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 1000); 
var renderer = new THREE.WebGLRenderer();
var directionalLight = new THREE.DirectionalLight(0xffffff, 1.0);
var geometry = new THREE.Geometry();
var controls = new THREE.TrackballControls(camera);
var antMaterial = new THREE.MeshLambertMaterial({color: 0xff0000});
var material, mesh;

function init()
{
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColorHex(0x0088FF, 1);
document.body.appendChild(renderer.domElement);
camera.position.z += 5;
camera.position.y += 1;

//Controls
controls.rotateSpeed = 1.0;
controls.zoomSpeed = 1.0;
controls.panSpeed = 1.0;
controls.noZoom = false;
controls.noPan = false;
controls.staticMoving = true;
controls.addEventListener('change', render);

scene.add(ant());
directionalLight.position.set(1, 1, 1);
scene.add(directionalLight);

render();
animate();
}

1 个答案:

答案 0 :(得分:0)

您的问题的答案很可能是您的定向光来自窗格下方。这使得屏幕截图中可见的另一侧的颜色变黑,因为光线未到达此面部。首先尝试使用环境光或将位置更改为:

  directionalLight.position.set(0,0,-1); // change these values for the direction of the light source