mergedGeometry LineSegment combination problem Three.js

31 views Asked by At

I want to create my edge lines of merged geometry. But with that code ı can create edges lines independentyl with 2 main geometry

// Combine two geometries
const geometry1 = new THREE.BoxGeometry(0.01, 9.1, 0.01);
const geometry2 = new THREE.BoxGeometry(1, 1, 1);
const mergedGeometry = BufferGeometryUtils.mergeBufferGeometries(
  [geometry1, geometry2]
);

// Create a mesh with a material that suppresses edge lines
const mergedMaterial = new THREE.MeshBasicMaterial({
    color: 0x542452,
    wireframe: true,  // Enable wireframe rendering
    opacity: 0,       // Set opacity to 0 to suppress edge lines
    transparent: true // Make the material transparent
});

const mergedMesh = new THREE.Mesh(mergedGeometry, mergedMaterial);
scene.add(mergedMesh);

// Create edges for the entire merged geometry
const edgesGeometry = new THREE.EdgesGeometry(mergedMesh.geometry);
const mergedLines = new THREE.LineSegments(
    edgesGeometry,
    new THREE.LineBasicMaterial({ color: 0xff0000 })
);

scene.add(mergedLines);

I want to

0

There are 0 answers