1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-01 04:20:27 +02:00

refactor: start from unit sphere

This commit is contained in:
Justin Lin
2022-03-28 16:58:14 +08:00
parent cd2b3bf379
commit 0430baeaa9

View File

@@ -3,19 +3,19 @@ use <noise/nz_perlin3s.scad>;
use <polyhedra/geom_icosahedron.scad>;
radius = 30;
detail = 30;
detail = 15;
amplitude = 10;
period = 2;
period = 1;
perlin_sphere(radius, detail, amplitude, period);
module perlin_sphere(radius, detail, amplitude, period = 1, seed = undef) {
points_faces = geom_icosahedron(radius, detail);
points_faces = geom_icosahedron(1, detail);
points = points_faces[0];
faces = points_faces[1];
sd = is_undef(seed) ? rand() * 1000: seed;
noisy = nz_perlin3s(period * points / radius, sd);
noisy = nz_perlin3s(period * points, sd);
noisy_points = [
for(i = [0:len(points) - 1])
@@ -23,7 +23,7 @@ module perlin_sphere(radius, detail, amplitude, period = 1, seed = undef) {
p = points[i],
nz = noisy[i]
)
p / norm(p) * (radius + nz * amplitude)
p * (radius + nz * amplitude)
];
polyhedron(noisy_points, faces);