Skip to content

Commit cdcb357

Browse files
committed
voronoi on sphere
1 parent 7ef7354 commit cdcb357

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
load_library 'hemesh'
2+
3+
java_import 'wblut.processing.WB_Render3D'
4+
java_import 'wblut.geom.WB_Point'
5+
java_import 'wblut.geom.WB_RandomOnSphere'
6+
include_package 'wblut.hemesh'
7+
8+
attr_reader :mesh, :render, :points
9+
10+
def setup
11+
sketch_title 'Voronoi On Sphere'
12+
ArcBall.init(self)
13+
rs = WB_RandomOnSphere.new
14+
creator = HEC_ConvexHull.new
15+
num = 500
16+
@points = (0...num).map { rs.next_point.mul_self(400.0) }
17+
creator.set_points(points)
18+
creator.set_n(num)
19+
imesh = HE_Mesh.new(creator)
20+
@mesh = HE_Mesh.new(HEC_Dual.new(imesh).set_fix_non_planar_faces(false))
21+
ext = HEM_Extrude.new.set_distance(0).set_chamfer(5).set_relative(false)
22+
mesh.modify(ext)
23+
mesh.get_selection('extruded').modify(HEM_Extrude.new.set_distance(-20))
24+
@render = WB_Render3D.new(self)
25+
end
26+
27+
def draw
28+
background(55)
29+
directional_light(255, 255, 255, 1, 1, -1)
30+
directional_light(127, 127, 127, -1, -1, 1)
31+
stroke(0)
32+
render.draw_edges(mesh)
33+
points.each { |point| render.draw_point(point) }
34+
no_stroke
35+
render.draw_faces(mesh)
36+
end
37+
38+
def settings
39+
size(1000, 1000, P3D)
40+
smooth(8)
41+
end

0 commit comments

Comments
 (0)