xtk / X

The X Toolkit
http://www.goXTK.com
Other
786 stars 263 forks source link

Draw Line in renderer2D in xtk library #225

Open chiliblast opened 2 years ago

chiliblast commented 2 years ago

I am trying to draw a line on click in canvas in renderer3D and renderer2D, after loading dicom files. Line does get drawing in renderer3D, but not in renderer2D. How can I get line in renderer2D

// create and initialize a 3D renderer this.r_3D = new X.renderer3D(); this.r_3D.container = canvas3D; this.r_3D.init();

// create and initialize a 2D renderer
this.r_X = new X.renderer2D();
this.r_X.container = canvasX;
this.r_X.orientation = 'X';
this.r_X.init();

click(e:any) {

let obj = new X.object();

obj.points = new X.triplets(6);
obj.normals = new X.triplets(6);
//obj.colors = new X.triplets(6);

// and set the type to POINTS
obj.type = 'LINES';

obj.points.add(e.offsetX, e.offsetY, 0);
obj.points.add(e.offsetX+100, e.offsetY+200, 200);
this.r_3D.add(obj);
this.r_2D.add(obj);

}