javascript - Drawing a Line3 in Threejs -


i want draw line3 in threejs , here code it:

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 doesn't give error doesn't draw line either. in same program, have sphere:

   var initscene = function () {    window.scene = new three.scene();     window.renderer = new three.webglrenderer({       alpha: true     });      window.renderer.setclearcolor(0x000000, 0);     window.renderer.setsize(window.innerwidth, window.innerheight);      window.renderer.domelement.style.position = 'fixed';     window.renderer.domelement.style.top = 0;     window.renderer.domelement.style.left = 0;     window.renderer.domelement.style.width = '100%';     window.renderer.domelement.style.height = '100%';      document.body.appendchild(window.renderer.domelement);      var directionallight = new three.directionallight( 0xffffff, 1 );     directionallight.position.set( 0, 0.5, 1 );     window.scene.add(directionallight);      window.camera = new three.perspectivecamera(45, window.innerwidth / window.innerheight, 1, 1000);     window.camera.position.fromarray([0, 150, 700]);     window.camera.lookat(new three.vector3(0, 160, 0));      window.addeventlistener('resize', function () {        camera.aspect = window.innerwidth / window.innerheight;       camera.updateprojectionmatrix();       renderer.setsize(window.innerwidth, window.innerheight);       renderer.render(scene, camera);      }, false);      scene.add(camera);      // set sphere vars     var radius = 50,     segments = 16,     rings = 16;      // create new mesh     // sphere geometry - cover     // spherematerial next!     var spherematerial =     new three.meshlambertmaterial(     {       color: 0xcc0000     });     var sphere = new three.mesh(      new three.spheregeometry(     radius,     segments,     rings),       spherematerial);      // add sphere scene     scene.add(sphere);      start = new three.vector3(20, 10, 0);      end = new three.vector3(200, 100, 0);     var line  = new three.line3(start, end);        scene.add(line);     renderer.render(scene, camera);     };      initscene(); 

i see sphere on screen. can please tell me wrong?

enter image description here

adlads (a day late , dollar short):
http://threejs.org/docs/

line3 1 of many math objects of three.js can used compute geometric stuff. others are: box2 box3 color euler frustum line3 math matrix3 matrix4 plane quaternion ray sphere spline triangle vector2 vector3 vector4

say had "line", line3 object , "plane", plane object. check if line intersected plane doing plane.intersectsline(line). give true or false.

none of these math objects (including line3's) object3d's, things rendered.

here's scoop:
1) make scene, camera, , renderer.
2) add object3d's scene.
2a) object3d's can points, lines, or meshes.
2b) points, lines, , meshes made of geometries , materials.
2c1) points , lines, geometries contain vertices(vector3's) , faces(face3's). "vertices.push" or "faces.push".
2c2) meshes, geometries can be: box circle cylinder dodecahedron extrude icosahedron lathe octahedron parametric plane polyhedron ring shape sphere tetrahedron text torus torusknot tube
3) "renderer.render(scene, camera)".

thanks question. straightened me out.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -