diff --git a/bkcore.coffee/Timer.coffee b/bkcore.coffee/Timer.coffee new file mode 100644 index 0000000..7d5da39 --- /dev/null +++ b/bkcore.coffee/Timer.coffee @@ -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 \ No newline at end of file diff --git a/bkcore.coffee/Timer.js b/bkcore.coffee/Timer.js new file mode 100644 index 0000000..b2b4b63 --- /dev/null +++ b/bkcore.coffee/Timer.js @@ -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); diff --git a/index.html b/index.html index fb9ecbf..8794bd3 100644 --- a/index.html +++ b/index.html @@ -32,16 +32,16 @@
- - - - - - - - - - + + + + + + + + + + diff --git a/js/DAT.GUI.min.js b/libs/DAT.GUI.min.js similarity index 100% rename from js/DAT.GUI.min.js rename to libs/DAT.GUI.min.js diff --git a/js/Detector.js b/libs/Detector.js similarity index 100% rename from js/Detector.js rename to libs/Detector.js diff --git a/js/ShaderExtras.js b/libs/ShaderExtras.js similarity index 100% rename from js/ShaderExtras.js rename to libs/ShaderExtras.js diff --git a/js/Stats.js b/libs/Stats.js similarity index 100% rename from js/Stats.js rename to libs/Stats.js diff --git a/js/Three.dev.js b/libs/Three.dev.js similarity index 100% rename from js/Three.dev.js rename to libs/Three.dev.js diff --git a/js/postprocessing/BloomPass.js b/libs/postprocessing/BloomPass.js similarity index 100% rename from js/postprocessing/BloomPass.js rename to libs/postprocessing/BloomPass.js diff --git a/js/postprocessing/DotScreenPass.js b/libs/postprocessing/DotScreenPass.js similarity index 100% rename from js/postprocessing/DotScreenPass.js rename to libs/postprocessing/DotScreenPass.js diff --git a/js/postprocessing/EffectComposer.js b/libs/postprocessing/EffectComposer.js similarity index 100% rename from js/postprocessing/EffectComposer.js rename to libs/postprocessing/EffectComposer.js diff --git a/js/postprocessing/FilmPass.js b/libs/postprocessing/FilmPass.js similarity index 100% rename from js/postprocessing/FilmPass.js rename to libs/postprocessing/FilmPass.js diff --git a/js/postprocessing/MaskPass.js b/libs/postprocessing/MaskPass.js similarity index 100% rename from js/postprocessing/MaskPass.js rename to libs/postprocessing/MaskPass.js diff --git a/js/postprocessing/RenderPass.js b/libs/postprocessing/RenderPass.js similarity index 100% rename from js/postprocessing/RenderPass.js rename to libs/postprocessing/RenderPass.js diff --git a/js/postprocessing/SavePass.js b/libs/postprocessing/SavePass.js similarity index 100% rename from js/postprocessing/SavePass.js rename to libs/postprocessing/SavePass.js diff --git a/js/postprocessing/ShaderPass.js b/libs/postprocessing/ShaderPass.js similarity index 100% rename from js/postprocessing/ShaderPass.js rename to libs/postprocessing/ShaderPass.js diff --git a/js/postprocessing/TexturePass.js b/libs/postprocessing/TexturePass.js similarity index 100% rename from js/postprocessing/TexturePass.js rename to libs/postprocessing/TexturePass.js