4 <script type=
"text/javascript" src=
"nt3d.js"></script>
5 <script type=
"text/javascript">
6 function finger(params, finger_crosssection, ring_num, ring_radius, finger_angle) {
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);
10 for (var finger_point =
0; finger_point <= params.finger_points; finger_point++) {
11 var finger_progress = finger_point / params.finger_points;
12 var angle = (finger_angle + twirl_angle * finger_progress) *
2 * Math.PI;
13 var x = ring_radius * Math.cos(angle);
14 var y = ring_radius * Math.sin(angle);
15 var z = params.finger_height * finger_progress;
18 return nt3d.extrude(path, finger_crosssection, [
0,
0,
1], nt3d.pathnormals_from_point(path, [
0,
0,
0]));
20 function medusa(params) {
21 var finger_crosssection = nt3d.circle(params.finger_radius, params.finger_faces);
23 for (var ring_num =
0; ring_num < params.num_rings; ring_num++) {
24 var ring_radius = params.first_ring_radius + ring_num * params.ring_spacing;
25 var num_fingers = Math.round((ring_radius *
2 * Math.PI) / params.finger_spacing);
26 for (var finger_num =
0; finger_num < num_fingers; finger_num++) {
27 var finger_angle = finger_num / num_fingers;
28 fingers = fingers.concat(finger(params, finger_crosssection, ring_num, ring_radius, finger_angle));
34 var params = [["first_ring_radius",
20],
36 ["ring_spacing",
10, "Space Between Rings"],
37 ["finger_spacing",
10],
40 ["finger_points",
20],
41 ["finger_twirl_distance",
50],
42 ["finger_twirl_period",
2, "Finger Twirl Period (
1=same,
2=alternating)"],
43 ["finger_height",
100]];
46 <body onload=
"nt3d.framework(medusa, params)">
48 <p>An artsy thing.
</p>