|
2 | 2 | original commented source there. */
|
3 | 3 | (function(){
|
4 | 4 | "use strict";
|
5 |
| - var canvas, ref$, width, height, k, ref1$, v, x0$, arr, rotation, e, currentRot, fov, distance, symmetric, x1$, minVal, ref2$, x2$, maxVal, reclamp, ctx, buffers, latBands, lonBands, noiseTex, noiseTransport, orthogonalLic, advection, blend, setupBuffers, numTriangles, p, mod, frame, initial, playing, x3$, x4$, draw, oceanField, landTextures, texturesToLoad, totalTextures, maybeDraw, landMask, pad, i, nightTexture, pointUnder, x5$, out$ = typeof exports != 'undefined' && exports || this; |
| 5 | + var canvas, ref$, width, height, k, ref1$, v, x0$, arr, rotation, e, currentRot, fov, distance, symmetric, x1$, minVal, ref2$, x2$, maxVal, reclamp, ctx, buffers, latBands, lonBands, noiseTex, noiseTransport, orthogonalLic, advection, blend, setupBuffers, numTriangles, p, mod, frame, initial, playing, x3$, x4$, draw, oceanField, landTextures, texturesToLoad, totalTextures, maybeDraw, pad, i, landMask, nightTexture, pointUnder, x5$, out$ = typeof exports != 'undefined' && exports || this; |
6 | 6 | canvas = document.getElementById('canvas');
|
7 | 7 | ref$ = document.documentElement, canvas.width = ref$.clientWidth, canvas.height = ref$.clientHeight;
|
8 | 8 | width = canvas.width, height = canvas.height;
|
@@ -122,7 +122,7 @@ original commented source there. */
|
122 | 122 | minVal.value = 1 - parseFloat(this.value);
|
123 | 123 | }
|
124 | 124 | });
|
125 |
| - addWheelListener(document.body, function(it){ |
| 125 | + addWheelListener(canvas, function(it){ |
126 | 126 | fov = clamp(fov + it.deltaY / Math.abs(it.deltaY), 1, 100);
|
127 | 127 | });
|
128 | 128 | ctx = document.createElement('canvas').getContext('2d');
|
@@ -249,11 +249,12 @@ original commented source there. */
|
249 | 249 | return (num % base + base) % base;
|
250 | 250 | };
|
251 | 251 | function loadOceanCurrentCommon(program){
|
252 |
| - var time, cur, last, next, timeVal, x3$; |
| 252 | + var slicesAvailable, time, cur, last, next, timeVal, x3$; |
| 253 | + slicesAvailable = oceanField.length; |
253 | 254 | time = parseFloat($('time').value);
|
254 | 255 | cur = Math.floor(time / 2);
|
255 |
| - last = mod(cur - 1, 8); |
256 |
| - next = mod(cur + 1, 8); |
| 256 | + last = mod(cur - 1, slicesAvailable); |
| 257 | + next = mod(cur + 1, slicesAvailable); |
257 | 258 | loadTexture(program, oceanField[cur], 'curOcean', 0);
|
258 | 259 | loadTexture(program, oceanField[last], 'prevOcean', 1);
|
259 | 260 | loadTexture(program, oceanField[next], 'nextOcean', 2);
|
@@ -287,13 +288,15 @@ original commented source there. */
|
287 | 288 | $('play').disabled = false;
|
288 | 289 | });
|
289 | 290 | out$.draw = draw = function(){
|
290 |
| - var t, speed, newT, x5$, x6$, x7$, x8$, x9$, rot, modelView, useDay, monthNo, nextNo, x10$, x11$, x12$, x13$, x14$, x15$, x16$; |
| 291 | + var slicesAvailable, t, speed, newT, x5$, x6$, x7$, x8$, x9$, rot, modelView, useDay, monthNo, nextNo, x10$, x11$, x12$, x13$, x14$, x15$, x16$; |
| 292 | + slicesAvailable = oceanField.length * 2; |
291 | 293 | t = parseFloat($('time').value);
|
292 | 294 | if (playing) {
|
293 | 295 | speed = parseFloat($('speed').value);
|
294 |
| - newT = mod(t + speed, 16); |
| 296 | + newT = mod(t + speed, slicesAvailable); |
295 | 297 | $('time').value = newT;
|
296 | 298 | t = newT;
|
| 299 | + updateTimestamp(); |
297 | 300 | }
|
298 | 301 | loadPlainQuadProgram(p.noiseTransport, noiseTransport.framebuffer);
|
299 | 302 | loadIsWater(p.noiseTransport);
|
@@ -395,45 +398,78 @@ original commented source there. */
|
395 | 398 | }
|
396 | 399 | oceanField = [];
|
397 | 400 | landTextures = [];
|
398 |
| - texturesToLoad = totalTextures = 1 + 1 + 12 + 1; |
| 401 | + texturesToLoad = totalTextures = 2 + 1 + 12 + 1; |
399 | 402 | maybeDraw = function(){
|
400 |
| - $('load-progress').value = 1 - totalTextures / texturesToLoad; |
| 403 | + $('load-progress').value = 1 - texturesToLoad / totalTextures; |
401 | 404 | if (texturesToLoad === 0) {
|
402 | 405 | $('loading').hidden = true;
|
403 | 406 | $('load-progress').value = 0;
|
| 407 | + $('time').setAttribute('max', oceanField.length * 2 - 0.01); |
| 408 | + $('time').value = 0; |
404 | 409 | draw();
|
405 | 410 | }
|
406 | 411 | };
|
407 |
| - loadImage('packed16.png', function(){ |
408 |
| - var c, ref$, ctx, i$, ref1$, len$, y, j$, ref2$, len1$, x; |
409 |
| - c = (ref$ = document.createElement('canvas'), ref$.width = this.width, ref$.height = this.height, ref$); |
| 412 | + pad = function(it){ |
| 413 | + if (it >= 10) { |
| 414 | + return it; |
| 415 | + } else { |
| 416 | + return "0" + it; |
| 417 | + } |
| 418 | + }; |
| 419 | + function splitPacked(img, idx){ |
| 420 | + var c, ref$, ctx, start, n, i$, ref1$, len$, y, j$, ref2$, len1$, x; |
| 421 | + c = (ref$ = document.createElement('canvas'), ref$.width = img.width, ref$.height = img.height, ref$); |
410 | 422 | ctx = c.getContext('2d');
|
411 |
| - ctx.drawImage(this, 0, 0); |
| 423 | + ctx.drawImage(img, 0, 0); |
| 424 | + start = idx * 8; |
| 425 | + n = 0; |
412 | 426 | for (i$ = 0, len$ = (ref1$ = [0, 512, 1024, 1536]).length; i$ < len$; ++i$) {
|
413 | 427 | y = ref1$[i$];
|
414 | 428 | for (j$ = 0, len1$ = (ref2$ = [0, 1024]).length; j$ < len1$; ++j$) {
|
415 | 429 | x = ref2$[j$];
|
416 |
| - oceanField.push(setTexture(gl.createTexture(), ctx.getImageData(x, y, 1024, 512))); |
| 430 | + oceanField[start + n] = setTexture(gl.createTexture(), ctx.getImageData(x, y, 1024, 512)); |
| 431 | + ++n; |
417 | 432 | }
|
418 | 433 | }
|
419 | 434 | --texturesToLoad;
|
420 |
| - maybeDraw(); |
| 435 | + return maybeDraw(); |
| 436 | + } |
| 437 | + for (i = 0; i < 2; ++i) { |
| 438 | + (fn$.call(this, i)); |
| 439 | + } |
| 440 | + $('load-more').addEventListener('click', function(){ |
| 441 | + var i; |
| 442 | + totalTextures = 13; |
| 443 | + texturesToLoad = 13; |
| 444 | + $('loading').hidden = false; |
| 445 | + $('load-progress').value = 0; |
| 446 | + for (i = 2; i < 15; ++i) { |
| 447 | + (fn$.call(this, i)); |
| 448 | + } |
| 449 | + function fn$(i){ |
| 450 | + loadImage("packed-" + pad(i) + ".png", function(){ |
| 451 | + splitPacked(this, i); |
| 452 | + }); |
| 453 | + } |
421 | 454 | });
|
| 455 | + $('time').addEventListener('input', updateTimestamp); |
| 456 | + function updateTimestamp(){ |
| 457 | + var months, years, yMonths, x5$, date; |
| 458 | + months = parseFloat($('time').value); |
| 459 | + years = Math.floor(months / 12); |
| 460 | + yMonths = Math.floor(months - years * 12); |
| 461 | + x5$ = date = new Date; |
| 462 | + x5$.setFullYear(1991 + years, yMonths, 1); |
| 463 | + return $('timestamp').textContent = date.getFullYear() + "-" + pad(date.getMonth() + 1); |
| 464 | + } |
422 | 465 | landMask = gl.createTexture();
|
423 | 466 | loadImage('land-mask.png', function(){
|
424 | 467 | setTexture(landMask, this);
|
425 | 468 | --texturesToLoad;
|
426 | 469 | maybeDraw();
|
427 | 470 | });
|
428 |
| - pad = function(it){ |
429 |
| - if (it >= 10) { |
430 |
| - return it; |
431 |
| - } else { |
432 |
| - return "0" + it; |
433 |
| - } |
434 |
| - }; |
435 | 471 | for (i = 1; i <= 12; ++i) {
|
436 |
| - loadImage("blue-marble-" + pad(i) + ".jpg", fn$); |
| 472 | + (fn1$.call(this, i)); |
437 | 473 | }
|
438 | 474 | nightTexture = gl.createTexture();
|
439 | 475 | loadImage('black-marble.jpg', function(){
|
@@ -487,9 +523,16 @@ original commented source there. */
|
487 | 523 | x5$.addEventListener('mouseup', stop);
|
488 | 524 | x5$.addEventListener('mouseleave', stop);
|
489 | 525 | });
|
490 |
| - function fn$(){ |
491 |
| - landTextures.push(setTexture(gl.createTexture(), this)); |
492 |
| - --texturesToLoad; |
493 |
| - maybeDraw(); |
| 526 | + function fn$(i){ |
| 527 | + loadImage("packed-" + pad(i) + ".png", function(){ |
| 528 | + splitPacked(this, i); |
| 529 | + }); |
| 530 | + } |
| 531 | + function fn1$(i){ |
| 532 | + loadImage("blue-marble-" + pad(i) + ".jpg", function(){ |
| 533 | + landTextures[i - 1] = setTexture(gl.createTexture(), this); |
| 534 | + --texturesToLoad; |
| 535 | + maybeDraw(); |
| 536 | + }); |
494 | 537 | }
|
495 | 538 | }).call(this);
|
0 commit comments