Started CoffeeScript port. Moved third-party libs from js/ to libs/.

This commit is contained in:
BKcore
2012-12-20 14:31:13 +01:00
parent 3e8d91af91
commit 52e6bd0b93
17 changed files with 173 additions and 10 deletions
+71
View File
@@ -0,0 +1,71 @@
class Timer
constructor: ()->
@time =
start: 0
current: 0
previous: 0
elapsed: 0
delta: 0
@active = false
start: ()->
now = (new Date).getTime()
@time.start = now
@time.current = now
@time.previous = now
@time.elapsed = 0
@time.delta = 0
@active = true
pause: (doPause)->
@active = not doPause
update: ()->
if not active then return
now = (new Date).getTime()
@time.current = now
@time.elapsed = @time.current - @time.start
@time.delta = now - @time.previous
@time.previous = now
getElapsedTime: ()->
return @constructor.msToTime(@time.elapsed)
@msToTime: (t)->
ms = t%1000
s = Math.floor((t/1000)%60)
m = Math.floor((t/60000)%60)
h = Math.floor(t/3600000)
return {h:h, m:m, s:s, ms,ms}
@msToTimeString: (t)->
time = @msToTime(t)
time.h = @zfill(time.h, 2)
time.m = @zfill(time.m, 2)
time.s = @zfill(time.s, 2)
time.ms = @zfill(time.ms, 4)
return time
@zfill: (num, size)->
len = size - num.toString().length
return if len > 0 then new Array(len+1).join('0') + num else num.toString()
exports = exports ? @
exports.bkcore.Timer = Timer
+92
View File
@@ -0,0 +1,92 @@
// Generated by CoffeeScript 1.4.0
(function() {
var Timer, exports;
Timer = (function() {
function Timer() {
this.time = {
start: 0,
current: 0,
previous: 0,
elapsed: 0,
delta: 0
};
this.active = false;
}
Timer.prototype.start = function() {
var now;
now = (new Date).getTime();
this.time.start = now;
this.time.current = now;
this.time.previous = now;
this.time.elapsed = 0;
this.time.delta = 0;
return this.active = true;
};
Timer.prototype.pause = function(doPause) {
return this.active = !doPause;
};
Timer.prototype.update = function() {
var now;
if (!active) {
return;
}
now = (new Date).getTime();
this.time.current = now;
this.time.elapsed = this.time.current - this.time.start;
this.time.delta = now - this.time.previous;
return this.time.previous = now;
};
Timer.prototype.getElapsedTime = function() {
return this.constructor.msToTime(this.time.elapsed);
};
Timer.msToTime = function(t) {
var h, m, ms, s;
ms = t % 1000;
s = Math.floor((t / 1000) % 60);
m = Math.floor((t / 60000) % 60);
h = Math.floor(t / 3600000);
return {
h: h,
m: m,
s: s,
ms: ms,
ms: ms
};
};
Timer.msToTimeString = function(t) {
var time;
time = this.msToTime(t);
time.h = this.zfill(time.h, 2);
time.m = this.zfill(time.m, 2);
time.s = this.zfill(time.s, 2);
time.ms = this.zfill(time.ms, 4);
return time;
};
Timer.zfill = function(num, size) {
var len;
len = size - num.toString().length;
if (len > 0) {
return new Array(len + 1).join('0') + num;
} else {
return num.toString();
}
};
return Timer;
})();
exports = exports != null ? exports : this;
exports.bkcore.Timer = Timer;
}).call(this);
+10 -10
View File
@@ -32,16 +32,16 @@
<div id="overlay"></div>
<div id="main"></div>
<script src="js/Three.dev.js"></script>
<script src="js/ShaderExtras.js"></script>
<script src="js/postprocessing/EffectComposer.js"></script>
<script src="js/postprocessing/RenderPass.js"></script>
<script src="js/postprocessing/BloomPass.js"></script>
<script src="js/postprocessing/ShaderPass.js"></script>
<script src="js/postprocessing/MaskPass.js"></script>
<script src="js/Detector.js"></script>
<script src="js/Stats.js"></script>
<script src="js/DAT.GUI.min.js"></script>
<script src="libs/Three.dev.js"></script>
<script src="libs/ShaderExtras.js"></script>
<script src="libs/postprocessing/EffectComposer.js"></script>
<script src="libs/postprocessing/RenderPass.js"></script>
<script src="libs/postprocessing/BloomPass.js"></script>
<script src="libs/postprocessing/ShaderPass.js"></script>
<script src="libs/postprocessing/MaskPass.js"></script>
<script src="libs/Detector.js"></script>
<script src="libs/Stats.js"></script>
<script src="libs/DAT.GUI.min.js"></script>
<script src="bkcore/Timer.js"></script>
<script src="bkcore/ImageData.js"></script>
View File
View File
View File