@@ -475,18 +475,24 @@ export class WebGLPreview {
475475 }
476476
477477 private renderPathsAsLines ( paths : Path [ ] , color : Color ) : void {
478- console . log ( this . clippingPlanes ) ;
479478 const material = new LineMaterial ( {
480479 color : Number ( color . getHex ( ) ) ,
481480 linewidth : this . lineWidth ,
482481 clippingPlanes : this . clippingPlanes
483482 } ) ;
484483
485484 const lineVertices : number [ ] = [ ] ;
485+
486+ // lines need to be offset.
487+ // The gcode specifies the nozzle height which is the top of the extrusion.
488+ // The line doesn't have a constant height in world coords so it should be rendered at horizontal midplane of the extrusion layer.
489+ // Otherwise the line will be clipped by the clipping plane.
490+ const offset = - this . lineHeight / 2 ;
491+
486492 paths . forEach ( ( path ) => {
487493 for ( let i = 0 ; i < path . vertices . length - 3 ; i += 3 ) {
488- lineVertices . push ( path . vertices [ i ] , path . vertices [ i + 1 ] , path . vertices [ i + 2 ] ) ;
489- lineVertices . push ( path . vertices [ i + 3 ] , path . vertices [ i + 4 ] , path . vertices [ i + 5 ] ) ;
494+ lineVertices . push ( path . vertices [ i ] , path . vertices [ i + 1 ] - 0.1 , path . vertices [ i + 2 ] + offset ) ;
495+ lineVertices . push ( path . vertices [ i + 3 ] , path . vertices [ i + 4 ] - 0.1 , path . vertices [ i + 5 ] + offset ) ;
490496 }
491497 } ) ;
492498
0 commit comments