Is there a way to control the "subdivision" of edges in EdgesGeometry?

Right now I’m rendering a cube with wireframed edges:

var cubeGeometry = new THREE.BoxGeometry(2, 2, 2);   
var wireframeGeometry = new THREE.EdgesGeometry(cubeGeometry);
var wireframeMaterial = new THREE.LineBasicMaterial({ color: 0x000000 });
var cube = new THREE.LineSegments(wireframeGeometry, wireframeMaterial);
Three.scene.add(cube);

This works but now I want to increase the “subdivision” of the edges so that it looks more like a wireframe Rubik’s cube. I tried increasing the BoxGeometry segments…

var cubeGeometry = new THREE.BoxGeometry(2, 2, 2, 3, 3, 3);

But this doesn’t change anything. EdgesGeometry still only renders the outermost edges.

If I want each face to have a # of intersecting edges (but not the diagonal lines you get with the WireframeGeometry), how would I do that?

Hi!
Maybe this topic will be useful/helpful with ideas: GridBoxGeometry

1 Like

Hey, I’d love to use this but BoxBufferGeometry doesn’t exist for me… only BufferGeometry.

But BoxGeometry exists in later revisions. It equals to BoxBufferGeometry from earlier revisions. :thinking:

Sorry, misunderstood while on the train. For what it’s worth I rewrote a section of your code to be a bit more grokkable by me subjectively!

let startIndex = 0;
    let indexSide1 = indexSide(segmentsZ, segmentsY, startIndex);
    startIndex += (segmentsZ + 1) * (segmentsY + 1);
    let indexSide2 = indexSide(segmentsZ, segmentsY, startIndex);
    startIndex += (segmentsZ + 1) * (segmentsY + 1);
    let indexSide3 = indexSide(segmentsX, segmentsZ, startIndex);
    startIndex += (segmentsX + 1) * (segmentsZ + 1);
    let indexSide4 = indexSide(segmentsX, segmentsZ, startIndex);
    startIndex += (segmentsX + 1) * (segmentsZ + 1);
    let indexSide5 = indexSide(segmentsX, segmentsY, startIndex);
    startIndex += (segmentsX + 1) * (segmentsY + 1);
    let indexSide6 = indexSide(segmentsX, segmentsY, startIndex);

    let fullIndices = [];
    fullIndices = fullIndices.concat(indexSide1);
    fullIndices = fullIndices.concat(indexSide2);
    fullIndices = fullIndices.concat(indexSide3);
    fullIndices = fullIndices.concat(indexSide4);
    fullIndices = fullIndices.concat(indexSide5);
    fullIndices = fullIndices.concat(indexSide6);

    newGeometry.setIndex(fullIndices);

as this…

let fullIndices = [];

  fullIndices.push(...indexSide(segmentsZ, segmentsY, 0));
  fullIndices.push(...indexSide(segmentsZ, segmentsY, (segmentsZ + 1) * (segmentsY + 1)));
  fullIndices.push(...indexSide(segmentsX, segmentsZ, (segmentsZ + 1) * (segmentsY + 1) * 2));
  fullIndices.push(...indexSide(segmentsX, segmentsZ, (segmentsZ + 1) * (segmentsY + 1) * 2 + (segmentsX + 1) * (segmentsZ + 1)));
  fullIndices.push(...indexSide(segmentsX, segmentsY, (segmentsZ + 1) * (segmentsY + 1) * 2 + (segmentsX + 1) * (segmentsZ + 1) * 2));
  fullIndices.push(...indexSide(segmentsX, segmentsY, (segmentsZ + 1) * (segmentsY + 1) * 2 + (segmentsX + 1) * (segmentsZ + 1) * 2 + (segmentsX + 1) * (segmentsY + 1)));

  newGeometry.setIndex(fullIndices);
1 Like

Haven’t met “grok” since I’ve read Heinlein in 90s :slight_smile: