浏览代码

Implemented performance.now() in Clock. Closes #2975.

Mr.doob 12 年之前
父节点
当前提交
b13ec20b24
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      src/core/Clock.js

+ 3 - 3
src/core/Clock.js

@@ -16,7 +16,7 @@ THREE.Clock = function ( autoStart ) {
 
 
 THREE.Clock.prototype.start = function () {
 THREE.Clock.prototype.start = function () {
 
 
-	this.startTime = Date.now();
+	this.startTime = performance.now !== undefined ? performance.now() : Date.now();
 	this.oldTime = this.startTime;
 	this.oldTime = this.startTime;
 
 
 	this.running = true;
 	this.running = true;
@@ -52,7 +52,7 @@ THREE.Clock.prototype.getDelta = function () {
 
 
 	if ( this.running ) {
 	if ( this.running ) {
 
 
-		var newTime = Date.now();
+		var newTime = performance.now !== undefined ? performance.now() : Date.now();
 		diff = 0.001 * ( newTime - this.oldTime );
 		diff = 0.001 * ( newTime - this.oldTime );
 		this.oldTime = newTime;
 		this.oldTime = newTime;
 
 
@@ -62,4 +62,4 @@ THREE.Clock.prototype.getDelta = function () {
 
 
 	return diff;
 	return diff;
 
 
-};
+};