1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-12 09:44:16 +02:00

refactor: loop onice

This commit is contained in:
Justin Lin
2022-05-01 16:34:56 +08:00
parent 5ccfbf4bbb
commit 920b09ed07

View File

@@ -1,5 +1,5 @@
use <util/rand.scad>;
use <noise/nz_perlin3s.scad>;
use <noise/nz_perlin3.scad>;
use <polyhedra/geom_icosahedron.scad>;
radius = 30;
@@ -14,17 +14,11 @@ module perlin_sphere(radius, detail, amplitude, period = 1, seed = undef) {
points = points_faces[0];
faces = points_faces[1];
sd = is_undef(seed) ? rand() * 1000: seed;
noisy = nz_perlin3s(period * points, sd);
noisy_points = [
for(i = [0:len(points) - 1])
let(
p = points[i],
nz = noisy[i]
)
p * (radius + nz * amplitude)
];
sd = is_undef(seed) ? floor(rand(0, 256)) : seed % 256;
noisy_points = [
for(p = points)
p * (radius + nz_perlin3(p.x, p.y, p.z, sd) * amplitude)
];
polyhedron(noisy_points, faces);
}