Skip to content

Commit 60f37b7

Browse files
authored
Merge pull request #12 from KBLLR/codex/define-functional-implementations-for-generators
Add generator class wrappers
2 parents bd488b9 + ab89423 commit 60f37b7

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { SceneManager } from '../managers/SceneManager';
2+
3+
/**
4+
* Basic wrapper around SceneManager to generate scenes from
5+
* configuration objects. This allows scenes to be created and
6+
* managed with a simple API while keeping the heavy lifting in
7+
* the existing managers.
8+
*/
9+
export class SceneGenerator {
10+
constructor(renderer) {
11+
this.manager = new SceneManager(renderer);
12+
}
13+
14+
/**
15+
* Create a new scene using the provided configuration.
16+
* @param {string} name - Identifier for the scene.
17+
* @param {object} [config={}] - Optional scene configuration.
18+
* @returns {THREE.Scene}
19+
*/
20+
create(name, config = {}) {
21+
return this.manager.createScene(name, config);
22+
}
23+
24+
/**
25+
* Set the active scene for rendering.
26+
* @param {string} name
27+
*/
28+
setActive(name) {
29+
this.manager.setActiveScene(name);
30+
}
31+
32+
/**
33+
* Update the active scene each frame.
34+
* @param {number} deltaTime
35+
*/
36+
update(deltaTime) {
37+
this.manager.update(deltaTime);
38+
}
39+
40+
/** Dispose all created scenes. */
41+
dispose() {
42+
this.manager.dispose();
43+
}
44+
}
45+
46+
export default SceneGenerator;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { StageManager } from '../managers/StageManager';
2+
3+
/**
4+
* Simple generator that delegates stage creation and management
5+
* to StageManager. This keeps configuration handling flexible
6+
* while exposing a minimal interface for external modules.
7+
*/
8+
export class StageGenerator {
9+
constructor(renderer, container) {
10+
this.manager = new StageManager(renderer, container);
11+
}
12+
13+
/**
14+
* Create a new stage using the provided configuration.
15+
* Convenience wrapper over StageManager.createStage.
16+
*
17+
* @param {string} name - Identifier for the stage.
18+
* @param {object} [config={}] - Optional stage configuration.
19+
* @returns {THREE.Scene}
20+
*/
21+
create(name, config = {}) {
22+
return this.manager.createStage(name, config);
23+
}
24+
25+
/** Proxy to StageManager.setActiveStage. */
26+
setActive(name) {
27+
this.manager.setActiveStage(name);
28+
}
29+
30+
/** Update the active stage each frame. */
31+
update(deltaTime) {
32+
this.manager.update(deltaTime);
33+
}
34+
35+
/** Resize the underlying renderer and cameras. */
36+
resize(width, height) {
37+
this.manager.resize(width, height);
38+
}
39+
40+
/** Dispose of all resources created by the generator. */
41+
dispose() {
42+
this.manager.dispose();
43+
}
44+
}
45+
46+
export default StageGenerator;

0 commit comments

Comments
 (0)