I am currently developing a webpage using three.js. Here is the code I have implemented successfully:
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
camera.position.z = 7;
var renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
var pointLight = new THREE.PointLight(0xFFFFFF);
pointLight.position.x = 20;
pointLight.position.y = 20;
pointLight.position.z = 20;
scene.add(pointLight);
var material = new THREE.MeshBasicMaterial( { color: 0xFFFFFF } );
var object3d, loader = new THREE.OBJLoader();
loader.load("https://dl.dropbox.com/s/kasjdw78lx3bkk0/weirdshape.obj?dl=0", function (obj) {
obj.material = material;
obj.traverse(function(child) { child.material = material; });
scene.add(obj);
object3d = obj;
render();
});
function render() {
object3d.rotation.y += 0.01;
object3d.rotation.x += 0.01;
object3d.rotation.z += 0.01;
requestAnimationFrame( render );
renderer.render( scene, camera );
}
Everything functions correctly with the current code. However, when attempting to switch from MeshBasicMaterial
to MeshPhongMaterial
, the screen remains black despite proper lighting setup. How can this issue be resolved?