瀏覽代碼

Merge pull request #20743 from linbingquan/dev-clock

Clock: Clean up.
Mr.doob 4 年之前
父節點
當前提交
14388e461b
共有 1 個文件被更改,包括 8 次插入2 次删除
  1. 8 2
      src/core/Clock.js

+ 8 - 2
src/core/Clock.js

@@ -14,7 +14,7 @@ class Clock {
 
 	start() {
 
-		this.startTime = ( typeof performance === 'undefined' ? Date : performance ).now(); // see #10732
+		this.startTime = now();
 
 		this.oldTime = this.startTime;
 		this.elapsedTime = 0;
@@ -50,7 +50,7 @@ class Clock {
 
 		if ( this.running ) {
 
-			const newTime = ( typeof performance === 'undefined' ? Date : performance ).now();
+			const newTime = now();
 
 			diff = ( newTime - this.oldTime ) / 1000;
 			this.oldTime = newTime;
@@ -65,4 +65,10 @@ class Clock {
 
 }
 
+function now() {
+
+	return ( typeof performance === 'undefined' ? Date : performance ).now(); // see #10732
+
+}
+
 export { Clock };