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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
<!doctype>
<html>
<head>
<title>rain</title>
<style type="text/css">
* { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }
.mx-object3d { -webkit-transform-style: preserve-3d; transform-style: preserve-3d; }
html,body{ margin: 0; padding: 0; width:100%;height:100%;}
body {
-webkit-perspective: 600px;
-moz-perspective: 600px;
perspective: 1000px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
overflow:hidden;
position:fixed;
top:0;
left:0;
width:100%;
height:100%;
cursor:move;
font-family:sans-serif;
background-color: white;
}
.text {
font-size: 100px;
color: white;
}
#flip{
display:none;
}
#bg {
pointer-events: none;
position: fixed;
width: 100%;
top: 0;
height: 100%;
z-index: 0;
cursor:move;
left:0;
}
</style>
<body>
<div id="info"></div>
<div id="flip">FLIP</div>
<div id="bg"></div>
</body>
<script type="text/javascript" src="http://okfoc.us/beentrill/shirts/assets/js/vendor/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="http://okfoc.us/beentrill/shirts/assets/js/vendor/jquery-nodoubletapzoom.js"></script>
<script type="text/javascript" src="http://okfoc.us/beentrill/shirts/assets/js/vendor/mx.min.js"></script>
<script type="text/javascript" src="http://okfoc.us/beentrill/shirts/assets/js/vendor/mx.gyroControl.js"></script>
<script type="text/javascript" src="http://okfoc.us/beentrill/shirts/assets/js/vendor/mx.rotationControl.js"></script>
<script type="text/javascript" src="http://okfoc.us/beentrill/shirts/assets/js/vendor/mx.scene.js"></script>
<script type="text/javascript" src="http://asdf.us/dither/js/util.js"></script>
<script type="text/javascript" src="http://okfoc.us/beentrill/shirts/assets/js/image.js"></script>
<script type="text/javascript">
(function( ua ) {
ua = ua.toLowerCase();
var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
/(msie) ([\w.]+)/.exec( ua ) ||
0 > ua.indexOf("compatible") && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
[];
var matched = {
browser: match[ 1 ] || "",
version: match[ 2 ] || "0"
};
browser = {};
if ( matched.browser ) {
browser[ matched.browser ] = true;
browser.version = matched.version;
}
// Chrome is Webkit, but Webkit is also Safari.
if ( browser.chrome ) {
browser.webkit = true;
} else if ( browser.webkit ) {
browser.safari = true;
}
$.browser = browser;
return browser;
})( navigator.userAgent );
$(window).load(function(){
scene.init();
});
var scene = new function(){}
scene.init = function(){
MX.rotationUnit = 'deg'
scene.control = new MX.RotationControl()
// scene.control.disableY = true
scene.control.lowerBoundY = -50
scene.control.upperBoundY = 50
scene.control.lowerBoundX = -30
scene.control.upperBoundX = 30
scene.parent = new MX.Object3D("#scene")
scene.parent.addTo("#info");
scene.parent.perspective = 600
scene.parent.update()
scene.parent.rotationY = -5
scene.parent.rotationX = 5
hashtags.init()
// if (is_mobile) {
// hashtags.parent.scale = 0.8
// }
$("#flip").click(function(){
scene.flip()
})
scene.control.init(scene.parent)
scene.animate(0)
}
scene.animate = function (t) {
requestAnimationFrame(scene.animate)
t /= 500
scene.control.update()
scene.parent.update()
hashtags.animate(t)
}
scene.reverse = false
scene.flip = function(){
scene.reverse = ! scene.reverse
var rotation = scene.control.rotationY % 180;
if (scene.reverse) {
scene.control.rotationY = scene.control.rotationY - rotation + 180 * 3
}
else {
scene.control.rotationY = scene.control.rotationY - rotation - 180 * 3
}
}
var hashtags = new function(){}
hashtags.init = function(){
this.parent = new MX.Object3D('.mx-rapper')
this.parent.addTo(scene.parent)
this.children = []
var count = $.browser.mozilla ? 50 : 100
var w = window.innerWidth, h = window.innerHeight
for (var i = 0; count > i; i++) {
var hash = new MX.Image({
src: 'http://upload.wikimedia.org/wikipedia/commons/thumb/4/44/Cannabis_leaf_2.svg/200px-Cannabis_leaf_2.svg.png',
scale: 0.5
})
var theta = TWO_PI*random()
hash.x = sin(theta) * randrange(h/2, h*1.2)
hash.y = Math.cos(TWO_PI*random()) * randrange(h/2, h*1.2)
hash.z = randrange(z_min, z_max)
hash.rotationZ = random()*360
hash.el.style.opacity = 1.0
hash.dz = randrange(-100,-10)
hash.drz = randrange(-1,1)/2
hash.addTo(this.parent);
hash.update()
}
}
hashtags.show = function(){
hashtags.parent.el.style.opacity = 1
}
hashtags.hide = function(){
hashtags.parent.el.style.opacity = 0
}
var z_min = -1000, z_fade = 2000, z_max = 4000
hashtags.animate = function (t) {
scene.control.rotationZ += 1
var dt = ~Math.sin(t) * 0.1
hashtags.parent.children.forEach(function(item){
item.z -= ~~(item.dz*dt)
item.rotationZ += item.drz
if (z_min > item.z) item.z = z_max
if (item.z >= z_max-z_fade) {
item.el.style.opacity = lerp((z_max-item.z)/z_fade, 0.0, 1.0)
}
item.update()
})
}
</script>
</html>
|