提交 a387c43d 编写于 作者: M Mr.doob

Added performance.now() polyfill.

上级 9c97ee55
......@@ -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;
}
} )();
}
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册