diff --git a/src/experimental/worley_sphere.scad b/src/experimental/worley_sphere.scad index f9e23e89..2cd70c2c 100644 --- a/src/experimental/worley_sphere.scad +++ b/src/experimental/worley_sphere.scad @@ -1,5 +1,6 @@ use ; use ; +use ; use ; radius = 30; @@ -11,22 +12,10 @@ worley_sphere(radius, detail, amplitude, dist); module worley_sphere(radius, detail, amplitude, dist = "border", grid_w = undef, seed = undef) { gw = is_undef(grid_w) ? radius : grid_w; - points_faces = geom_icosahedron(1, detail); - points = points_faces[0]; - faces = points_faces[1]; - - sd = is_undef(seed) ? rand() * 1000: seed; - noisy = nz_worley3s(points * radius, sd, gw, dist); - - noisy_points = [ - for(i = [0:len(points) - 1]) - let( - p = points[i], - nz = noisy[i][3] - ) - p * (radius + nz * amplitude) - ]; - - polyhedron(noisy_points, faces); + sd = is_undef(seed) ? floor(rand(0, 256)) : seed % 256; + polyhedron( + [for(p = points_faces[0]) p * (radius + _nz_worley3(p * radius, sd, gw, dist)[3] * amplitude)], + points_faces[1] + ); } \ No newline at end of file