three.js shape to line

shape to line seems to be missing a segment

by wilt

HTML

<script src="http://threejs.org/build/three.min.js"></script>

CSS

body {
	background-color: #000;
	margin: 0px;
	overflow: hidden;
}

JavaScript

// three.js shape to line

var renderer, scene, camera;

var line;
var MAX_POINTS = 500;
var drawCount;

init();
animate();

function init() {

	// info
	var info = document.createElement( 'div' );
	info.style.position = 'absolute';
	info.style.top = '30px';
	info.style.width = '100%';
	info.style.textAlign = 'center';
	info.style.color = '#fff';
	info.style.fontWeight = 'bold';
	info.style.backgroundColor = 'transparent';
	info.style.zIndex = '1';
	info.style.fontFamily = 'Monospace';
	info.innerHTML = "three.js - shape to line seems to miss a segment";
	document.body.appendChild( info );

	// renderer
	renderer = new THREE.WebGLRenderer();
	renderer.setPixelRatio( window.devicePixelRatio );
	renderer.setSize( window.innerWidth, window.innerHeight );
	document.body.appendChild( renderer.domElement );

	// scene
	scene = new THREE.Scene();

	// camera
	camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 10000 );
	camera.position.set( 0, 0, 1000 );

  // shape
  shape = new THREE.Shape();
  shape.moveTo( 0, 0 );
  shape.lineTo( 40, 0 );
  shape.lineTo( 40, 40 );
  shape.lineTo( 0, 40 );
  shape.lineTo( 0, 0 );
  
	// geometry
	var geometry = shape.makeGeometry();

	// material
	var material = new THREE.LineBasicMaterial( { color: 0xff0000, linewidth: 2 } );

	// line
	line = new THREE.Line( geometry,  material );
	scene.add( line );

}

// render
function render() {

	renderer.render( scene, camera );

}

// animate
function animate() {

	requestAnimationFrame( animate );

  render();

}