I am trying to apply an image a texture to a plane I create, below is the mthod that I am using. Any pointers on the mistake?
function drawPlane(plane){
geometry = new THREE.Geometry();
geometry.vertices.push( new THREE.Vector3( plane[0][0], plane[0][1], plane[0][2]) );
geometry.vertices.push( new THREE.Vector3( plane[1][0], plane[1][1], plane[1][2]));
geometry.vertices.push( new THREE.Vector3( plane[2][0], plane[2][1], plane[2][2]) );
geometry.vertices.push( new THREE.Vector3( plane[3][0], plane[3][1], plane[3][2]) );
geometry.faces.push( new THREE.Face3( 0, 1, 2 ) ); // counter-clockwise winding order
geometry.faces.push( new THREE.Face3( 0, 2, 3 ) );
geometry.computeFaceNormals();
geometry.computeVertexNormals();
//var material = new THREE.MeshBasicMaterial({color: 0xffffff});
var material = new THREE.MeshPhongMaterial();
material.side = THREE.DoubleSide;
material.map = texture; // this texture not applied
mesh = new THREE.Mesh( geometry, material );
scene.add(mesh);
}
The texture object is not null and seems to load properly but doesnt get applied on the created plane.