]> git.scottworley.com Git - nt3d/blob - medusa.html
Use a params object rather than loose arguments
[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(params) {
7 var finger_crosssection = nt3d.circle(params.finger_radius, params.finger_faces);
8 var fingers = [];
9 for (var ring_num = 0; ring_num < params.num_rings; ring_num++) {
10 var ring_radius = params.first_ring_radius + ring_num * params.ring_spacing;
11 for (var finger_num = 0; finger_num < params.num_fingers; finger_num++) {
12 var finger_angle = finger_num / params.num_fingers;
13 var path = [];
14 for (var finger_point = 0; finger_point <= params.finger_points; finger_point++) {
15 var angle = (finger_angle + params.finger_twirl * finger_point / params.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, params.finger_height * finger_point / params.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 ["num_rings", 10],
29 ["ring_spacing", 10, "Space Between Rings"],
30 ["num_fingers", 5],
31 ["finger_radius", 3],
32 ["finger_faces", 5],
33 ["finger_points", 20],
34 ["finger_twirl", .1, "Finger Twirl (in turns)"],
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>