Просмотр исходного кода

Clock (#8564)

* Make Clock work on iOS without polyfill.

* Clock: Avoid adding up unnecessary rounding error.

0.001 does not have a finite binary float representation.
tschw 9 лет назад
Родитель
Сommit
cad40e6ae8
1 измененных файлов с 3 добавлено и 3 удалено
  1. 3 3
      src/core/Clock.js

+ 3 - 3
src/core/Clock.js

@@ -20,7 +20,7 @@ THREE.Clock.prototype = {
 
 	start: function () {
 
-		this.startTime = performance.now();
+		this.startTime = ( performance || Date ).now();
 
 		this.oldTime = this.startTime;
 		this.running = true;
@@ -53,9 +53,9 @@ THREE.Clock.prototype = {
 
 		if ( this.running ) {
 
-			var newTime = performance.now();
+			var newTime = ( performance || Date ).now();
 
-			diff = 0.001 * ( newTime - this.oldTime );
+			diff = ( newTime - this.oldTime ) / 1000;
 			this.oldTime = newTime;
 
 			this.elapsedTime += diff;