diff --git a/packages/components/src/core/Worlds/example.ts b/packages/components/src/core/Worlds/example.ts index fcea83ca2..fff23da1e 100644 --- a/packages/components/src/core/Worlds/example.ts +++ b/packages/components/src/core/Worlds/example.ts @@ -6,7 +6,11 @@ const container = document.getElementById("container")!; const components = new OBC.Components(); const worlds = components.get(OBC.Worlds); -const world = new OBC.SimpleWorld(components); +const world = new OBC.SimpleWorld< + OBC.SimpleScene, + OBC.SimpleCamera, + OBC.SimpleRenderer +>(components); world.scene = new OBC.SimpleScene(components); world.renderer = new OBC.SimpleRenderer(components, container); diff --git a/packages/components/src/core/Worlds/src/simple-world.ts b/packages/components/src/core/Worlds/src/simple-world.ts index 73f0f174c..e79e3d35f 100644 --- a/packages/components/src/core/Worlds/src/simple-world.ts +++ b/packages/components/src/core/Worlds/src/simple-world.ts @@ -9,7 +9,14 @@ import { } from "../../Types"; import { Components } from "../../Components"; -export class SimpleWorld extends Base implements World { +export class SimpleWorld< + T extends BaseScene = BaseScene, + U extends BaseCamera = BaseCamera, + S extends BaseRenderer = BaseRenderer, + > + extends Base + implements World +{ readonly onAfterUpdate = new Event(); readonly onBeforeUpdate = new Event(); @@ -20,11 +27,11 @@ export class SimpleWorld extends Base implements World { readonly onDisposed = new Event(); - private _scene?: BaseScene; + private _scene?: T; - private _camera?: BaseCamera; + private _camera?: U; - private _renderer: BaseRenderer | null = null; + private _renderer: S | null = null; get scene() { if (!this._scene) { @@ -33,7 +40,7 @@ export class SimpleWorld extends Base implements World { return this._scene; } - set scene(scene: BaseScene) { + set scene(scene: T) { this._scene = scene; scene.worlds.set(this.uuid, this); scene.currentWorld = this; @@ -47,7 +54,7 @@ export class SimpleWorld extends Base implements World { return this._camera; } - set camera(camera: BaseCamera) { + set camera(camera: U) { this._camera = camera; camera.worlds.set(this.uuid, this); camera.currentWorld = this; @@ -58,7 +65,7 @@ export class SimpleWorld extends Base implements World { return this._renderer; } - set renderer(renderer: BaseRenderer | null) { + set renderer(renderer: S | null) { this._renderer = renderer; if (renderer) { renderer.worlds.set(this.uuid, this);