-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrefraction.js
68 lines (59 loc) · 1.63 KB
/
refraction.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
(function () {
let w = 400,
h = 350;
let sim = new Sim("#refraction_test", h, w)
sim.add_circle(new Circle(3 * w / 4, h / 3, 40), {
reflective: false,
refractive: true,
style: "solid glass",
ior: 1.5
});
sim.add_rect(30, 50, 70, 200, {
refractive: true,
ior: 1.5,
style: "solid glass"
});
let prism_width = 80;
let prism_x = w / 2 - 40;
let prism_y = h / 3
sim.add_solid([
new Line(prism_x, prism_y, prism_x + prism_width, prism_y),
new Line(prism_x + prism_width, prism_y, prism_x + prism_width, prism_y + prism_width),
new Line(prism_x + prism_width, prism_y + prism_width, prism_x, prism_y)
], {
refractive: true,
ior: 1.5,
style: "solid glass"
})
sim.add_solid([
new Line(prism_x, prism_y, prism_x + prism_width, prism_y),
new Line(prism_x + prism_width, prism_y, prism_x + prism_width, prism_y - prism_width),
new Line(prism_x + prism_width, prism_y - prism_width, prism_x, prism_y)
], {
refractive: true,
ior: 4,
style: "darkglass"
})
sim.add_solid([
new Bezier(100 + 10, 216,
166.666 + 10, 362.666,
233.333 + 10, 362.666,
300 + 10, 216),
new Line(300 + 10, 216, 100 + 10, 216)
], {
refractive: true,
ior: 1.33333,
style: "solid water"
})
let beam = new Beam({
x1: 41,
y1: 17,
x2: 178,
y2: 143,
num_rays: 10,
width: 20,
strength: 0.8,
ui: {}
})
sim.add_light(beam);
})();