Marching Cubes problem

Hey, i started using Babylonjs a few days ago and, as i noticed it was very simple to use and powerful, i decided to try and make marching cubes algorithm.
Spoiler: it isn’t going well :frowning:
I can’t quite understand why it isn’t working. I’ve changed the code so that i can manipulate the vertices values, draw a single cube and the output was the expected. However when given random values it doesn’t show any meaningful mesh :confused:
This is hard and i appreciate anyone who may be able to help me, thanks in advance!

Link to playground:

Hello and Welcome to the forum :slight_smile:

@JohnK and @jerome are Maths king and might be able to help here.

That said your PG is a bit big to troubleshoot, could you create a smaller one hightlighting your issue ?

Yeah, i know its a bit of a headache to work with my code, however i really have no idea what the issue might be making it hard to highlight :frowning:
EDIT: it might help to uncomment line 46 in order to view the cubes
here is an example (same code) but with just one cube, origin of the world is vertex 0 of the cube and is (0,0).
Vertices of the cube activated are 7, 5 and 1.
Here is an image comparing the output with an youtube video:

Link for new playground:
Sorry for so much editing and thanks!

First things first, thanks for trying to help!
So, i was solving this all day long and i think i figured it out. It is tricky to explain but i’ll do my best. The algorithm was/is working just fine, the problem were the values of the vertex’s which were completely random (on purpose) thus not generating anything meaningful. I’ve gone ahead and somewhat included perlin noise instead of random values. I haven’t finished it yet but i’m making progress as seen here:


New update, figuring more stuff out, the problem was definitely the one i tried to explain earlier:

1 Like