]> git.scottworley.com Git - nt3d/blob - medusa.html
e82d9e53e75ba13949961beae30a1059c9c22031
[nt3d] / medusa.html
1 <html>
2 <head>
3 <title>Medusa</title>
4 <script type="text/javascript" src="nt3d.js"></script>
5 <script type="text/javascript">
6 function medusa(first_ring_radius, num_rings, ring_spacing, num_fingers, finger_radius, finger_faces, finger_points, finger_twirl, finger_height) {
7 var finger_crosssection = nt3d.circle(finger_radius, finger_faces);
8 var fingers = [];
9 for (var ring_num = 0; ring_num < num_rings; ring_num++) {
10 var ring_radius = first_ring_radius + ring_num * ring_spacing;
11 for (var finger_num = 0; finger_num < num_fingers; finger_num++) {
12 var finger_angle = finger_num / num_fingers;
13 var path = [];
14 for (var finger_point = 0; finger_point <= finger_points; finger_point++) {
15 var angle = (finger_angle + finger_twirl * finger_point / finger_points) * 2 * Math.PI;
16 var x = ring_radius * Math.cos(angle);
17 var y = ring_radius * Math.sin(angle);
18 path.push([x, y, finger_height * finger_point / finger_points]);
19 }
20 var finger = nt3d.extrude(path, finger_crosssection, [0, 0, 1], nt3d.pathnormals_from_point(path, [0, 0, 0]));
21 fingers = fingers.concat(finger);
22 }
23 }
24
25 return fingers;
26 }
27 var params = [["First ring radius", 20],
28 ["Number of rings", 10],
29 ["Space between rings", 10],
30 ["Number of fingers", 5],
31 ["Finger radius", 3],
32 ["Finger faces", 5],
33 ["Finger points", 20],
34 ["Finger twirl (in turns)", .1],
35 ["Finger height", 100]];
36 </script>
37 </head>
38 <body onload="nt3d.framework(medusa, params)">
39 <h1>Medusa</h1>
40 <p>An artsy thing.</p>
41 </body>
42 </html>