简体   繁体   中英

How to remove wireframe diagonals?

I wrote a custom exporter for CAD software to export geometry data to ThreeJS editor. Now, of course in ThreeJS I wrote a correct loader which is loading all the geometry correctly.

There is just one problem; In wireframe view in ThreeJS I have triangles from each vertex. With what technique can I remove the triangulation and diagonals ? How can I show wireframe without diagonals ?

Source 3D: 图片

ThreeJS 3D: (see the triangles and diagonales) 图片

it looks like you are drawing all points/polygons as single polyline

  • that is not correct you should process each polygon as line loop
  • if your mesh is triangulated or quaded then you need to extract the perimeter line

extracting perimeter line

  1. if your mesh is not defined by polygons then you need to group all connected primitives as single polygon
  2. take all lines from single polygon in a list
  3. find duplicate lines and remove them all
    • so all lines that uses the same points (in any order) are duplicate
    • joined primitives share the same edge
    • so this is enough for properly triangulated polygons
  4. some triangulations can be joined by line only not by points
    • for these you need to compare all remaining lines
    • take all parallel lines (the same or opposite angle)
    • and test if they lies on the same line
    • if yes and are connected (overlapping)
    • then cut the lines so the overlapped part will be deleted

Bad triangulation

  • if primitives are overlapping instead of joined
  • then draw single polygon to cleared buffer
  • then process all lines
  • compute midle point for each
  • and test if the coordinate is filled in the buffer or not
  • if it is remove the line
  • this is not 100% bullet proof
  • you should test more points along each line
  • and if some are in and some out then find the intersections and cut the inside part only
  • you can also use vector approach for the inside test but you have to handle multiple overlaps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM