Skip to content

Commit

Permalink
🐛 Fix updating scene before loading is complete
Browse files Browse the repository at this point in the history
  • Loading branch information
mayacoda committed Nov 3, 2022
1 parent 0a0cd41 commit 1a3a83e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/engine/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export class Engine {
}

update(delta: number) {
if (!this.loader.isComplete) return

this.camera.update()
this.renderEngine.update()
this.experience.update(delta)
Expand Down
4 changes: 3 additions & 1 deletion src/engine/interface/Loader.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import './loader.scss'

export class Loader {
element: HTMLDivElement
private readonly element: HTMLDivElement
public isComplete = false

constructor() {
this.element = document.createElement('div')
Expand Down Expand Up @@ -39,5 +40,6 @@ export class Loader {

complete() {
this.element.remove()
this.isComplete = true
}
}

0 comments on commit 1a3a83e

Please sign in to comment.