Skip to content

Commit f526556

Browse files
committed
refactor timer
1 parent 09fc11b commit f526556

File tree

5 files changed

+30
-51
lines changed

5 files changed

+30
-51
lines changed

README.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,25 @@ Paper-cli 是什么?
106106

107107
- [ ] [支持发布到微信小游戏](https://github.com/egret-labs/egret3d/issues/5)
108108
- [x] [支持粒子系统](https://github.com/egret-labs/egret3d/issues/4)
109-
- [ ] [通过修改 index.html 中的 data-show-fps 显示和隐藏帧率面板](https://github.com/egret-labs/egret3d/issues/7)
110109
- [x] 修复 paper-cli 在特定情况下的 BUG
111110
- [x] [修复特定情况下无法执行 paper install egret3d 的BUG](https://github.com/egret-labs/egret3d/issues/6)
112111
- [x] [修复MacOS / Linux 系统上无法执行paper create helloworld 的 BUG](https://github.com/egret-labs/egret3d/issues/8)
113112
- [ ] 更详细的教程文档
114113

115114

115+
116+
0.10 ( 2018.6.11 )
117+
------------------------
118+
- [ ] [通过修改 index.html 中的 data-show-fps 显示和隐藏帧率面板](https://github.com/egret-labs/egret3d/issues/7)
119+
- [ ] [重构声音系统](https://github.com/egret-labs/egret3d/issues/3)
120+
121+
116122
1.0 ( 2018.7 )
117123
----------------------
118124

119125
- [ ] 更完善的材质系统
120126
- [ ] 更完善的碰撞和物理系统
121127
- [ ] 向部分开发者提供 Egret3D 编辑器的内测版,代号“Paper”
122-
- [ ] [重构声音系统](https://github.com/egret-labs/egret3d/issues/3)
123128
- [ ] 性能优化
124129
- [ ] 统一 paper 命令行与 egret 命令行
125130

bin/egret3d.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -2119,7 +2119,6 @@ declare namespace paper {
21192119
private static _unscaledDeltaTime;
21202120
static initialize(): void;
21212121
static update(timer?: number): void;
2122-
static readonly now: number;
21232122
static readonly frameCount: number;
21242123
static readonly time: number;
21252124
static readonly unscaledTime: number;

bin/egret3d.js

+2-15
Original file line numberDiff line numberDiff line change
@@ -4039,28 +4039,15 @@ var paper;
40394039
function Time() {
40404040
}
40414041
Time.initialize = function () {
4042-
this._lastTimer = this._beginTimer = this.now;
4042+
this._lastTimer = this._beginTimer = Date.now() * 0.001;
40434043
};
40444044
Time.update = function (timer) {
4045-
var now = timer || this.now;
4045+
var now = timer || Date.now() * 0.001;
40464046
this._frameCount += 1;
40474047
this._unscaledTime = now - this._beginTimer;
40484048
this._unscaledDeltaTime = now - this._lastTimer;
40494049
this._lastTimer = now;
40504050
};
4051-
Object.defineProperty(Time, "now", {
4052-
get: function () {
4053-
if (window.performance) {
4054-
return window.performance.now() * 0.001;
4055-
}
4056-
else if (Date.now) {
4057-
return Date.now() * 0.001;
4058-
}
4059-
return new Date().getTime() * 0.001;
4060-
},
4061-
enumerable: true,
4062-
configurable: true
4063-
});
40644051
Object.defineProperty(Time, "frameCount", {
40654052
get: function () {
40664053
return this._frameCount;

bin/egret3d.min.js

+13-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

egret3d/ecs/core/Time.ts

+8-20
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,28 @@ namespace paper {
22

33
export class Time {
44

5-
public static timeScale: number = 1.0;
5+
public static timeScale = 1.0;
66

7-
private static _frameCount: number = 0;
8-
private static _lastTimer: number = 0.0;
9-
private static _beginTimer: number = 0.0;
10-
private static _unscaledTime: number = 0.0;
11-
private static _unscaledDeltaTime: number = 0.0;
7+
private static _frameCount = 0;
8+
private static _lastTimer = 0.0;
9+
private static _beginTimer = 0.0;
10+
private static _unscaledTime = 0.0;
11+
private static _unscaledDeltaTime = 0.0;
1212

1313

1414
public static initialize(): void {
15-
this._lastTimer = this._beginTimer = this.now;
15+
this._lastTimer = this._beginTimer = Date.now() * 0.001;
1616
}
1717

1818

1919
public static update(timer?: number): void {
20-
const now = timer || this.now;
20+
const now = timer || Date.now() * 0.001;
2121
this._frameCount += 1;
2222
this._unscaledTime = now - this._beginTimer;
2323
this._unscaledDeltaTime = now - this._lastTimer;
2424
this._lastTimer = now;
2525
}
2626

27-
28-
public static get now(): number {
29-
if (window.performance) {
30-
return window.performance.now() * 0.001;
31-
}
32-
else if (Date.now) {
33-
return Date.now() * 0.001;
34-
}
35-
36-
return new Date().getTime() * 0.001;
37-
}
38-
3927
public static get frameCount() {
4028
return this._frameCount;
4129
}

0 commit comments

Comments
 (0)