Skip to content

Commit 02e129f

Browse files
committed
Offset lines to not interfere with the clipping plane
1 parent e07ea35 commit 02e129f

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/webgl-preview.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)