-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmisc_surf.html
116 lines (98 loc) · 2.76 KB
/
misc_surf.html
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Surfaces</title>
<style type="text/css" media="screen">
@import url(algtop_demo.css);
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js">
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
jax: ["input/TeX","output/HTML-CSS"],
tex2jax: {inlineMath: [["$","$"]]}
});
</script>
<script src="https://preview.babylonjs.com/babylon.js"></script>
<script src="algtop.js"></script>
<script src="json/boys_complex_alt.js"></script>
<style>
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
font-family: arial, verdana;
background: white;
}
.canvas {
width: 400;
height: 400;
touch-action: none;
}
div.surface {
text-align: center;
display : inline-block;
border : 1px solid black;
}
</style>
</head>
<body>
<div id="control_div" style="position:absolute; left:10px; top:10px;">
<div class="control" style="width: 150px;" id="index" onclick="location='index.php'">Index</div>
</div>
<div style="max-width:1300px; padding-top:50px;" id="container"></div>
<script>
var demo = {
};
demo.init = function () {
var me = this;
surfaces0 = [
['cylinder' , 'Cylinder'],
['sphere' , 'Sphere'],
['torus' , 'Torus'],
['mobius' , 'Möbius strip'],
['klein' , 'Klein bottle'],
['boys' , 'Boys surface']
];
this.container = document.getElementById('container');
this.frames = [];
console.log(window);
for (i in surfaces0) {
var f = {};
this.frames.push(f);
var n = surfaces0[i][0];
f.name = n;
f.title = surfaces0[i][1];
f.div = document.createElement('div');
f.div.className = 'surface';
f.canvas = document.createElement('canvas');
f.canvas.width = 400;
f.canvas.height = 400;
f.div.appendChild(f.canvas);
f.title_div = document.createElement('div');
f.title_div.innerHTML = f.title;
f.div.appendChild(f.title_div);
this.container.appendChild(f.div);
f.engine =
new BABYLON.Engine(f.canvas, true, { preserveDrawingBuffer: true, stencil: true });
f.scene = algtop.basic_scene(f.engine,f.canvas);
f.surface = Object.create(algtop[n]);
f.surface.make_mesh(f.scene);
this.set_frame_callbacks(f);
};
};
demo.set_frame_callbacks = function(f) {
f.engine.runRenderLoop(function () {
if (f.scene) {
f.scene.render();
}});
window.addEventListener("resize", function () {
me.engine.resize();
});
};
demo.init();
</script>
</body>
</html>