فهرست منبع

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