Skip to content

Kosta/fix index creation (fix for #13) - #14

Merged
mourner merged 4 commits into
mapbox:masterfrom
Kosta-Github:Kosta/fix_index_creation
Mar 9, 2015
Merged

mourner merged 4 commits into
mapbox:masterfrom
Kosta-Github:Kosta/fix_index_creation

Conversation

@Kosta-Github

Copy link
Copy Markdown

This is a potential fix for #13

@mourner

mourner commented Mar 9, 2015

Copy link
Copy Markdown
Member

Thanks! Looks good to me. I'll now check if we can avoid getting vertex length on each vertex twice, and calculate dimensionality once instead...

@Kosta-Github

Copy link
Copy Markdown
Author

how about this?

@Kosta-Github

Copy link
Copy Markdown
Author

you could also make the number of dimensions variable (but the same for all vertices) and not just limiting it to 2 and 3 by explicitly using node.p.length for dim and not clamp it to 3. then you could replace https://github.com/mapbox/earcut/blob/master/src/earcut.js#L170-L172:

        vertices.push(node.p[0]);
        vertices.push(node.p[1]);
        if (node.p.length > 2) vertices.push(node.p[2]);

by

    vertices.concat(node.p);

@mourner

mourner commented Mar 9, 2015

Copy link
Copy Markdown
Member

concat produces a new array, so it's slow.
Looks good now. Do you think there are use cases that require more than 3 dimensions?

@Kosta-Github

Copy link
Copy Markdown
Author

ah yeah, right about concat...

I could imagine to store additional data with the vertices, such as normals, colors, uv-coordinates for texture mapping, and then use interleaved buffer arrays for that data to render it with WebGL...

But leaving that out for now works for me. If/when I have a concrete use case for that I can create another PR...

mourner added a commit that referenced this pull request Mar 9, 2015
@mourner
mourner merged commit 7855909 into mapbox:master Mar 9, 2015
@Kosta-Github
Kosta-Github deleted the Kosta/fix_index_creation branch March 9, 2015 16:43
@mourner

mourner commented Mar 9, 2015

Copy link
Copy Markdown
Member

Published in 1.4.0. Also fixed the code to work with any number of dimensions.

@jfirebaugh jfirebaugh mentioned this pull request Sep 29, 2015
5 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants