Skip to content

Commit

Permalink
fix: slow rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
gnlow committed Dec 4, 2023
1 parent 2be695a commit 519802a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class EntrySprite extends Sprite {
return sprite
}
clone(project: Entry) {
const sprite = new this.constructor()
const sprite = new (this.constructor as new () => this)()
sprite.textureIds = this.textureIds
sprite.currentTextureIndex = this.currentTextureIndex
sprite.texture = this.texture
Expand Down Expand Up @@ -210,6 +210,12 @@ export class Entry {
resolution: 4
})
parent.appendChild(this.renderer.canvas)

const loop = () => {
this.render()
requestAnimationFrame(loop)
}
requestAnimationFrame(loop)
}
emit(eventName: string) {
this.events[eventName].forEach(
Expand All @@ -228,7 +234,6 @@ export class Entry {
})
}
wait_tick() {
this.render()
return new Promise(o => {
requestAnimationFrame(o)
})
Expand All @@ -241,7 +246,6 @@ export class Entry {

/* 흐름 */
wait_second(sec: number) {
this.render()
return new Promise(o => {
setTimeout(o, sec * 1000)
})
Expand Down

0 comments on commit 519802a

Please sign in to comment.