Skip to content

Commit

Permalink
Update sceneManager.js
Browse files Browse the repository at this point in the history
  • Loading branch information
CleanCode-developer authored Dec 31, 2024
1 parent ca65f5b commit d50325a
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions js/sceneManager.js
Original file line number Diff line number Diff line change
@@ -1 +1,31 @@
class SceneManager {
constructor() {
this.scenes = [];
this.activeScene = null;
}

addScene(scene) {
this.scenes.push(scene);
if (!this.activeScene) {
this.activeScene = scene;
}
}

setActiveScene(sceneName) {
this.activeScene = this.scenes.find(scene => scene.name === sceneName);
}

update() {
if (this.activeScene) {
this.activeScene.update();
}
}

render(renderer) {
if (this.activeScene) {
renderer.render(this.activeScene);
}
}
}

export default SceneManager;

0 comments on commit d50325a

Please sign in to comment.