mrdoob/three.js — Issue #1222: Lighting
Author: gnitsuk
Created: 2012-01-31 15:29:50+00:00
State: open

Hi. I'm brand new to Three.js and its great. I have hopefully a simple problem, here it is. Below is the relevant part of my code:

m_material = new THREE.MeshLambertMaterial( { color: 0xff0000 } );

m_cubeGeometry = new THREE.Geometry();
m_cubeGeometry.vertices.push(new THREE.Vertex(new THREE.Vector3(0,0,0)));
m_cubeGeometry.vertices.push(new THREE.Vertex(new THREE.Vector3(0,500, 0)));
m_cubeGeometry.vertices.push(new THREE.Vertex(new THREE.Vector3(500,500,500)));

m_cubeGeometry.faces.push(new THREE.Face3(0,1,2));

m_cubeGeometry.computeFaceNormals();

m_cubeMesh = new THREE.Mesh(m_cubeGeometry, m_material);

m_cubeMesh.doubleSided = true;

m_scene.add(m_cubeMesh);

m_pointLight.position.x = 60;
m_pointLight.position.y = 50;
m_pointLight.position.z = 130;

//m_scene.add(m_pointLight);

The above works perfectly UNTIL I comment in the last line to add the light to the scene, then my triangle is invisible.
If I replace my custom geometry above with a call to new THREE.CubeGeometry( 200, 200, 200 ); and make a mesh from that then all is fine, the lighting is perfect.

I tried m_cubeGeometry.faces.push(new THREE.Face3(0,2,1)); but that didn't solve the issue.

I am rendering using THREE.CanvasRenderer.

Can anyone suggest my triangle is invisible when I add the pointlight to the scene?

Thanks for any help,
MItch.