From 9aa6bbb5ca23d597ecd1468c24dd7c414cfaea8b Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sun, 1 May 2022 16:55:53 +0800 Subject: [PATCH] refactor --- src/experimental/worley_sphere.scad | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) 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