1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 22:28:16 +01:00
dotSCAD/docs/lib3x-nz_worley3s.md

42 lines
1.3 KiB
Markdown
Raw Normal View History

2020-04-07 17:57:27 +08:00
# nz_worley3s
2021-01-07 15:29:07 +08:00
Returns 3D [Worley noise](https://en.wikipedia.org/wiki/Worley_noise) values `[cell_x, cell_y, cell_z, noise]` at (x, y, z) coordinates.
2020-04-07 17:57:27 +08:00
It divides the space into grids. The nucleus of each cell is randomly placed in a grid.
**Since:** 2.3
## Parameters
- `points` : A list of `[x, y, z]` coordinates.
- `seed` : The random seed.
- `grid_w` : The grid width. Default to 10. Smaller `grid_w` makes more cells.
- `dist` : The noise value of each point is based on its distance to other cells. Different distance strategies make different noises. The `dist` parameter accepts `"euclidean"`, `"manhattan"`, `"chebyshev"` or `"border"`.
## Examples
2021-02-07 17:25:45 +08:00
use <voxel/vx_sphere.scad>;
2020-04-07 17:57:27 +08:00
use <noise/nz_worley3s.scad>;
2021-07-21 11:08:22 +08:00
grid_w = 10;
2020-04-07 17:57:27 +08:00
dist = "euclidean"; // [euclidean, manhattan, chebyshev, border]
seed = 51;
2021-02-07 17:25:45 +08:00
points = vx_sphere(20);
2021-07-21 11:08:22 +08:00
cells = nz_worley3s(points, seed, grid_w, dist);
2020-04-07 17:57:27 +08:00
for(i = [0:len(cells) - 1]) {
2022-04-06 17:44:11 +08:00
c = (norm([cells[i].x, cells[i].y, cells[i].z]) % 20) / 20;
2020-04-07 17:57:27 +08:00
color([c, c, c])
translate(points[i])
cube(1);
}
2021-02-24 21:09:54 +08:00
![nz_worley3s](images/lib3x-nz_worley3s-1.JPG)
2020-04-07 17:57:27 +08:00
You can build things like [worley_noise_ball](https://github.com/JustinSDK/dotSCAD/blob/master/examples/worley_noise_ball.scad).
2021-02-24 21:09:54 +08:00
![nz_worley3s](images/lib3x-nz_worley3s-2.JPG)
2020-04-07 17:57:27 +08:00
2021-02-24 21:09:54 +08:00
![nz_worley3s](images/lib3x-nz_worley3s-3.JPG)