mourner / icomesh

Fast JavaScript icosphere mesh generation library for WebGL visualizations
https://observablehq.com/@mourner/fast-icosphere-mesh
ISC License
55 stars 4 forks source link

WIP: Frequency split algorithm #5

Open IvanSanchez opened 5 years ago

IvanSanchez commented 5 years ago

Partial implementation of #3 - only implements the interior of the faces and not the vertices on the shared edges.

image

image

It's buggy (specially when the frequency is higher than ~90), breaks compatibility (changes the meaning of the only parameter of the API of this module), it's incomplete, it could be optimized further (make less calls or no calls to the pairing function), but should be a good point to do a benchmark.

On the plus side, having a frequency instead of a recursive order allows users to tweak the precision of the icosphere at a finer level. I can imagine there's an use case for using the max screen resolution as the frequency of the subdivision, in order to have something like e.g. resolution of 2px per triangle kinda reliably.

IvanSanchez commented 5 years ago

See also https://observablehq.com/d/45378773bf64820a

IvanSanchez commented 5 years ago

Biggest unresolved issue with this implementation is assigning the vertex IDs for the edge subdivisions.

The idea is to:

Rest of TODOs are in the code.

mourner commented 5 years ago

@IvanSanchez awesome attempt! How does the performance look at the moment (when using spheres of equivalent triangle count)? This is cool, but I'm most worried about the code complexity — ideally we would keep the library as minimal and simple as possible.