- function medusa(first_ring_radius, num_rings, ring_spacing, num_fingers, finger_radius, finger_faces, finger_points, finger_twirl, finger_height) {
- var finger_crosssection = nt3d.circle(finger_radius, finger_faces);
+ function finger(params, finger_crosssection, ring_num, ring_radius, finger_angle) {
+ var path = [];
+ var twirl_amplitute = Math.cos((ring_num * 2 * Math.PI) / params.finger_twirl_period);
+ var twirl_angle = twirl_amplitute * params.finger_twirl_distance / (ring_radius * 2 * Math.PI);
+ var widen_scale = params.widen_amount / (Math.exp(params.widen_sharpness) - 1);
+ for (var finger_point = 0; finger_point <= params.finger_points; finger_point++) {
+ var finger_progress = finger_point / params.finger_points;
+ var angle = (finger_angle + twirl_angle * finger_progress) * 2 * Math.PI;
+ var r = ring_radius + widen_scale * Math.exp(finger_progress * params.widen_sharpness);
+ var x = r * Math.cos(angle);
+ var y = r * Math.sin(angle);
+ var z = params.finger_height * finger_progress;
+ path.push([x, y, z]);
+ }
+ return nt3d.extrude(path, finger_crosssection, [0, 0, 1], nt3d.pathnormals_from_point(path, [0, 0, 0]));
+ }
+ function medusa(params) {
+ var finger_crosssection = nt3d.circle(params.finger_radius, params.finger_faces);