mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-11 09:14:29 +02:00
refactor
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use <util/rand.scad>;
|
||||
use <noise/nz_worley3s.scad>;
|
||||
use <noise/_impl/_nz_worley3_impl.scad>;
|
||||
use <polyhedra/geom_icosahedron.scad>;
|
||||
|
||||
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]
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user