]>
Commit | Line | Data |
---|---|---|
1 | <html> | |
2 | <head> | |
3 | <title>Medusa</title> | |
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) { | |
7 | var path = []; | |
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 | var widen_scale = params.widen_amount / (Math.exp(params.widen_sharpness) - 1); | |
11 | for (var finger_point = 0; finger_point <= params.finger_points; finger_point++) { | |
12 | var finger_progress = finger_point / params.finger_points; | |
13 | var angle = (finger_angle + twirl_angle * finger_progress) * 2 * Math.PI; | |
14 | var r = ring_radius + widen_scale * Math.exp(finger_progress * params.widen_sharpness); | |
15 | var x = r * Math.cos(angle); | |
16 | var y = r * Math.sin(angle); | |
17 | var z = params.finger_height * finger_progress; | |
18 | path.push([x, y, z]); | |
19 | } | |
20 | return nt3d.extrude(path, finger_crosssection, [0, 0, 1], nt3d.pathnormals_from_point(path, [0, 0, 0])); | |
21 | } | |
22 | function medusa(params) { | |
23 | var finger_crosssection = nt3d.circle(params.finger_radius, params.finger_faces); | |
24 | var fingers = []; | |
25 | for (var ring_num = 0; ring_num < params.num_rings; ring_num++) { | |
26 | var ring_radius = params.first_ring_radius + ring_num * params.ring_spacing; | |
27 | var num_fingers = Math.round((ring_radius * 2 * Math.PI) / params.finger_spacing); | |
28 | for (var finger_num = 0; finger_num < num_fingers; finger_num++) { | |
29 | var finger_angle = finger_num / num_fingers; | |
30 | fingers = fingers.concat(finger(params, finger_crosssection, ring_num, ring_radius, finger_angle)); | |
31 | } | |
32 | } | |
33 | ||
34 | return fingers; | |
35 | } | |
36 | var params = [["first_ring_radius", 20], | |
37 | ["num_rings", 4], | |
38 | ["ring_spacing", 10, "Space Between Rings"], | |
39 | ["finger_spacing", 10], | |
40 | ["finger_radius", 3], | |
41 | ["finger_faces", 3], | |
42 | ["finger_points", 20], | |
43 | ["finger_twirl_distance", 50], | |
44 | ["finger_twirl_period", 2, "Finger Twirl Period (1=same, 2=alternating)"], | |
45 | ["finger_height", 100], | |
46 | ["widen_sharpness", 2, "Widen Sharpness (0=disable widening)"], | |
47 | ["widen_amount", 30]]; | |
48 | </script> | |
49 | </head> | |
50 | <body onload="nt3d.framework(medusa, params)"> | |
51 | <h1>Medusa</h1> | |
52 | <p>An artsy thing.</p> | |
53 | </body> | |
54 | </html> |