How to calculate the position and size of MarchingCube?

three.js examples


Do the codes in the red boxes in the figure represent the world coordinates of the sphere? What does’ length 'represent? How can I make it update MarchingCube based on the world coordinates and size in the scene? It’s quite confusing

Simulations like this usually have something that represents the “domain”.. that defines the worldspace area the simulation will cover. This can be represented as a bounding box, or a single node with a position/scale/rotation. In this case its the “new MarchingCubes()”
So you if you want to get in the domain from worldspace, you could use
marchingCubesObject.worldToLocal( yourWorldspacePoint )

yourWorldspacePoint is now in local space and should map to what is being set in that loop^

Thank you for your answer, this is not correct. If you have tried, you can see that its local coordinates are limited to 0-1

I was explaining to you how to use worldToLocal to transform from world space back to object space. The space that the marchingcubes simulation runs in is additionally defined by its resolution parameters, so you will still need to divide by those, and possibly add a fixed offset to make that local coordinates work.

But if you use .worldToLocal you should at least have a solution that works regardless of the scale/position/rotation of your marchingcubes object.

The coordinates are a small issue, but the radius of this sphere is really puzzling and I don’t know how to calculate it

Okay, the coordinates are also a big issue. This matchCube is not symmetrical