]> git.scottworley.com Git - nt3d/blame - medusa.html
Name finger_point / params.finger_points
[nt3d] / medusa.html
CommitLineData
00406c26
SW
1<html>
2 <head>
3 <title>Medusa</title>
4 <script type="text/javascript" src="nt3d.js"></script>
5 <script type="text/javascript">
b62906a2 6 function finger(params, finger_crosssection, ring_num, ring_radius, finger_angle) {
9c6ce9fa 7 var path = [];
b62906a2
SW
8 var twirl_amplitute = Math.cos((ring_num * 2 * Math.PI) / params.finger_twirl_period);
9 var twirl_angle = twirl_amplitute * params.finger_twirl_distance / (ring_radius * 2 * Math.PI);
9c6ce9fa 10 for (var finger_point = 0; finger_point <= params.finger_points; finger_point++) {
3fdffa6c
SW
11 var finger_progress = finger_point / params.finger_points;
12 var angle = (finger_angle + twirl_angle * finger_progress) * 2 * Math.PI;
9c6ce9fa
SW
13 var x = ring_radius * Math.cos(angle);
14 var y = ring_radius * Math.sin(angle);
3fdffa6c 15 path.push([x, y, params.finger_height * finger_progress]);
9c6ce9fa
SW
16 }
17 return nt3d.extrude(path, finger_crosssection, [0, 0, 1], nt3d.pathnormals_from_point(path, [0, 0, 0]));
18 }
3bafa9bd
SW
19 function medusa(params) {
20 var finger_crosssection = nt3d.circle(params.finger_radius, params.finger_faces);
00406c26 21 var fingers = [];
3bafa9bd
SW
22 for (var ring_num = 0; ring_num < params.num_rings; ring_num++) {
23 var ring_radius = params.first_ring_radius + ring_num * params.ring_spacing;
bdd7bcc0
SW
24 var num_fingers = Math.round((ring_radius * 2 * Math.PI) / params.finger_spacing);
25 for (var finger_num = 0; finger_num < num_fingers; finger_num++) {
26 var finger_angle = finger_num / num_fingers;
b62906a2 27 fingers = fingers.concat(finger(params, finger_crosssection, ring_num, ring_radius, finger_angle));
911d073b 28 }
00406c26
SW
29 }
30
31 return fingers;
32 }
3bafa9bd 33 var params = [["first_ring_radius", 20],
c81e16ac 34 ["num_rings", 4],
3bafa9bd 35 ["ring_spacing", 10, "Space Between Rings"],
bdd7bcc0 36 ["finger_spacing", 10],
3bafa9bd 37 ["finger_radius", 3],
c81e16ac 38 ["finger_faces", 3],
3bafa9bd 39 ["finger_points", 20],
34c919e9 40 ["finger_twirl_distance", 50],
b62906a2 41 ["finger_twirl_period", 2, "Finger Twirl Period (1=same, 2=alternating)"],
3bafa9bd 42 ["finger_height", 100]];
00406c26
SW
43 </script>
44 </head>
45 <body onload="nt3d.framework(medusa, params)">
46 <h1>Medusa</h1>
47 <p>An artsy thing.</p>
48 </body>
49</html>