I'm having trouble drawing a Line3 in Three.js using the following code:
start = new THREE.Vector3(20, 10, 0);
end = new THREE.Vector3(200, 100, 0);
var line = new THREE.Line3(start, end);
scene.add(line);
The code runs without any errors, but the line is not showing up on the screen. In the same program, I have also added a sphere:
var initScene = function () {
window.scene = new THREE.Scene();
window.renderer = new THREE.WebGLRenderer({
alpha: true
});
// remaining code for setting up the renderer and camera...
var radius = 50,
segments = 16,
rings = 16;
// creating a sphere
var sphereMaterial =
new THREE.MeshLambertMaterial(
{
color: 0xCC0000
});
var sphere = new THREE.Mesh(
new THREE.SphereGeometry(
radius,
segments,
rings),
sphereMaterial);
// adding the sphere to the scene
scene.add(sphere);
start = new THREE.Vector3(20, 10, 0);
end = new THREE.Vector3(200, 100, 0);
// attempting to draw a line
var line = new THREE.Line3(start, end);
scene.add(line);
renderer.render(scene, camera);
};
initScene();
Currently, only the sphere is visible on the screen. Can someone please point out where I might be making a mistake?