Skip to content

Commit

Permalink
fix(frameRate): render on small frameRate
Browse files Browse the repository at this point in the history
  • Loading branch information
lslzl3000 committed Nov 19, 2024
1 parent 5d8ef8c commit 8b685b9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Engine3D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,18 +437,18 @@ export class Engine3D {
private static async render(time: number) {
if (this._frameRateValue > 0) {
let delta = time - this._time;
while(delta < this._frameRateValue){
if(delta < this._frameRateValue){
let t = performance.now()
await Promise.resolve().then(()=>{
time += (performance.now() - t)
delta = time - this._time
await new Promise(res=>{
setTimeout(()=>{
time += (performance.now() - t)
res(true)
}, this._frameRateValue - delta)
})
}
this._time = time;
await this.updateFrame(time);
} else {
await this.updateFrame(time);
}
await this.updateFrame(time);
this.resume()

}
Expand Down

0 comments on commit 8b685b9

Please sign in to comment.