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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
|
var base_href = "http://okfocus.s3.amazonaws.com/2h/"
var box_images = shuffle([
"1.gif", "2.gif", "3.gif", "4.gif", "5.gif",
// "dies2.gif", "dies3.gif",
"6.gif", "7.gif", "8.gif", "9.gif",
"12.gif", "13.gif", "14.gif", "15.gif",
"16.gif", "17.gif", // "CCP-GIF.gif", "dies1.gif",
])
var strips = []
var done_loading = false, menu_open = false, entry_open = false
var environment = {}, hashes = {}
environment.init = function(){
var loader = new Loader(function(){
environment.ready()
})
loader.preloadImages(box_images.map(function(url){
return base_href + url
}))
loader.ready()
}
environment.ready = function(){
if (window.innerWidth < 500) document.body.classList.add('mobile')
controls = new MX.OrbitCamera({
radius: 1000,
radiusRange: [ 10, 2000 ],
rotationX: PI/2,
rotationY: PI,
wheelEase: 20,
ease: 100
})
controls.init()
$('.cat').click( function(){
$('.cat').removeClass('active')
$('.sub').removeClass('active')
$(this).addClass('active')
$(this).next('.sub').addClass('active')
})
$("nav a").click(function(e){
e.preventDefault()
var hash = "#" + $(this).data("hash")
if (done_loading && window.location.hash == hash) return
window.location.hash = hash
$("nav a.active").removeClass("active")
$(this).addClass("active")
open_entry()
var page = $(this).attr("href")
if (page.indexOf("#") !== -1) page = "#"
$("#entry_container").removeClass("visible")
var $loader = $("<div>")
$loader.load(page + " .entry", function(){
display_entry($loader.children()[0])
})
})
$("nav .about").click(function(e){
e.preventDefault()
if (done_loading && window.location.hash == "#about") return
window.location.hash = "#about"
$("nav a.active").removeClass("active")
open_entry()
$("#entry_container").removeClass("visible")
var $loader = $("<div>")
$loader.load("about .entry", function(){
display_entry($loader.children()[0])
})
})
$("nav .contact").click(function(e){
e.preventDefault()
if (done_loading && window.location.hash == "#contact") return
window.location.hash = "#contact"
$("nav a.active").removeClass("active")
open_entry()
$("#entry_container").removeClass("visible")
var $loader = $("<div>")
$loader.load("contact .entry", function(){
display_entry($loader.children()[0])
})
})
$("nav .index").click(function(e){
e.preventDefault()
if (done_loading && window.location.hash == "#index") return
window.location.hash = "#index"
$("nav a.active").removeClass("active")
open_entry()
$("#entry_container").removeClass("visible")
var $loader = $("<div>")
$loader.load("all .entry", function(){
display_entry($loader.children()[0])
})
})
$(".toggleRapper").click(toggle_menu)
$(".toplogo").click(hide_entry)
$(document).on("click", ".project", function(){
var hash = as_hash( $(this).find("span").text() )
load_hash(hash)
})
$(window).mousedown(function(e){
if (! menu_open) {
controls.pause()
controls.opt.ease = 10
}
})
$(window).mouseup(function(e){
if (! menu_open) {
controls.pause()
}
controls.opt.ease = 100
})
$(window).mousemove(function(e){
if (menu_open || controls.dragging) return
var x = e.pageX/window.innerWidth
var xmid = pow( abs( 2 * (x - 0.5) ), 1/2 )
var y = e.pageY/window.innerHeight
var ymid = pow( abs( 2 * (y - 0.5) ), 1/2 )
var z = dist( xmid, ymid, 0, 0 )
controls.zoomPercent( clamp(z - 0.3, 0, 1) )
controls.move(
(x) * TWO_PI * 4,
PI/2 + (1-y) * TWO_PI * 4
)
})
$("body").removeClass('loading')
var current_hash = window.location.hash.replace("#","")
$("nav a").each(function(){
var key = as_hash(this.innerHTML)
hashes[key] = this
$(this).data("hash", key)
})
hashes['about'] = $("nav .about")
hashes['contact'] = $("nav .contact")
hashes['index'] = $("nav .index")
if (current_hash in hashes) {
toggle_menu()
load_hash(current_hash)
setTimeout(build_scene, 200)
}
else {
build_scene()
}
setTimeout(function(){ done_loading = true }, 200)
// $(".mx-scenery").on("mouseenter", function(e){
// e.stopPropagation()
// $(this).addClass("red")
// })
// $(".mx-scenery").on("mouseleave", function(e){
// e.stopPropagation()
// $(".red").removeClass("red")
// })
$(document).on('webkitfullscreenchange mozfullscreenchange fullscreenchange MSFullscreenChange', function(){
setTimeout(function(){
if (window.innerHeight == screen.height) {
$("html").addClass("full-screen")
}
else {
$("html").removeClass("full-screen")
}
setTimeout(function(){
resize_gallery()
}, 100)
}, 500)
})
}
function build_scene () {
strips.push( new Strip({
images: box_images.slice(0, 5),
x: -100,
y: 100,
rotationY: PI/4,
offset: 100,
}) )
strips.push( new Strip({
images: box_images.slice(5, 10),
x: 100,
y: 100,
rotationX: PI/4,
rotationY: PI/-100,
offset: 200,
}) )
strips.push( new Strip({
images: box_images.slice(10, 15),
x: 0,
y: 100,
z: 100,
rotationY: PI/6,
offset: 300,
}) )
strips.push( new Strip({
images: box_images.slice(15, 20),
x: 0,
y: 100,
z: -50,
rotationX: PI/2,
rotationY: PI/100,
offset: 200,
}) )
strips.forEach(function(strip){ strip.update(0) })
scene.update()
environment.update = environment.updateOnReady
}
var entry_open_time = 0;
function as_hash (txt) {
return txt.replace(/\s/g,'_')
}
function load_hash (hash) {
var $menu = $(hashes[hash])
$(".active").removeClass('active')
$menu.parent().addClass('active')
$menu.parent().prev(".cat").addClass('active')
$menu.trigger("click")
}
function open_entry () {
if (is_mobile) {
$("body").removeClass("menuActive")
}
if (! entry_open) {
entry_open = true
controls.zoom(40)
controls.wheel.lock()
$("#scene").addClass("fade")
setTimeout(function(){ $("#scene").hide() }, 200)
}
entry_open_time = +new Date
$("#entry_container").addClass("fade")
}
function display_entry ($el) {
var now = +new Date
setTimeout(function(){
$("#entry_container").empty().append($el)
$("#entry_container").removeClass("fade")
build_gallery()
if (is_mobile) {
$(".video").each(function(){
load_video( $(this) )
})
}
if (window.location.hash.match(/about|contact|index/)) {
setTimeout(function(){
$(".entry").addClass("ready")
}, 100)
setTimeout(function(){
$(".entry").addClass("done")
}, 600)
}
else {
$(".entry").addClass("ready")
}
}, max(0, 200 - (now - entry_open_time)) + 20)
$("#entry_container").scrollTop(0)
$("#entry_container").addClass("visible")
controls.setZoom(100000)
setTimeout(function(){ controls.zoom(100) }, 100)
}
function hide_entry () {
$("nav .active").removeClass("active")
$("#entry_container").addClass("fade")
setTimeout(function(){
$("#entry_container").empty()
}, 200)
$("#scene").show().removeClass("fade")
controls.zoom(1500)
window.location.hash = "#"
}
function toggle_menu (){
$("body").toggleClass("menuActive")
menu_open = $("body").hasClass("menuActive")
if (! is_mobile) {
$("#entry_container").removeClass("visible")
}
if (menu_open) {
controls.pause()
}
if (! menu_open && entry_open && ! is_mobile) {
entry_open = false
controls.wheel.unlock()
setTimeout(function(){ $("#scene").removeClass("fade") })
$("nav a.active").removeClass("active")
}
if (! menu_open && ! entry_open) {
window.location.hash = "#"
$("#scene").show()
$("#entry_container").empty()
controls.zoom(1500)
$('.cat').removeClass('active')
$('.sub').removeClass('active')
}
}
var gallery = null
function build_gallery () {
videos = []
var $el = $("#entry_container #okgallery")
if (! $el.length) {
gallery = null
return
}
var $next = $el.next(".next")
var $caption = $el.next(".caption")
gallery = new Flickity( "#okgallery", {
cellSelector: '.cell',
cellAlign: 'left',
wrapAround: true,
prevNextButtons: false,
pageDots: true,
setGallerySize: false,
draggable: true,
imagesLoaded: true,
})
$("#okgallery .video").each(function(){
var $play = $('<div class="play"></div>')
var $el = $(this)
$el.append($play)
$play.click(function(e){
e.stopPropagation()
e.preventDefault()
if ($el.hasClass('loaded')) {
var player = $el.data('player')
player.api('play')
}
else {
load_video($el)
}
})
})
$(".caption").click(function(){
fullscreen($(".gallery")[0])
})
gallery.on("cellSelect", function(){
$caption.html( $(gallery.selectedElement).data("caption") )
videos.forEach(function(player){
player.api('pause')
})
})
gallery.on("settle", function(){
$caption.html( $(gallery.selectedElement).data("caption") )
})
gallery.on("staticClick", function(e){
// console.log(e)
var $el = $(e.target)
if ($el.hasClass("play")) {
// load_video($el)
}
else {
next()
}
})
// $next.on("click", next)
function next(){
gallery.next()
}
gallery.loader.on("progress", function(imagesLoaded, loadingImage){
$(loadingImage.img).addClass('loaded')
})
}
function resize_gallery () {
if (! gallery) return;
var isFullscreen = $("html").hasClass("full-screen")
$("#okgallery").find(".cell img").each(function(){
var h = isFullscreen ? window.innerHeight : 0.6 * window.innerHeight
var w = isFullscreen ? "auto" : this.naturalWidth / this.naturalHeight * h
$(this).css({
width: w, height: h,
})
})
$(".flickity-viewport").css("height","")
gallery.resize()
}
var videos = []
function load_video ($el) {
if ($el.hasClass('loaded')) { return }
$el.addClass('loaded')
var vimeo_id = $el.data("video").match(/\d+/)[0]
var $embed = $('<iframe src="https://player.vimeo.com/video/' + vimeo_id + '?autoplay=1&title=0&byline=0&portrait=0" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>')
$el.append($embed)
var $mask = $('<div class="mask"></div>')
$el.append($mask)
var player = $f( $el.find("iframe")[0] )
$el.data('player', player)
player.addEvent('ready', function(){
player.addEvent('play', function(){
$el.addClass('playing')
})
player.addEvent('pause', function(){
$el.removeClass('playing')
})
})
videos.push(player)
}
environment.update = noop
environment.updateOnReady = function(t){
// strips.forEach(function(strip){ strip.update(t) })
controls.delta( menu_open ? 0 : 1/16, 0)
scene.update()
controls.update()
}
var titles = [
"BARNEY'S, GAGA CONSTELLATION",
"CCP GAMES, EVE ONLINE",
"DIESEL ACCESSORIES",
"DIESEL CAMPAIGN FW13/SS14",
"DIESEL CAMPAIGN FW14",
"#DIESELREBOOT",
"#DIESELTRIBUTE",
"DIESEL JOGG JEANS",
"DIESEL WATCHES",
'MAC, "UNTITLED, SELF-PORTRAIT"',
"MUGLER, BROTHERS OF ARCADIA",
"MUGLER, LADY GAGA",
"MUGLER, MEN’S FW11",
"NICOLA’S, HO HO HO CHRISTMAS SHOP",
"NICOLA'S, LANE CRAWFORD",
"NICOLA’S, NEW YORK"
]
var Strip = function( opt ){
this.opt = opt
var root = this.root = new MX.Object3D ()
root.x = opt.x || 0
root.y = opt.y || 0
root.z = opt.z || 0
root.rotationX = opt.rotationX || 0
root.rotationY = opt.rotationY || 0
root.rotationZ = opt.rotationZ || 0
root.addTo(scene)
var prev = root
this.els = opt.images.map(function(url, i){
var el = new MX.Image({
src: base_href + url,
onload: function(img){
}
})
$(el.el).attr("data-title", choice(titles))
el.setCSSTransformOrigin( "50% 100%" )
el.addTo(prev)
el.update()
prev = el
return el
})
}
Strip.prototype.update = function(t){
var count = this.els.length
var offset = this.opt.offset
t += offset
// this.root.rotationZ = t/10000
this.els.forEach(function(el, i){
el.rotationX = i/count * Math.PI * 2
el.skewY = cos( (1 + i) * 2 * Math.PI * t/100000 + 100 ) / 10
el.y = el.height / 2
})
}
|