forked from vetorlab/cube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
103 lines (91 loc) · 4.6 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Cubefaces</title>
<meta name="viewport" content="width=device-width, minimum-scale=1,
initial-scale=1, user-scalable=no">
<style>
html {
background: #333;
box-sizing: border-box;
}
html * {
box-sizing: inherit;
}
html, body {
margin: 0; padding: 0;
}
section {
width: 100vw; height: 100vh;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
}
section > * {
flex: 0 0 auto;
}
</style>
<!-- webcomponents -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.0.1/webcomponents-lite.js" integrity="sha256-la6qW/wkFtceGefXKR37VKKRVXZvwUnUPiRPBmMpsP0=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.0.1/custom-elements-es5-adapter.js" integrity="sha256-uR3rlUJvFO/YuZv1B+fUPLirw4ORZWLcJtR590iIj30=" crossorigin="anonymous"></script>
<link rel="import" href="vz-cube.html">
</head>
<body>
<!-- <section>
<vz-cube>
<vz-cubepivot>
<vz-cubeface data-face="top" style="background-image: url(static/images/cubes/01/top.jpg)"></vz-cubeface>
<vz-cubeface data-face="bottom" style="background-image: url(static/images/cubes/01/bottom.jpg)"></vz-cubeface>
<vz-cubeface data-face="front" style="background-image: url(static/images/cubes/01/front.jpg)"></vz-cubeface>
<vz-cubeface data-face="back" style="background-image: url(static/images/cubes/01/back.jpg)"></vz-cubeface>
<vz-cubeface data-face="left" style="background-image: url(static/images/cubes/01/left.jpg)"></vz-cubeface>
<vz-cubeface data-face="right" style="background-image: url(static/images/cubes/01/right.jpg)"></vz-cubeface>
</vz-cubepivot>
</vz-cube>
</section> -->
<section>
<vz-cube id="cube">
<vz-cubepivot>
<vz-cubeface data-face="top" style="background-image: url(static/images/cubes/02/top.jpg)"></vz-cubeface>
<vz-cubeface data-face="bottom" style="background-image: url(static/images/cubes/02/bottom.jpg)"></vz-cubeface>
<vz-cubeface data-face="front" style="background-image: url(static/images/cubes/02/front.jpg)"></vz-cubeface>
<vz-cubeface data-face="back" style="background-image: url(static/images/cubes/02/back.jpg)"></vz-cubeface>
<vz-cubeface data-face="left" style="background-image: url(static/images/cubes/02/left.jpg)"></vz-cubeface>
<vz-cubeface data-face="right" style="background-image: url(static/images/cubes/02/right.jpg)"></vz-cubeface>
<vz-cube-feature id="f1" title="Feature 1" yaw="0" pitch="0"></vz-cube-feature>
<vz-cube-feature id="f2" title="Feature 2" yaw="20" pitch="20"></vz-cube-feature>
<vz-cube-feature class="ping-pong-on-the-back" title="Right"
yaw="165" pitch="0"></vz-cube-feature>
<vz-cube-feature class="ping-pong-on-the-back" title="Left"
yaw="-165" pitch="0"></vz-cube-feature>
<vz-cube-feature class="ping-pong-on-the-back" title="Right"
yaw="10" pitch="0"></vz-cube-feature>
<vz-cube-feature class="ping-pong-on-the-back" title="Left"
yaw="-10" pitch="0"></vz-cube-feature>
</vz-cubepivot>
</vz-cube>
</section>
<script>
f1.addEventListener('click', e => {
e.preventDefault()
cube.animateTo(e.currentTarget.yaw, e.currentTarget.pitch)
cube.freeze()
cube.zoomIn()
})
f2.addEventListener('click', e => {
e.preventDefault()
cube.animateTo(-e.currentTarget.yaw, -e.currentTarget.pitch, 1000, _ => {
cube.freeze()
cube.zoomIn()
})
})
document.querySelectorAll('.ping-pong-on-the-back').forEach(c => {
c.addEventListener('click', e => {
cube.animateTo(-e.currentTarget.yaw, -e.currentTarget.pitch, 500)
})
})
</script>
</body>
</html>