1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-29 09:19:59 +02:00

add nz_worley3s

This commit is contained in:
Justin Lin
2020-03-29 10:44:54 +08:00
parent 6c060194ab
commit cff96e2d2b
2 changed files with 36 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
use <experimental/nz_worley3s.scad>;
size = [20, 20, 20];
dim = 5;
dist = "euclidean"; // [euclidean, manhattan, chebyshev]
seed = 5;
points = [
for(z = [0:size[2] - 1])
for(y = [0:size[1] - 1])
for(x = [0:size[0] - 1])
[x, y, z]
];
noises = nz_worley3s(size, points, seed, dim, dist);
max_dist = max(noises);
for(i = [0:len(noises) - 1]) {
c = noises[i] / max_dist;
color([c, c, c, c])
translate(points[i])
cube(1);
}

View File

@@ -0,0 +1,12 @@
use <util/rand.scad>;
use <experimental/_impl/_nz_worley3_comm.scad>;
function nz_worley3s(size, points, seed, dim = 3, dist = "euclidean") =
let(
sd = 6 + (is_undef(seed) ? floor(rand(0, 256)) : seed % 256),
// m*n pixels per grid
m = size[0] / dim,
n = size[1] / dim,
o = size[2] / dim
)
[for(p = points) _nz_worley3(p, sd, dim, m, n, o, dist)];