-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
120 lines (102 loc) · 2.58 KB
/
index.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
117
118
119
120
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>vox</title>
</head>
<body>
<style>
* {
background: #d0d0e1;
padding: 0;
margin: 0;
}
head {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
user-select: none;
-webkit-user-select: none;
}
.screen {
width: 100%;
height: 100%;
}
#canvas {
position: absolute;
touch-action: none;
image-rendering: pixelated;
}
@media (orientation: portrait) {
#canvas {
top: calc(90vh - 125vw);
width: 100vw;
height: 100vw;
}
}
@media (orientation: landscape) {
#canvas {
width: 100vh;
height: 100vh;
left: calc(50vw - 50vh);
}
}
</style>
<div class="screen">
<canvas id="canvas"></canvas>
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAB5CAYAAADvRtvsAAAAAXNSR0IArs4c6QAAAQZJREFUWIXtlT0SgjAQhXcz9B7B8RB0dDZWjJew0ZZjYOFV7GlsabV2PIIXYG1U8gOBxTEGydcwZF+WZd8SAAKBSZMTQU7UFRNOiwow6OkgGqIMURFKDLA7J4KTpYy22L+B8k1F5lsLrPvO6nMEAIZTCq9YhiisQm2TUobYq3H9vn5Uj6kbIywH0SbUN7DsHiDenu1Nf8bfmcXu0pxNWmd1Y4w4sPt6uzcK5XWW3d+bOoWKiJJkTfJ1cDJP8MRuB+cGHspGQdt6sNuBKZ7MhkDEIk6VYBGn3Yc5rTY+z4Rvdv9WbHRDtnxZHkf/72bBmo1ID8of6GI+UzdyyvjMQSPblBwMeMgDbfzGsYzA884AAAAASUVORK5CYII=" class="sprite" hidden>
</div>
<script src="vox.js"></script>
<script src="camera.js"></script>
<script>
image = document.querySelector('.sprite');
width = image.width;
height = image.height;
//resolution of screen
scaleSize = 32/(width/16);
//number of stacks
resolution = 4;
res = scaleSize/resolution;
layers = height/width;
size = layers*scaleSize;
canvas.width = size;
canvas.height = size;
layers2 = layers*scaleSize/res;
is = scaleSize/(scaleSize/res*2)
x = size/2-size/4
y = x;
scale = size/2;
t = 0;
function update() {
Yaw = Yaw + YawV;
Pitch = Math.min(Math.max(Pitch + PitchV,-90),90);
YawV = YawV * .9;
PitchV = PitchV * .9;
//sorting stacks
if (Pitch > 0) {
ctx.globalCompositeOperation = 'source-over';
}
else {
ctx.globalCompositeOperation = 'destination-over';
}
t = t+1;
//updating screen
cls(ctx);
z = 0;
rotx = Pitch;
roty = Yaw;
for (i = layers2; i > 0; i--) {
if (i%(scaleSize/res)==0) {
z++;
}
ssprr(ctx,x,y+(i*is-layers2*is/2)*Math.cos(rotx*Math.PI/180),scale,scale,0,z*-width+height,width,width,roty,rotx);
}
requestAnimationFrame(update);
}
update();
</script>
</body>
</html>