I recently created a basic program using Three.js to generate pyramidal roof shapes. Unfortunately, when rendering these shapes along with other objects like extrusions and cubes in BufferGeometry with a MeshLambertMaterial, the roofs appear as if they were generated with a MeshBasicMaterial. I'm unsure of what could be causing this issue since this is just a simplified version of my code:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<script src="three.min.js"></script>
<script src="OrbitControls.js"></script>
<style type="text/css">
body{margin:0;}
</style>
</head>
<body>
<script>
var camera, SCENE, renderer, controls, SUN, OBJ;
init();
animate();
function init() {
camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.1, 1000 );
SCENE = new THREE.Scene();
SCENE.background = new THREE.Color( 0xBBDDFF );
SUN = new THREE.DirectionalLight( 0xffffff, 0.6 );
SCENE.add( SUN );
SCENE.add( new THREE.AmbientLight( 0xcccccc, 0.8 ) );
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
controls = new THREE.OrbitControls( camera, renderer.domElement );
controls.minDistance = 1;
controls.maxDistance = 1000;
var geometry = new THREE.BufferGeometry();
var material = new THREE.MeshLambertMaterial( { color:0xff0000} );
vertices = new Float32Array([
0,0,0,
0,1,0,
1,0,0,
0,0,0,
0,0,1,
0,1,0,
0,0,0,
1,0,0,
0,0,1,
0,1,0,
0,0,1,
1,0,0,
]);
geometry.addAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
OBJ = new THREE.Mesh(geometry,material);
SCENE.add(OBJ);
camera.position.set(OBJ.position.x,10,OBJ.position.z-10);
camera.lookAt(OBJ.position);
controls.target.set(OBJ.position.x,1,OBJ.position.z);
camera.updateProjectionMatrix();
SUN.position.copy( camera.position );
SUN.target = OBJ;
document.body.appendChild( renderer.domElement );
renderer.render( SCENE, camera );
}
function animate() {
requestAnimationFrame( animate );
renderer.render( SCENE, camera );
}
</script>
</body>