1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-22 22:35:18 +02:00

refactor: start from unit sphere

This commit is contained in:
Justin Lin
2022-03-28 17:11:52 +08:00
parent 1c893c3fc7
commit af87c89ecc

View File

@@ -2,22 +2,22 @@ use <util/rand.scad>;
use <noise/nz_worley3s.scad>;
use <polyhedra/geom_icosahedron.scad>;
// radius = 30;
// detail = 10;
// amplitude = .05;
// dist = "border"; // [euclidean, manhattan, chebyshev, border]
radius = 30;
detail = 10;
amplitude = .05;
dist = "border"; // [euclidean, manhattan, chebyshev, border]
// worley_sphere(radius, detail, amplitude, dist);
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(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_worley3s(points, sd, gw, dist);
noisy = nz_worley3s(points * radius, sd, gw, dist);
noisy_points = [
for(i = [0:len(points) - 1])
@@ -25,7 +25,7 @@ module worley_sphere(radius, detail, amplitude, dist = "border", grid_w = undef,
p = points[i],
nz = noisy[i][3]
)
p / norm(p) * (radius + nz * amplitude)
p * (radius + nz * amplitude)
];
polyhedron(noisy_points, faces);