2

I am working on project where the app needs to show quad elements in wifeframe ( quad elements count could be in thousands) and also be able to pick the quad elements. I used 2 face3 to generate a quad, this results in a diagonal edge between the trias. What is a good solution to create quad element

squareGeometry = new THREE.Geometry(); 
squareGeometry.vertices.push(new THREE.Vector3(-1.0,  1.0, 0.0)); 
squareGeometry.vertices.push(new THREE.Vector3( 1.0,  1.0, 0.0)); 
squareGeometry.vertices.push(new THREE.Vector3( 1.0, -1.0, 0.0)); 
squareGeometry.vertices.push(new THREE.Vector3(-1.0, -1.0, 0.0)); 
squareGeometry.faces.push(new THREE.Face3(0, 1, 2)); 
squareGeometry.faces.push(new THREE.Face3(0, 3, 2));

material = new THREE.MeshBasicMaterial({color: 0x999999, specular: 0x101010, side: THREE.DoubleSide, wireframe: true});
mesh = new THREE.Mesh( squareGeometry, material );
scene.add(mesh)

Update : The suggestions on Three.JS wireframe material - all polygons vs. just edges helps to create wireframe for hard edges. How about for shared edges. Below is a image with four QUAD elements, as seen only the free edges/hard edges are shown in wireframe Note : I am using JsonLoader to load a Json file which has QUAD faces and vertices defining them

Is going towards custom shader a better option to hide the diagonal lines?

4 Quad Shaded

var material = new THREE.MeshPhongMaterial( {
    color: 0xeee000, 
    opacity: 0.5,
    transparent: true,
    side: THREE.DoubleSide,
    shading: THREE.FlatShading,
    polygonOffset: true,
    polygonOffsetFactor: 1, 
    polygonOffsetUnits: 1
} );
mesh = new THREE.Mesh( geometry, material );

scene.add( mesh );

var geo = new THREE.EdgesGeometry( mesh.geometry); 
var mat = new THREE.LineBasicMaterial( { color: 0xffffff, linewidth: 1 } );
var wireframe = new THREE.LineSegments( geo, mat );
mesh.add( wireframe );
Community
  • 1
  • 1
MangoCode
  • 38
  • 1
  • 6
  • http://stackoverflow.com/questions/20153705/three-js-wireframe-material-all-polygons-vs-just-edges – 2pha Jan 08 '17 at 06:31
  • 1
    Thanks 2pha for pointing out the answer .. – MangoCode Jan 09 '17 at 02:16
  • One aspect of your question, "and also be able to pick the quad elements" might find some traction with my previous answer here: http://stackoverflow.com/questions/41471686/way-to-group-coplanar-triangles-in-threejs-mesh/41476595#41476595 – Radio Jan 09 '17 at 23:28
  • Thanks Radio for pointing in right direction... – MangoCode Jan 13 '17 at 04:29

0 Answers0