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