0

I want to implement polygon offset for ShapeGeometries (2D) in three.js

enter image description here

The above picture is an example of how it works in CityEngine.

What would be the best way to achieve this?

UPDATE 1

The problem is also described here. However, the external C++/C#/Delphi library Clipper is used to solve the problem there. It seems like the best solution is to feed a 3rd party library with the polygon values and import the result back as three.js geometry.

Community
  • 1
  • 1
Jonas
  • 1,315
  • 1
  • 18
  • 31
  • Sorry; I'm unclear — do the negative offsets amount to weird tessellations? Or is any area lost? The output object is still 2d, right? – Tommy Aug 13 '14 at 21:37
  • Well, I dont have any implementation, but I want a `x pixel` offset for an existing 2D-Geometry. The tesselation is a problem though, because in three.js there are only triangles and I can't figure out how to implement this offset. The result is 2D again, exactly. – Jonas Aug 13 '14 at 23:47
  • other than writing your own modeling tool, doubt that this is easy to achieve – pailhead Aug 14 '14 at 02:19

1 Answers1

0

I'm ending up feeding my 2D vertices to the Javascript version of Clipper: Javascript Clipper. It works pretty good, though there is some overhead with format conversion.

  1. Convert to Javascript Clipper format
  2. Execute offset operation in Javascript Clipper
  3. Convert back to three.js format
Jonas
  • 1,315
  • 1
  • 18
  • 31