WireframeGeometry2 & LineMaterial - Remove diagonal lines on box

How do I remove these ugly diagonal lines?

I need the lines to have thickness so I can’t use edgegeometry.

linesremove

Here is my code:

		var geo3 = new THREE.BoxGeometry( 1,1,1 );
		var geometry3 = new WireframeGeometry2( geo3 );
		var matLine = new LineMaterial({
			color: 0x4080ff,
			linewidth: 0.002, // in pixels?
			//resolution:  // to be set by renderer, eventually
			dashed: false
		} );
		this.bboxLines = new Wireframe( geometry3, matLine );
		this.bboxLines.computeLineDistances();
		this.bboxLines.scale.set( 1, 1, 1 );

Hi!

WireframeGeometry2 is extended from LineSegmentsGeometry, and that geometry has fromEdgesGeometry method: three.js/examples/jsm/lines/LineSegmentsGeometry.js at 841d2e791d3e8a2463322c5ca31b16956828b91c · mrdoob/three.js · GitHub

Demo: https://codepen.io/prisoner849/full/MWxxxbL

4 Likes

Very nice move, thanks!

new LineSegmentsGeometry().fromEdgesGeometry(eg);
1 Like