-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathshell.html
executable file
·106 lines (91 loc) · 3.6 KB
/
shell.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
<!doctype html>
<html lang="en-us">
<head>
<title>2D to 3D Extrusion</title>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
#canvas {
display: block;
margin: 10px;
border: 0px none;
background-color: black;
}
#wrapper {
border: solid 2px black;
resize: both;
overflow: hidden;
margin: auto;
width: 660px;
height: 500px;
display: flex;
justify-content: center;
}
#about {
display: block;
margin: auto;
border: 0px none;
width: 660px;
text-align: center;
justify-content: center;
background-color: transparent;
}
</style>
</head>
<body>
<div class="emscripten" id="wrapper">
<canvas width=640 height=480 class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas>
</div>
<div class="emscripten" id="about">
<br>
<b>Instructions</b><br>
Drag and drop image from below (or from desktop, *.png / *.bmp) onto canvas to generate 3D model. Images should be 32bit,
alpha channel is used for determining shape. Image size for this demo limited to a maximum height and width of 2048 pixels.
<br><br>
<b>Controls</b><br>
Press keys '1' (lowest) thru '9' (highest) to adjust number of triangles in model.<br>
Press 'w' key to toggle wireframe.<br>
Use mouse to rotate model, mouse wheel to zoom.<br>
<br>
</div>
<br>
<div class="emscripten" id="about">
<a href="assets/blob.png"><img id="Blob" draggable="true" src="assets/blob.png" height=128 width=128></a>
<a href="assets/shapes.png"><img id="Shapes" draggable="true" src="assets/shapes.png" height=128 width=128></a>
<a href="assets/craft.png"><img id="Craft" draggable="true" src="assets/craft.png" height=128 width=128></a>
</div>
<script type='text/javascript'>
const blob = document.getElementById("Blob");
const shapes = document.getElementById("Shapes");
const craft = document.getElementById("Craft");
blob.addEventListener("dragstart", (event) => {
});
var Module = {
canvas: (function() {
var canvas = document.getElementById('canvas');
var canvasWrapper = document.getElementById('wrapper');
const border_width = 16;
let width;
let height;
setInterval(() => {
const newWidth = canvasWrapper.clientWidth;
const newHeight = canvasWrapper.clientHeight;
if ((width != newWidth - border_width) || (height != newHeight - border_width)) {
width = newWidth - border_width;
height = newHeight - border_width;
canvas.width = width;
canvas.height = height;
window.dispatchEvent(new Event('resize'));
}
}, 100)
canvas.addEventListener("webglcontextlost", (event) => {
event.preventDefault();
alert('WebGL context lost. You will need to reload the page.');
});
return canvas;
})()
};
</script>
{{{ SCRIPT }}}
</body>
</html>