diff --git a/src/Three.js b/src/Three.js index da6b4325649e9454cd95ffdb9f0d874c1e89118d..3ba490e9609a014a7eda1d646ae03703cc268a5d 100644 --- a/src/Three.js +++ b/src/Three.js @@ -62,7 +62,31 @@ if ( self.requestAnimationFrame === undefined || self.cancelAnimationFrame === u } - }() ); + } )(); + +} + +// + +if ( self.performance === undefined ) { + + self.performance = {}; + +} + +if ( self.performance.now === undefined ) { + + ( function () { + + var start = Date.now(); + + self.performance.now = function () { + + return Date.now() - start; + + } + + } )(); } diff --git a/src/core/Clock.js b/src/core/Clock.js index f259a921e7a953556586f78f823c559c09997ff7..21d664cf73e2f37965f1343344c078496216aff8 100644 --- a/src/core/Clock.js +++ b/src/core/Clock.js @@ -18,17 +18,9 @@ THREE.Clock.prototype = { constructor: THREE.Clock, - _now: function () { - - return self.performance !== undefined && self.performance.now !== undefined - ? self.performance.now() - : Date.now(); - - }, - start: function () { - this.startTime = this._now(); + this.startTime = self.performance.now(); this.oldTime = this.startTime; this.running = true; @@ -61,7 +53,7 @@ THREE.Clock.prototype = { if ( this.running ) { - var newTime = this._now(); + var newTime = self.performance.now(); diff = 0.001 * ( newTime - this.oldTime ); this.oldTime = newTime;